public static void WriteLine(int mqpathid, string mqpath, string methodname, string msg, Exception exp) { if (!string.IsNullOrWhiteSpace(ConfigHelper.LogDBConnectString)) { try { SqlHelper.ExcuteSql(ConfigHelper.LogDBConnectString, (c) => { tb_error_dal dal = new tb_error_dal(); dal.Add(c, new tb_error_model() { createtime = DateTime.Now, info = string.Format("错误:{0},exp:{1}", msg.NullToEmpty(), exp.Message.NullToEmpty()), mqpath = mqpath.NullToEmpty(), mqpathid = mqpathid, methodname = methodname.NullToEmpty() }); }); } catch (Exception e1) { XXF.Log.ErrorLog.Write(string.Format("BusinessMQ插入错误信息时发生错误,mqpathid:{0},mqpath:{1},methodname:{2},msg:{3}", mqpathid, mqpath.NullToEmpty(), methodname.NullToEmpty(), msg.NullToEmpty()), e1); } } else { XXF.Log.ErrorLog.Write(string.Format("BusinessMQ错误,mqpathid:{0},mqpath:{1},methodname:{2},msg:{3}", mqpathid, mqpath.NullToEmpty(), methodname.NullToEmpty(), msg.NullToEmpty()), exp); } DebugHelper.WriteLine(mqpathid, mqpath, methodname, "【出错】:" + msg + "exp:" + exp.Message + "strace:" + exp.StackTrace); }
public override void Run() { var tempinfo = this.OpenOperator.GetDataBaseTempData <TaskManageErrorSendTaskTempInfo>(); if (tempinfo == null) { tempinfo = new TaskManageErrorSendTaskTempInfo(); tempinfo.LastLogID = 0; } //扫描 List <tb_senderror_model> senderrormodels = new List <tb_senderror_model>(); List <tb_user_model> usermodels = new List <tb_user_model>(); SqlHelper.ExcuteSql(this.SystemRuntimeInfo.TaskConnectString, (c) => { tb_error_dal errordal = new tb_error_dal(); senderrormodels = errordal.GetErrors(c, tempinfo.LastLogID); tb_user_dal userdal = new tb_user_dal(); usermodels = userdal.GetAllUsers(c); }); foreach (var u in usermodels) { if (string.IsNullOrEmpty(u.useremail)) { continue; } if (u.userrole == (int)EnumUserRole.Admin) { SendEmail(senderrormodels, u.useremail); } else { SendEmail(senderrormodels.Where(c => c.taskcreateuserid == u.id).ToList(), u.useremail); } } if (senderrormodels.Count > 0) { int maxid = senderrormodels.Max(c => c.error_model.id); tempinfo.LastLogID = maxid; this.OpenOperator.Log(string.Format("本次处理错误日志{0}条", senderrormodels.Count)); } this.OpenOperator.SaveDataBaseTempData(tempinfo); }
/// <summary> /// 添加错误日志 /// </summary> /// <param name="model"></param> public static void AddError(tb_error_model model) { try { AddLog(new tb_log_model { logcreatetime = model.errorcreatetime, logtype = model.errortype, msg = model.msg, taskid = model.taskid }); SqlHelper.ExcuteSql(Config.TaskConnectString, (c) => { tb_error_dal errordal = new tb_error_dal(); model.msg = model.msg.SubString2(1000); errordal.Add2(c, model); }); } catch (Exception exp) { XXF.Log.ErrorLog.Write("添加错误日志至数据库出错", exp); } }
// // GET: /Log/ public ActionResult ErrorLog(string keyword, string CStime, string CEtime, int id = -1, int errortype = -1, int taskid = -1, int nodeid = -1, int pagesize = 10, int pageindex = 1) { return(this.Visit(Core.EnumUserRole.None, () => { int count = 0; using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString)) { ViewBag.keyword = keyword; ViewBag.CStime = CStime; ViewBag.CEtime = CEtime; ViewBag.id = id; ViewBag.errortype = errortype; ViewBag.taskid = taskid; ViewBag.nodeid = nodeid; ViewBag.pagesize = pagesize; ViewBag.pageindex = pageindex; PubConn.Open(); tb_error_dal dal = new tb_error_dal(); List <tb_errorinfo_model> model = dal.GetList(PubConn, keyword, id, CStime, CEtime, errortype, taskid, nodeid, pagesize, pageindex, out count); PagedList <tb_errorinfo_model> pageList = new PagedList <tb_errorinfo_model>(model, pageindex, pagesize, count); List <tb_task_model> Task = new tb_task_dal().GetListAll(PubConn); List <tb_node_model> Node = new tb_node_dal().GetListAll(PubConn); ViewBag.Node = Node; ViewBag.Task = Task; return View(pageList); } })); }
/// <summary> /// 添加错误日志 /// </summary> /// <param name="model"></param> private static void AddError(tb_error_model model) { try { AddLog(new tb_log_model { logcreatetime = model.errorcreatetime, logtype = model.errortype, msg = model.msg, taskid = model.taskid, nodeid = GlobalConfig.NodeID }); SqlHelper.ExcuteSql(GlobalConfig.ConnectionString, (c) => { tb_error_dal errordal = new tb_error_dal(); model.msg = model.msg.SubString2(1000); errordal.Add2(c, model); }); } catch (Exception exp) { ErrorLog.Write("添加错误日志至数据库出错", exp); } }