예제 #1
0
 private BcLogErrorEntity PrepareFormData()
 {
     //TODO:需要校验参数的合法性
     var entity = new BcLogErrorEntity();
     entity.Id = int.Parse(txtId.Text);
     entity.UserId = int.Parse(txtUserId.Text);
     entity.UserName = txtUserName.Text;
     entity.OpUrl = txtOpUrl.Text;
     entity.OpTime = DateTime.Parse(txtOpTime.Text);
     entity.OpHostAddress = txtOpHostAddress.Text;
     entity.OpHostName = txtOpHostName.Text;
     entity.OpUserAgent = txtOpUserAgent.Text;
     entity.OpQueryString = txtOpQueryString.Text;
     entity.OpHttpMethod = txtOpHttpMethod.Text;
     entity.Message = txtMessage.Text;
     return entity;
 }
예제 #2
0
 public void UpdateBcLogError(BcLogErrorEntity entity)
 {
     entity.Update();
 }
예제 #3
0
 public void AddNewBcLogError(BcLogErrorEntity entity)
 {
     entity.Id = null;
     entity.Insert();
 }
예제 #4
0
 public void DeleteBcLogError(int id)
 {
     BcLogErrorEntity entity = new BcLogErrorEntity() {Id = id};
     EntityExecution.Delete(entity);
 }
예제 #5
0
        protected void Application_Error(object sender, EventArgs e)
        {
            var errorLogPath = Server.MapPath("/TempFile/ErrorLogPath");
            var 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);
                }
            }
        }