Пример #1
0
 public static void WriteOperatorLog(OperationType operationType, string MenuPowerID, string MenuName, int UserID, string Account, string CommandName, string Title, string Description, object OperationData)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(MenuPowerID) && !string.IsNullOrWhiteSpace(Title))
         {
             if (string.IsNullOrWhiteSpace(Account))
             {
                 Account = "";
             }
             if (string.IsNullOrWhiteSpace(CommandName))
             {
                 CommandName = operationType.ToString();
             }
             if (string.IsNullOrWhiteSpace(Description))
             {
                 Description = operationType.GetEnumDescription() + ":" + Title;
             }
             if (string.IsNullOrWhiteSpace(MenuName))
             {
                 MenuName = "";
             }
             loger_operationhistory _operationhistory = new loger_operationhistory {
                 MenuPowerID     = MenuPowerID,
                 UserID          = UserID,
                 MenuName        = MenuName,
                 Account         = Account,
                 OperationTypeID = (int)operationType,
                 CommandName     = CommandName.CutWord(10),
                 CreateDate      = DateTime.Now,
                 Title           = Title.CutWord(500),
                 Description     = Description.CutWord(500),
                 OperationData   = (OperationData == null) ? "" : OperationData.JsonJsSerialize(),
                 UserHostAddress = RequestHelper.GetRealIp()
             };
             LogRule rule = new LogRule();
             rule.CurrentEntities.AddTologer_operationhistory(_operationhistory);
             rule.CurrentEntities.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         new Logger("Application").WriteLog("记录用户操作行为异常", exception);
     }
 }