コード例 #1
0
ファイル: LogFilter.cs プロジェクト: kaka8384/EFPNet
 /// <summary>
 /// 添加操作日志
 /// </summary>
 /// <param name="filterContext"></param>
 /// <param name="opEvent"></param>
 private void AddLog(ControllerContext filterContext,OperateLogEvent opEvent)
 {
     OperateLogDto model = new OperateLogDto()
     {
         ControllerName = filterContext.RouteData.Values["controller"].ToString(),
         ActionName = filterContext.RouteData.Values["action"].ToString(),
         Desc = LogDesc,
         IP = EFP.Common.Tool.WebTools.GetIPAddress(),
         Event=opEvent
     };
     
     _logService.AddLog(model);
 }
コード例 #2
0
ファイル: OperateLogService.cs プロジェクト: kaka8384/EFPNet
 /// <summary>
 /// 添加系统日志
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public OperationResult AddLog(OperateLogDto dto)
 {
     ObjectsMapper<OperateLogDto, OperateLog> mapper = ObjectMapperManager.DefaultInstance.GetMapper<OperateLogDto, OperateLog>();
     OperateLog opLog = mapper.Map(dto);
     opLog.Id = Guid.NewGuid();
     opLog.OperateDate = DateTime.Now;
     opLog.AddDate = DateTime.Now;
     var userInfo=FormsPrincipal<UserInfo>.GetUserData();  //取用户信息
     if (userInfo != null)
     {
         opLog.UserID = userInfo.UserId;
         opLog.LastOperateUser = userInfo.UserName.ToString();
     }
    
     var result=_operatelogRepository.Insert(opLog);
     return result > 0 ? new OperationResult(OperationResultType.Success) : new OperationResult(OperationResultType.NoChanged);
 }