void Application_Error(object sender, EventArgs e) { ErrorDAL DAL = new ErrorDAL(); Exception ex = Server.GetLastError().GetBaseException(); var requestUrl = Request.Url.ToString(); DAL.InsertErrorLog(requestUrl, ex.Message, ex.StackTrace); if (ex is HttpException) { if (((HttpException)ex).GetHttpCode() == 404) { Response.Redirect("/Error/Error404", true); } } else { string excMessageSafe = Regex.Replace(ex.ToString(), "(\\<+[a-z!/\\?])|(&\\#)", new MatchEvaluator((m) => { return(m.Value.Replace("<", string.Empty).Replace("&#", string.Empty)); }), RegexOptions.IgnoreCase); //string errorDetailsQueryString = System.Web.Configuration.WebConfigurationManager.AppSettings["show_detailed_errors"] == "true" ? "?ErrorTitle=" + HttpUtility.UrlPathEncode(exc.GetType().Name) + "ErrorMessage" + HttpUtility.UrlPathEncode(excMessageSafe.Substring(0, 1200)) : ""; Response.Redirect("/Error/Error500", true); } }
protected void Page_Load(object sender, EventArgs e) { DateTime sd = DateTime.Now; DateTime ed; try { if (!Page.IsPostBack) { CtlAgreementPercent111.NotDefaultAgree = true; CtlAgreementPercent111.AgreementID = Convert.ToInt32(Request.QueryString["aid"]); CtlAgreementPercent111.onlyActive = 0; CtlAgreementPercent111.BindDD(); CtlAgreementPercent111.BindGrid(); CtlAgreementPercent111.NotDefaultAgree = true; } CtlAgreementPercent111.Bindtbljarime(); } catch (Exception ex) { ed = DateTime.Now; var lineNumber = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); clError cl = new clError(); cl.ErrorLog = ex.Message.ToString(); cl.Page = HttpContext.Current.Request.Url.OriginalString; cl.timeLeft = (ed - sd).TotalSeconds.ToString(); cl.IP = CSharp.PublicFunction.GetIPAddress(); ErrorDAL.insert(cl); } }
protected override void OnException(ExceptionContext filterContext) { ErrorDAL DAL = new ErrorDAL(); filterContext.ExceptionHandled = true; var ex = filterContext.Exception; // TPDO : Log Exception var requestUrl = Request.Url.ToString(); DAL.InsertErrorLog(requestUrl, ex.Message, ex.StackTrace); #region Use full Code if (filterContext.HttpContext.Request.IsAjaxRequest()) { var urlHelper = new UrlHelper(filterContext.RequestContext); filterContext.HttpContext.Response.StatusCode = 403; filterContext.Result = new JsonResult { Data = new { Error = ex.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } else { if (ex is HttpException) { if (((HttpException)ex).GetHttpCode() == 404) { //Redirect to 404 page: filterContext.Result = RedirectToAction("Error404", "Error"); } } else { string excMessageSafe = Regex.Replace(ex.ToString(), "(\\<+[a-z!/\\?])|(&\\#)", new MatchEvaluator((m) => { return(m.Value.Replace("<", string.Empty).Replace("&#", string.Empty)); }), RegexOptions.IgnoreCase); // Redirect on error: //var ErrorObject = System.Web.Configuration.WebConfigurationManager.AppSettings["show_detailed_errors"] == "true" ? new { ErrorTitle = ex.GetType().Name, ErrorMessage = excMessageSafe.Substring(0, 1400) } : null; filterContext.Result = RedirectToAction("Error500", "Error"); } } #endregion }
public void BindGrid() { DateTime sd = DateTime.Now; DateTime ed; try { ClAgreementPercent cl = new ClAgreementPercent(); cl.AgreementID = Convert.ToInt32(AgreementID); cl.ExplainID = DDExplainID.SelectedValue; cl.VisitDate = DateConvert.sh2m(txtdatetimenow.Text).ToString(); DataSet ds = AgreementPercentClass.GetList_inmonth(cl); DataView dv = new DataView(ds.Tables[0]); if (ViewState["AgreementPercentID"] == null) { ViewState["AgreementPercentID"] = "AgreementPercentID Desc"; } dv.Sort = Securenamespace.SecureData.CheckSecurity(ViewState["AgreementPercentID"].ToString()).ToString(); GridView1.DataSource = dv; GridView1.DataBind(); txtunitNumberNazer.Text = unitNumberDEfault(Convert.ToInt32(AgreementID), Convert.ToInt32(DDExplainID.SelectedValue)).ToString(); LBLunitNumberNazer.Text = unitNumberDEfault(Convert.ToInt32(AgreementID), Convert.ToInt32(DDExplainID.SelectedValue)).ToString(); RowColor(); ds.Dispose(); } catch (Exception ex) { ed = DateTime.Now; var lineNumber = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); clError cl = new clError(); cl.ErrorLog = ex.Message.ToString(); cl.Page = HttpContext.Current.Request.Url.OriginalString; cl.timeLeft = (ed - sd).TotalSeconds.ToString(); cl.IP = CSharp.PublicFunction.GetIPAddress(); ErrorDAL.insert(cl); } }
public static DataTable GetError(DateTime DateFrom, DateTime DateTo, int StartRow, int MaxRow) { DataTable dt = null; try { dt = ErrorDAL.GetError(DateFrom, DateTo, StartRow, MaxRow); return(dt); } catch (Exception ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } } }
public void BindDD() { DateTime sd = DateTime.Now; DateTime ed; try { ClAgreement cl = new ClAgreement(); DDAgreementID.DataSource = AgreementClass.GetList(cl); DDAgreementID.DataTextField = "AgreeName"; DDAgreementID.DataValueField = "AgreementID"; DDAgreementID.DataBind(); DDSuperVisorID.DataSource = TaxiDAL.UsersClass.GetListNazer(null, null, null, null, null, null, "600", null, null, null, null); DDSuperVisorID.DataTextField = "FullNameUser"; DDSuperVisorID.DataValueField = "UserID"; DDSuperVisorID.DataBind(); DDExplainID.Bind(); CtlAgreePercentProtest1.BindDD(); Bindtbljarime(); DDExplainID.AutoPostBackExplan = true; } catch (Exception ex) { ed = DateTime.Now; var lineNumber = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); clError cl = new clError(); cl.ErrorLog = ex.Message.ToString(); cl.Page = HttpContext.Current.Request.Url.OriginalString; cl.timeLeft = (ed - sd).TotalSeconds.ToString(); cl.IP = CSharp.PublicFunction.GetIPAddress(); ErrorDAL.insert(cl); } }
protected void Application_Error(object sender, EventArgs e) { HttpException lastErrorWrapper = Server.GetLastError() as HttpException; Exception lastError = lastErrorWrapper; if (lastErrorWrapper.InnerException != null) { lastError = lastErrorWrapper.InnerException; } string lastErrorTypeName = lastError.GetType().ToString(); string lastErrorMessage = lastError.Message; string lastErrorStackTrace = lastError.StackTrace; string page = HttpContext.Current.Request.Url.OriginalString; clError cl = new clError(); cl.ErrorLog = lastErrorMessage + ":Type:" + lastErrorTypeName + ":ST:" + lastErrorStackTrace; cl.Page = page; cl.IP = CSharp.PublicFunction.GetIPAddress(); //string sql = " insert into Tbl_ErrorLog(ErrorLog,createDate)values(N'" + "pagr:" + page + Securenamespace.SecureData.CheckSecurity(lastErrorMessage.ToString() + "IP" + CSharp.PublicFunction.GetIPAddress().ToString()) + "',getdate())"; //System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection(CSharp.PublicFunction.cnstr()); //System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, cnn); //cmd.CommandType = System.Data.CommandType.Text; try { int i = ErrorDAL.insert(cl); //cnn.Open(); //cmd.ExecuteNonQuery(); } catch { } finally { } //// Response.Redirect("~/ErrorPage.aspx"); }
public static void InsertError(string sError, string sDescription, string sPageName, DateTime dDate, DateTime dDateGMT, string sUser) { ErrorDAL.InsertError(sError, sDescription, sPageName, dDate, dDateGMT, sUser); }
public static int GetErrorCount(DateTime DateFrom, DateTime DateTo) { return(ErrorDAL.GetErrorCount(DateFrom, DateTo)); }