/// <summary> /// Writting the Log in the Errors tables of database /// </summary> /// <param name="ex">The Exception</param> /// <param name="sUserOrgId">The user's string from Context.User</param> /// <param name="sPageName">Current Page Name</param> internal static void Log(Exception ex, string sUserOrgId, string sPageName) { clsErrors _error = null; try { _error = new clsErrors(); _error.cAction = "U"; _error.iId = 0; if (sUserOrgId.Length > 0) { _error.iUserId = GetUserOrgId(sUserOrgId, true); _error.iOrgId = GetUserOrgId(sUserOrgId, false); } else { _error.iUserId = 6; _error.iOrgId = 1; } _error.sPageName = sPageName; _error.sErrorName = ex.Message; _error.daCreated = DateTime.Now; _error.sDesc = ex.ToString(); _error.ErrorDetail(); } catch { } finally { if (_error != null) { _error.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { try { if (Request.QueryString["id"] == null) { Session["lastpage"] = "error_report.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { ErrorId = Convert.ToInt32(Request.QueryString["id"]); } catch (FormatException fex) { Session["lastpage"] = "error_report.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } string [,] arrBrdCrumbs = new string [2, 2]; arrBrdCrumbs[0, 0] = "main.aspx"; arrBrdCrumbs[0, 1] = "Home"; arrBrdCrumbs[1, 0] = "error_report.aspx"; arrBrdCrumbs[1, 1] = "Error report"; PageTitle = "Error Detail"; Header.BrdCrumbs = ParseBreadCrumbs(arrBrdCrumbs, PageTitle); Header.PageTitle = PageTitle; lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='error_report.aspx'\">"; if (!IsPostBack) { error = new clsErrors(); error.cAction = "S"; error.iId = ErrorId; if (error.ErrorDetail() != -1) { lblCreated.Text = error.daCreated.Value.ToString("g"); lblDesc.Text = error.sDesc.Value; lblErrorMessage.Text = error.sErrorName.Value; lblOrg.Text = error.sOrgName.Value; lblPageName.Text = error.sPageName.Value; lblUserName.Text = error.sUserName.Value; } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(115); Response.Redirect("error.aspx", false); } } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, "error_report.aspx.cs"); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (error != null) { error.Dispose(); } } }