Example #1
0
        private void ShowErrorMessageForm_Load(object sender, EventArgs e)
        {
            this.tbErrorInfo.Text = this.ecInfo;
            this.reportContent.Append("组织机构:" + ConfigHelper.GetNode("orgName") + " 编号:" + ConfigHelper.GetNode("orgCode") + "\r\n");
            Ping ping = new Ping();

            try
            {
                if ((PadForm.netStatus == "1") && (ping.Send("smtp.163.com").Status == IPStatus.Success))
                {
                    this.btnReport.Enabled = true;
                }
            }
            catch (Exception)
            {
            }
            if (!this.btnReport.Enabled)
            {
                SystemErrorLogBLL report = new SystemErrorLogBLL();
                report.CheckTable("SystemErrorLog");
                SystemErrorLogModel model = new SystemErrorLogModel
                {
                    CreateDate = new DateTime?(DateTime.Now),
                    IDCardNo   = PadForm.idNo,
                    LogData    = this.exp.ToString(),
                    Message    = this.exp.Message,
                    SendEd     = "0",
                    StackTrace = this.exp.StackTrace,
                    TargetSite = this.exp.TargetSite.ToString()
                };
                report.Add(model);
            }
        }
Example #2
0
        protected void Application_Error(object sender, EventArgs e)
        {
            Exception           LastError = Server.GetLastError();
            SystemErrorLogModel SELM      = new SystemErrorLogModel();

            SELM.ErrorType    = LastError.GetType().FullName;
            SELM.ErrorMessage = LastError.Message;
            SELM.PathAndQuery = Request.Url.PathAndQuery;
            SELM.ClientIP     = Request.UserHostAddress;
            SELM.ErrorTime    = DateTime.Now;
            SELM.StackTrace   = LastError.StackTrace.Replace("\r\n", "<br/>");
            new SystemErrorLogBLL().Add(SELM);
        }
Example #3
0
        public int Add(SystemErrorLogModel model)
        {
            DbCommand cmd = db.GetStoredProcCommand("PROC_T_SYS_SystemErrorLogAdd");

            db.AddInParameter(cmd, "@ErrorType", DbType.String, model.ErrorType);
            db.AddInParameter(cmd, "@ErrorMessage", DbType.String, model.ErrorMessage);
            db.AddInParameter(cmd, "@PathAndQuery", DbType.String, model.PathAndQuery);
            db.AddInParameter(cmd, "@ClientIP", DbType.String, model.ClientIP);
            db.AddInParameter(cmd, "@ErrorTime", DbType.DateTime, model.ErrorTime);
            db.AddInParameter(cmd, "@StackTrace", DbType.String, model.StackTrace);
            int i = db.ExecuteNonQuery(cmd);

            return(i);
        }
Example #4
0
        public SystemErrorLogModel DataRowToModel(DataRow row)
        {
            SystemErrorLogModel report = new SystemErrorLogModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    report.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["LogData"] != null) && (row["LogData"] != DBNull.Value))
                {
                    report.LogData = row["LogData"].ToString();
                }
                if ((row["Message"] != null) && (row["Message"] != DBNull.Value))
                {
                    report.Message = row["Message"].ToString();
                }
                if ((row["StackTrace"] != null) && (row["StackTrace"] != DBNull.Value))
                {
                    report.StackTrace = row["StackTrace"].ToString();
                }
                if ((row["TargetSite"] != null) && (row["TargetSite"] != DBNull.Value))
                {
                    report.TargetSite = row["TargetSite"].ToString();
                }
                if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value))
                {
                    report.IDCardNo = row["IDCardNo"].ToString();
                }
                if (((row["CreateDate"] != null) && (row["CreateDate"] != DBNull.Value)) && (row["CreateDate"].ToString() != ""))
                {
                    report.CreateDate = new DateTime?(DateTime.Parse(row["CreateDate"].ToString()));
                }
                if ((row["SendEd"] != null) && (row["SendEd"] != DBNull.Value))
                {
                    report.SendEd = row["SendEd"].ToString();
                }
                if (((row["SendDate"] != null) && (row["SendDate"] != DBNull.Value)) && (row["SendDate"].ToString() != ""))
                {
                    report.SendDate = new DateTime?(DateTime.Parse(row["SendDate"].ToString()));
                }
            }
            return(report);
        }
