/// <summary> /// 记录系统操作日志 /// </summary> /// <param name="jsonMsg">返回前台的json 消息</param> /// <param name="type">类型(增、删、查、改)</param> /// <param name="module">操作模块</param> /// <param name="desc">备注说明</param> public void WriteSystemLog(JsonMessage jsonMsg, string type, string module, string desc = "") { try { string enamespace = ""; string eclass = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().ReflectedType.Name; string emethod = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name; SysLogRep _logRep = new SysLogRep(); SysLogModel model = new SysLogModel(); model.LOG_ID = GuidHelper.GenerateComb().ToString().ToUpper(); model.OPERATE_ID = UserID; model.LOG_MSG = jsonMsg.message; model.LOG_RESULT = jsonMsg.type == 1 ? "SUCCESS" : "FAIL"; model.LOG_TYPE = type; model.LOG_MODULE = module; model.LOG_DESC = desc; model.LOG_NAMESPACE = enamespace; model.LOG_CLASS = eclass; model.LOG_METHOD = emethod; model.CREATE_USER = UserID; model.LM_USER = UserID; _logRep.Insert(model); } catch (Exception ex) { LogHelper.Error(ex.Message);//异常失败写入txt } }
public JsonMessage Insert(string userid, string msg, string res, string type, string module, string space, string eclass, string emethed, string desc) { JsonMessage jsonMsg = new JsonMessage(); //返回Json int result = -1; //类型(成功 、失败) try { SysLogModel model = new SysLogModel(); model.LOG_ID = GuidHelper.GenerateComb().ToString().ToUpper(); model.OPERATE_ID = userid; model.LOG_MSG = msg; model.LOG_RESULT = res; model.LOG_TYPE = type; model.LOG_MODULE = module; model.LOG_NAMESPACE = space; model.LOG_CLASS = eclass; model.LOG_METHOD = emethed; model.LOG_DESC = desc; result = _logRep.Insert(model); jsonMsg = ServiceResult.Message(1, "添加日志成功"); } catch (Exception ex) { jsonMsg = ServiceResult.Message(-1, ex.Message); WriteSystemException(ex, this.GetType(), OPT_MODEL, "添加日志失败"); } return(jsonMsg); }