private BcLogErrorEntity PrepareFormData() { //TODO:需要校验参数的合法性 var entity = new BcLogErrorEntity(); entity.Id = int.Parse(this.txtId.Text); entity.UserId = int.Parse(this.txtUserId.Text); entity.UserName = this.txtUserName.Text; entity.OpUrl = this.txtOpUrl.Text; entity.OpTime = DateTime.Parse(this.txtOpTime.Text); entity.OpHostAddress = this.txtOpHostAddress.Text; entity.OpHostName = this.txtOpHostName.Text; entity.OpUserAgent = this.txtOpUserAgent.Text; entity.OpQueryString = this.txtOpQueryString.Text; entity.OpHttpMethod = this.txtOpHttpMethod.Text; entity.Message = this.txtMessage.Text; return entity; }
public void UpdateBcLogError(BcLogErrorEntity entity) { EntityExecution.UpdateEntity(entity); }
public void AddNewBcLogError(BcLogErrorEntity entity) { entity.Id = null; EntityExecution.InsertEntity(entity); }
public void DeleteBcLogError(int id) { BcLogErrorEntity entity = new BcLogErrorEntity() { Id = id }; EntityExecution.DeleteEntity(entity); }
protected void Application_Error(object sender, EventArgs e) { string errorLogPath = Server.MapPath("/TempFile/ErrorLogPath"); string errorPage = "/CustomPage/error.html"; Exception ex = null; try { ex = Server.GetLastError().GetBaseException(); var sysSettingEntity = new SysGlobalSettingBiz().GetSysSettingEntity(); errorLogPath = Server.MapPath(sysSettingEntity.ErrorLogPath); errorPage = sysSettingEntity.ErrorPage; BcUserInfoEntity userInfo = null; var identity = HttpContext.Current.User.Identity as FormsIdentity; if (identity != null) userInfo = new BcUserInfoBiz().GetBcUserInfoWithPermission(identity.Ticket.UserData); var entity = new BcLogErrorEntity(); if (userInfo != null) { entity.UserId = userInfo.UserId; entity.UserName = userInfo.UserName; } else { entity.UserId = 0; entity.UserName = ""; } entity.OpUrl = Request.Url.ToString(); entity.OpTime = DateTime.Now; entity.OpHostAddress = Request.UserHostAddress; entity.OpHostName = Request.UserHostName; entity.OpUserAgent = Request.UserAgent; entity.OpQueryString = Request.QueryString.ToString(); entity.OpHttpMethod = Request.HttpMethod; entity.Message = ex.ToString(); try { new BcLogErrorBiz().AddNewBcLogError(entity); } catch (Exception ex2) { WriteLocalLog(errorLogPath, ex.ToString()); WriteLocalLog(errorLogPath, ex2.ToString()); } } catch (Exception ex3) { if (ex != null) WriteLocalLog(errorLogPath, ex.ToString()); WriteLocalLog(errorLogPath, ex3.ToString()); } finally { if (!ConfigHelper.GetConfigBool("IsDevelopMode")) { Server.ClearError(); Response.Redirect(errorPage); } } }