Example #5
0
        public List <SystemErrorLogModel> DataTableToList(DataTable dt)
        {
            List <SystemErrorLogModel> list = new List <SystemErrorLogModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    SystemErrorLogModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Example #6
0
        public string GetSystemErrorLog(HttpContext context)
        {
            string PageIndex          = context.Request["page"] == null ? "" : context.Request["page"].ToString();
            string PageSize           = context.Request["rows"] == null ? "" : context.Request["rows"].ToString();
            string LogJson            = "";
            SystemErrorLogModel model = new SystemErrorLogModel();

            model.PageIndex = string.IsNullOrEmpty(PageIndex) ? 1 : Convert.ToInt32(PageIndex);
            model.PageSize  = string.IsNullOrEmpty(PageSize) ? 10 : Convert.ToInt32(PageSize);
            List <SystemErrorLogModel> List = SELBLL.GetList(model);

            LogJson = "{\"total\":" + model.OUTTotalCount + ",\"rows\":[";
            foreach (SystemErrorLogModel item in List)
            {
                LogJson += "{\"ID\":\"" + item.ID + "\",\"ErrorType\":\"" + item.ErrorType + "\",\"ErrorMessage\":\"" + item.ErrorMessage + "\",\"PathAndQuery\":\"" + item.PathAndQuery + "\",\"ClientIP\":\"" + item.ClientIP + "\",\"ErrorTime\":\"" + item.ErrorTime + "\",\"StackTrace\":\"" + item.StackTrace + "\"},";
            }
            LogJson  = LogJson.TrimEnd(',');
            LogJson += "]}";
            return(LogJson);
        }
Example #7
0
        public List <SystemErrorLogModel> GetList(SystemErrorLogModel model)
        {
            List <SystemErrorLogModel> List = new List <SystemErrorLogModel>();

            string[]        strPara     = new string[] { "@PageIndex", "@PageSize", "@OUTTotalCount" };
            ParameterMapper mapper      = new ParameterMapper(strPara);
            var             ObjectModel = db.CreateSprocAccessor <SystemErrorLogModel>("PROC_T_SYS_GetSystemErrorLogList", mapper, MapBuilder <SystemErrorLogModel> .MapNoProperties()
                                                                                       .Map(p => p.ID).ToColumn("ID")
                                                                                       .Map(p => p.ErrorType).ToColumn("ErrorType")
                                                                                       .Map(p => p.ErrorMessage).ToColumn("ErrorMessage")
                                                                                       .Map(p => p.PathAndQuery).ToColumn("PathAndQuery")
                                                                                       .Map(p => p.ClientIP).ToColumn("ClientIP")
                                                                                       .Map(p => p.ErrorTime).ToColumn("ErrorTime")
                                                                                       .Map(p => p.StackTrace).ToColumn("StackTrace")
                                                                                       .Build()
                                                                                       );

            object[] param = { model.PageIndex, model.PageSize, model.OUTTotalCount };
            List = ObjectModel.Execute(param).ToList <SystemErrorLogModel>();
            model.OUTTotalCount = int.Parse(mapper.GetParameterValue("@OUTTotalCount").ToString());
            return(List);
        }
Example #8
0
        public bool Update(SystemErrorLogModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update SYS_ERROR_LOG set ");
            builder.Append("LogData=@LogData,");
            builder.Append("Message=@Message,");
            builder.Append("StackTrace=@StackTrace,");
            builder.Append("TargetSite=@TargetSite,");
            builder.Append("IDCardNo=@IDCardNo,");
            builder.Append("CreateDate=@CreateDate,");
            builder.Append("SendEd=@SendEd,");
            builder.Append("SendDate=@SendDate");
            builder.Append(" where ID=@ID");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@LogData", MySqlDbType.String),
                new MySqlParameter("@Message", MySqlDbType.String),
                new MySqlParameter("@StackTrace", MySqlDbType.String),
                new MySqlParameter("@TargetSite", MySqlDbType.String),
                new MySqlParameter("@IDCardNo", MySqlDbType.String),
                new MySqlParameter("@CreateDate", MySqlDbType.Date),
                new MySqlParameter("@SendEd", MySqlDbType.String, 1),
                new MySqlParameter("@SendDate", MySqlDbType.Date),
                new MySqlParameter("@ID", MySqlDbType.Int32, 8)
            };

            cmdParms[0].Value = model.LogData;
            cmdParms[1].Value = model.Message;
            cmdParms[2].Value = model.StackTrace;
            cmdParms[3].Value = model.TargetSite;
            cmdParms[4].Value = model.IDCardNo;
            cmdParms[5].Value = model.CreateDate;
            cmdParms[6].Value = model.SendEd;
            cmdParms[7].Value = model.SendDate;
            cmdParms[8].Value = model.ID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Example #9
0
        public int Add(SystemErrorLogModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into SYS_ERROR_LOG(");
            builder.Append("LogData,Message,StackTrace,TargetSite,IDCardNo,CreateDate,SendEd,SendDate)");
            builder.Append(" values (");
            builder.Append("@LogData,@Message,@StackTrace,@TargetSite,@IDCardNo,@CreateDate,@SendEd,@SendDate)");
            builder.Append(";select @@IDENTITY");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@LogData", MySqlDbType.String),
                new MySqlParameter("@Message", MySqlDbType.String),
                new MySqlParameter("@StackTrace", MySqlDbType.String),
                new MySqlParameter("@TargetSite", MySqlDbType.String),
                new MySqlParameter("@IDCardNo", MySqlDbType.String),
                new MySqlParameter("@CreateDate", MySqlDbType.Date),
                new MySqlParameter("@SendEd", MySqlDbType.String, 1),
                new MySqlParameter("@SendDate", MySqlDbType.Date)
            };
            cmdParms[0].Value = model.LogData;
            cmdParms[1].Value = model.Message;
            cmdParms[2].Value = model.StackTrace;
            cmdParms[3].Value = model.TargetSite;
            cmdParms[4].Value = model.IDCardNo;
            cmdParms[5].Value = model.CreateDate;
            cmdParms[6].Value = model.SendEd;
            cmdParms[7].Value = model.SendDate;
            object single = MySQLHelper.GetSingle(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
Example #10
0
 public List <SystemErrorLogModel> GetList(SystemErrorLogModel model)
 {
     return(DAL.GetList(model));
 }
Example #11
0
 public int Add(SystemErrorLogModel model)
 {
     return(DAL.Add(model));
 }
Example #12
0
 public int Add(SystemErrorLogModel model)
 {
     return(this.dal.Add(model));
 }
Example #13
0
 public bool Update(SystemErrorLogModel model)
 {
     return(this.dal.Update(model));
 }