using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using FileUploadDAL;
/// <summary>
/// Summary description for SAM
/// </summary>
namespace FileUploadSAM
{
public class SAM
{
public SAM()
{
}
public class UploadFile
{
public static DataTable CustomTableData(string procedurename, params SqlParameter[] p)
{
return DataAccess.GetFromDataTable(procedurename, p);
}
//Insert logFile details
public static int InsertLogFile(LogFile lf)
{
SqlParameter[] p = new SqlParameter[5];
p[0] = new SqlParameter("@UserID", lf.UserID);
p[1] = new SqlParameter("@UserType", lf.UserType);
p[2] = new SqlParameter("@UserLog", lf.UserLog);
p[3] = new SqlParameter("@IPAddress", lf.IPAddress);
p[4] = new SqlParameter("@EntryDate", lf.EntryDate);
return DataAccess.Execute("InsertLogFile", p);
}
//Insert FileUpload Details from User End
public static int UserUploadFile(UserUploadFile UF)
{
SqlParameter[] p = new SqlParameter[7];
p[0] = new SqlParameter("@EntryDate", UF.EntryDate );
p[1] = new SqlParameter("@UserID", UF.UserID );
p[2] = new SqlParameter("@UIPAddress", UF.UIPAddress );
p[3] = new SqlParameter("@Titile", UF.Titile );
p[4] = new SqlParameter("@FilePath", UF.FilePath );
p[5] = new SqlParameter("@FileSize", UF.FileSize);
p[6] = new SqlParameter("@Remark", UF.Remark );
return DataAccess.Execute("InsertUserUploadFile", p);
}
public static DataTable GetDownloadFileDetail(string FUPID)
{
SqlParameter[] p = new SqlParameter[1];
p[0] = new SqlParameter("@FUPID", FUPID);
return DataAccess.GetFromDataTable("GetDownloadFileDetail", p);
}
public static DataTable GetDownloadFileDetailbyDate(string FromDate,string ToDate)
{
SqlParameter[] p = new SqlParameter[2];
p[0] = new SqlParameter("@DateFrom", FromDate);
p[1] = new SqlParameter("@DateTo", ToDate);
return DataAccess.GetFromDataTable("GetDownloadFileDetailbyDate", p);
}
}
public static string GetIPAddress()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
string sIPAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(sIPAddress))
{
return context.Request.ServerVariables["REMOTE_ADDR"];
}
else
{
string[] ipArray = sIPAddress.Split(new Char[] { ',' });
return ipArray[0];
}
}
public static DateTime getDateTime()
{
TimeSpan t = new TimeSpan(5, 30, 0);
DateTime currentDate = DateTime.UtcNow.Add(t);
return currentDate;
}
//Alert massege box
public static void alert(string customMessage, string redirectPageAbsolutePath, bool redirectAfterShowing)
{
Page current_page = (Page)HttpContext.Current.Handler;
string script_name = "scpt_" + DateTime.Now.Millisecond.ToString();
string script = "alert('" + customMessage.Replace("'", "\\'") + "');";
if (redirectAfterShowing == true)
{
if (!string.IsNullOrEmpty(redirectPageAbsolutePath))
{
script = script + "window.location.href='" + current_page.ResolveUrl(redirectPageAbsolutePath) + "';";
}
}
if (ScriptManager.GetCurrent(current_page) == null)
{
current_page.ClientScript.RegisterStartupScript(current_page.GetType(), script_name, script, true);
}
else
{
if (ScriptManager.GetCurrent(current_page).IsInAsyncPostBack == true)
{
ScriptManager.RegisterStartupScript(current_page, current_page.GetType(), Guid.NewGuid().ToString(), script, true);
}
else
{
current_page.ClientScript.RegisterStartupScript(current_page.GetType(), script_name, script, true);
}
}
}
}
}
//trim and replace fuction for sqlinjection
public static class StringExtensions
{
public static string TrimAndReplace(this string s)
{
return s.Trim().Replace("'", "").Replace(""", "").Replace("AUX ", "").Replace("CLOCK$", "").Replace("CON ", "").Replace("CONFIG$ ", "").Replace("NUL ", "").Replace(";", "").Replace("--", "").Replace("/*...*/", "").Replace("xp_", "").Replace("DROP ", "");
}
public static string TrimAndReplaceText(this string s)
{
return s.Trim().Replace(" ", "").Replace("'", "").Replace(""", "").Replace("AUX ", "").Replace("CLOCK$", "").Replace("CON ", "").Replace("CONFIG$ ", "").Replace("NUL ", "").Replace(";", "").Replace("--", "").Replace("/*...*/", "").Replace("xp_", "").Replace("DROP ", "");
}
}
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using FileUploadDAL;
/// <summary>
/// Summary description for SAM
/// </summary>
namespace FileUploadSAM
{
public class SAM
{
public SAM()
{
}
public class UploadFile
{
public static DataTable CustomTableData(string procedurename, params SqlParameter[] p)
{
return DataAccess.GetFromDataTable(procedurename, p);
}
//Insert logFile details
public static int InsertLogFile(LogFile lf)
{
SqlParameter[] p = new SqlParameter[5];
p[0] = new SqlParameter("@UserID", lf.UserID);
p[1] = new SqlParameter("@UserType", lf.UserType);
p[2] = new SqlParameter("@UserLog", lf.UserLog);
p[3] = new SqlParameter("@IPAddress", lf.IPAddress);
p[4] = new SqlParameter("@EntryDate", lf.EntryDate);
return DataAccess.Execute("InsertLogFile", p);
}
//Insert FileUpload Details from User End
public static int UserUploadFile(UserUploadFile UF)
{
SqlParameter[] p = new SqlParameter[7];
p[0] = new SqlParameter("@EntryDate", UF.EntryDate );
p[1] = new SqlParameter("@UserID", UF.UserID );
p[2] = new SqlParameter("@UIPAddress", UF.UIPAddress );
p[3] = new SqlParameter("@Titile", UF.Titile );
p[4] = new SqlParameter("@FilePath", UF.FilePath );
p[5] = new SqlParameter("@FileSize", UF.FileSize);
p[6] = new SqlParameter("@Remark", UF.Remark );
return DataAccess.Execute("InsertUserUploadFile", p);
}
public static DataTable GetDownloadFileDetail(string FUPID)
{
SqlParameter[] p = new SqlParameter[1];
p[0] = new SqlParameter("@FUPID", FUPID);
return DataAccess.GetFromDataTable("GetDownloadFileDetail", p);
}
public static DataTable GetDownloadFileDetailbyDate(string FromDate,string ToDate)
{
SqlParameter[] p = new SqlParameter[2];
p[0] = new SqlParameter("@DateFrom", FromDate);
p[1] = new SqlParameter("@DateTo", ToDate);
return DataAccess.GetFromDataTable("GetDownloadFileDetailbyDate", p);
}
}
public static string GetIPAddress()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
string sIPAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(sIPAddress))
{
return context.Request.ServerVariables["REMOTE_ADDR"];
}
else
{
string[] ipArray = sIPAddress.Split(new Char[] { ',' });
return ipArray[0];
}
}
public static DateTime getDateTime()
{
TimeSpan t = new TimeSpan(5, 30, 0);
DateTime currentDate = DateTime.UtcNow.Add(t);
return currentDate;
}
//Alert massege box
public static void alert(string customMessage, string redirectPageAbsolutePath, bool redirectAfterShowing)
{
Page current_page = (Page)HttpContext.Current.Handler;
string script_name = "scpt_" + DateTime.Now.Millisecond.ToString();
string script = "alert('" + customMessage.Replace("'", "\\'") + "');";
if (redirectAfterShowing == true)
{
if (!string.IsNullOrEmpty(redirectPageAbsolutePath))
{
script = script + "window.location.href='" + current_page.ResolveUrl(redirectPageAbsolutePath) + "';";
}
}
if (ScriptManager.GetCurrent(current_page) == null)
{
current_page.ClientScript.RegisterStartupScript(current_page.GetType(), script_name, script, true);
}
else
{
if (ScriptManager.GetCurrent(current_page).IsInAsyncPostBack == true)
{
ScriptManager.RegisterStartupScript(current_page, current_page.GetType(), Guid.NewGuid().ToString(), script, true);
}
else
{
current_page.ClientScript.RegisterStartupScript(current_page.GetType(), script_name, script, true);
}
}
}
}
}
//trim and replace fuction for sqlinjection
public static class StringExtensions
{
public static string TrimAndReplace(this string s)
{
return s.Trim().Replace("'", "").Replace(""", "").Replace("AUX ", "").Replace("CLOCK$", "").Replace("CON ", "").Replace("CONFIG$ ", "").Replace("NUL ", "").Replace(";", "").Replace("--", "").Replace("/*...*/", "").Replace("xp_", "").Replace("DROP ", "");
}
public static string TrimAndReplaceText(this string s)
{
return s.Trim().Replace(" ", "").Replace("'", "").Replace(""", "").Replace("AUX ", "").Replace("CLOCK$", "").Replace("CON ", "").Replace("CONFIG$ ", "").Replace("NUL ", "").Replace(";", "").Replace("--", "").Replace("/*...*/", "").Replace("xp_", "").Replace("DROP ", "");
}
}