public static void Log(string msg) { try { LoadConnectString(); SqlHelper.ExcuteSql(UnityLogConnectString, (c) => { tb_log_dal dal = new tb_log_dal(); dal.Add(c, new tb_log_model() { logcreatetime = DateTime.Now, logtag = "统一监控平台", logtype = (int)XXF.BaseService.Monitor.SystemRuntime.EnumCommonLogType.SystemLog, msg = msg, projectname = "统一监控平台" }); }); Debug.WriteLine(msg); CommLog.Write(msg); } catch (Exception e) { XXF.Log.ErrorLog.Write(msg, e); } }
/// <summary> /// 添加日志 /// </summary> /// <param name="model"></param> public static void AddLog(tb_log_model model) { try { SqlHelper.ExcuteSql(Config.TaskConnectString, (c) => { tb_log_dal logdal = new tb_log_dal(); model.msg = model.msg.SubString2(1000); logdal.Add2(c, model); }); } catch (Exception exp) { XXF.Log.ErrorLog.Write("添加日志至数据库出错", exp); } }
/// <summary> /// 添加日志 /// </summary> /// <param name="model"></param> private static void AddLog(tb_log_model model) { try { SqlHelper.ExcuteSql(GlobalConfig.ConnectionString, (c) => { tb_log_dal logdal = new tb_log_dal(); model.msg = model.msg.SubString2(1000); logdal.Add2(c, model); }); } catch (Exception exp) { ErrorLog.Write("添加日志至数据库出错", exp); } }
protected override void BatchCommit() { if (!string.IsNullOrEmpty(Config.UnityLogConnectString)) { if (TempQueue.Count > 500) { var dict = new Dictionary <string, string> { { "logcreatetime", "logcreatetime" }, { "logtype", "logtype" }, { "projectname", "projectname" }, { "logtag", "logtag" }, { "msg", "msg" } }; var timewatchinfoTable = DataTableHelper.ConvertToDataTable <tb_log_model>(TempQueue); using (var c = Db.DbConfig.CreateConn(Db.DbType.SQLSERVER, Config.UnityLogConnectString)) { c.Open(); c.BeginTransaction(); try { c.SqlBulkCopy(timewatchinfoTable, BatchTable + DateTime.Now.ToString("yyyyMM"), "", new List <ProcedureParameter>(), dict, 0); c.Commit(); } catch (Exception exp) { c.Rollback(); } } } else { foreach (var t in TempQueue) { try { SqlHelper.ExcuteSql(Config.UnityLogConnectString, (c) => { tb_log_dal logdal = new tb_log_dal(); logdal.Add(c, t); }); } catch { } } } } }
// // GET: /UnityLog/Log/ public ActionResult Index(string id, string keyword, string timebegin, string timeend, string projectname, int logtype = -1, int pageindex = 1, int pagesize = 10) { ViewBag.keyword = keyword; ViewBag.logtype = logtype; ViewBag.projectname = projectname; ViewBag.id = id; if (!string.IsNullOrWhiteSpace(timebegin)) { ViewBag.timebegin = DateTime.Parse(timebegin); } else { ViewBag.timebegin = DateTime.Now.Date; } if (!string.IsNullOrWhiteSpace(timeend)) { ViewBag.timeend = DateTime.Parse(timeend); } else { ViewBag.timeend = DateTime.Now.Date.AddDays(1); } tb_log_dal dal = new tb_log_dal(); PagedList <tb_log_model> pageList = null; int count = 0; using (DbConn PubConn = DbConfig.CreateConn(Config.UnityLogConnectString)) { PubConn.Open(); List <tb_log_model> List = new List <tb_log_model>(); try { List = dal.GetList(PubConn, id, keyword, ViewBag.timebegin, ViewBag.timeend, logtype, projectname, pagesize, pageindex, out count); } catch { List = new List <tb_log_model>(); } pageList = new PagedList <tb_log_model>(List, pageindex, pagesize, count); } if (Request.IsAjaxRequest()) { return(PartialView("List", pageList)); } return(View(pageList)); }
public ActionResult Log(string keyword, string CStime, string CEtime, int id = -1, int logtype = -1, int taskid = -1, int nodeid = -1, int pagesize = 10, int pageindex = 1) { return(this.Visit(Core.EnumUserRole.None, () => { ViewBag.keyword = keyword; ViewBag.CStime = CStime; ViewBag.CEtime = CEtime; ViewBag.id = id; ViewBag.logtype = logtype; ViewBag.taskid = taskid; ViewBag.nodeid = nodeid; ViewBag.pagesize = pagesize; ViewBag.pageindex = pageindex; int count = 0; using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString)) { PubConn.Open(); tb_log_dal dal = new tb_log_dal(); List <tb_loginfo_model> model = dal.GetList(PubConn, keyword, id, CStime, CEtime, logtype, taskid, nodeid, pagesize, pageindex, out count); PagedList <tb_loginfo_model> pageList = new PagedList <tb_loginfo_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); } })); }
public static void WriteLine(int mqpathid, string mqpath, string methodname, string info) { try { if (!string.IsNullOrWhiteSpace(ConfigHelper.LogDBConnectString)) { SqlHelper.ExcuteSql(ConfigHelper.LogDBConnectString, (c) => { tb_log_dal dal = new tb_log_dal(); dal.Add(c, new tb_log_model() { createtime = DateTime.Now, info = info, mqpath = mqpath, mqpathid = mqpathid, methodname = methodname }); }); } } catch (Exception exp) { XXF.Log.ErrorLog.Write(string.Format("BusinessMQ插入Log信息时发生错误,mqpathid:{0},mqpath:{1},methodname:{2},info:{3}", mqpathid, mqpath.NullToEmpty(), methodname.NullToEmpty(), info.NullToEmpty()), exp); } DebugHelper.WriteLine(mqpathid, mqpath, methodname, "【记录】:" + info); }