using Models; using Models.ModelItems; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web; namespace Services.Manager { public class DbLogServer { /// /// 写日志 /// /// 操作者 /// 内容 /// 0 新增 1 更新 2 删除 public static void WriteDbLog(string content, int type = 0, DbLog logs = null) { try { //从Session拷贝一个模板过来 DbLog log = new DbLog(); log = logs != null ? logs : HttpContext.Current.Session["log"] as DbLog; if(logs != null) { log = logs; } else { DbLog tmpSessionLog = HttpContext.Current.Session["log"] as DbLog; if(tmpSessionLog != null) { log = tmpSessionLog; } else { log.location = ""; log.Ip = ""; log.Client = ""; log.Uid = ""; } } //除了content, type, 其他的全部用模板的值 DbLog dlog = new DbLog { location = log.location, Ip = log.Ip, Client = log.Client, CreateTime = DateTime.Now, Uid = log.Uid, Type = type, Content = content }; SqlSugarBase.Db.Insertable(dlog).ExecuteCommand(); } catch (Exception EX) { LogHelp.WriteExceptionLog(EX); }; } } }