/// <summary> /// 用户操作日志 /// </summary> /// <param name="sender">this</param> /// <param name="plantCode">工厂编号</param> /// <param name="moduleCode">模块编号</param> /// <param name="msgCode">消息编号</param> /// <param name="userId">用户编号</param> /// <param name="eventType">事件类型</param> /// <param name="eventLevel">事件级别</param> /// <param name="eventDescription">事件描述</param> /// <param name="listExternParas">扩展参数</param> public void LogUserInfo(object sender, string plantCode, string moduleCode, string msgCode, string userId, string eventType, EventLevel eventLevel, string eventDescription, List <string> listExternParas) { try { UserLogInfoProxy model = new UserLogInfoProxy { Logid = Guid.NewGuid(), Plantcode = plantCode, OccurTime = DateTime.Now, Modulecode = moduleCode, Userid = userId }; if (string.IsNullOrWhiteSpace(msgCode)) { model.Eventlevel = eventLevel.ToString(); model.Eventtype = eventType; } else { model.Eventlevel = eventLevel.ToString(); model.Eventtype = eventType; model.Msgcode = msgCode; } model.Eventdescription = eventDescription; if (listExternParas != null) { if (listExternParas.Count == 1) { model.Para1 = listExternParas[0]; } if (listExternParas.Count == 2) { model.Para1 = listExternParas[1]; model.Para2 = listExternParas[2]; } if (listExternParas.Count == 3) { model.Para1 = listExternParas[0]; model.Para2 = listExternParas[1]; model.Para3 = listExternParas[2]; } } WriteOperateLog(model); //this.Info(this, EventDescription); } catch (Exception ex) { this.LogError(plantCode, moduleCode, string.Empty, eventLevel, ex); throw; } }
/// <summary> /// 用户操作日志 /// </summary> public void WriteOperateLog(UserLogInfoProxy model) { if (!string.IsNullOrEmpty(model.Msgcode)) { var msgInfo = GetInfo(model.Msgcode); if (msgInfo != null) { model.Eventtype = msgInfo.Msgtype; model.Eventlevel = msgInfo.Defaultlevel; model.Eventdescription = msgInfo.Chncontent; model.Para1 = msgInfo.Parameter1; model.Para2 = msgInfo.Parameter2; model.Para3 = msgInfo.Parameter3; } } if (_userLog != null && _userLog.IsInfoEnabled) { _userLog.Info(model); } }