public bool GetSensitiveMailInfo(Guid transactionid, AdminInfo admin, SensitiveMailInfo sensitiveMailInfo, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string message = string.Empty; string paramstr = string.Empty; paramstr += $"AdminID:{admin.UserID}"; paramstr += $"ID:{sensitiveMailInfo.ID}"; string funname = "GetSensitiveMailInfo"; try { do { SensitiveMailDBProvider Provider = new SensitiveMailDBProvider(); if (!Provider.GetSensitiveMailInfo(transactionid, admin, ref sensitiveMailInfo, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } error.Code = ErrorCode.None; string json = JsonConvert.SerializeObject(sensitiveMailInfo); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), true, transactionid); strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info, json); result = true; } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SensitiveMailManager调用GetSensitiveMailInfo异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool ExecuteSensitiveMail(Guid transactionid, AdminInfo admin, SensitiveMailInfo sensitiveMailInfo, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string message = string.Empty; string paramstr = string.Empty; paramstr += $"AdminID:{admin.UserID}"; paramstr += $"||AdminAccount:{admin.UserAccount}"; paramstr += $"||ID:{sensitiveMailInfo.ID}"; string funname = "ExecuteSensitiveMail"; try { do { SensitiveMailDBProvider provider = new SensitiveMailDBProvider(); if (!provider.GetSensitiveMailInfo(transactionid, admin, ref sensitiveMailInfo, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } if (sensitiveMailInfo.Status == SensitiveMailStatus.Executing || sensitiveMailInfo.Status == SensitiveMailStatus.Submit) { error.Code = ErrorCode.SensitiveMailExecute; strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } sensitiveMailInfo.Status = SensitiveMailStatus.Submit; sensitiveMailInfo.ExecuteID = transactionid; if (!provider.UpdateSensitiveMailStatus(transactionid, admin, sensitiveMailInfo, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } error.Code = ErrorCode.None; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), true, transactionid); strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info); #region 操作日志 LogInfo operateLog = new LogInfo(); operateLog.AdminID = admin.UserID; operateLog.AdminAccount = admin.UserAccount; operateLog.RoleID = admin.RoleID; operateLog.ClientIP = _clientip; operateLog.OperateResult = true; operateLog.OperateType = "执行敏感邮件规则"; operateLog.OperateLog = $"{admin.UserAccount}于{DateTime.Now}执行敏感邮件规则。" + $"名称:{sensitiveMailInfo.Name}," + $"关键字:{sensitiveMailInfo.Keywords}," + $"开始时间:{sensitiveMailInfo.StartTime}," + $"结束时间:{sensitiveMailInfo.EndTime}"; LogManager.AddOperateLog(transactionid, operateLog); #endregion result = true; } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SensitiveMailManager调用ExecuteSensitiveMail异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool ModifySensitiveMail(Guid transactionid, AdminInfo admin, SensitiveMailInfo sensitiveMailInfo, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string message = string.Empty; string paramstr = string.Empty; paramstr += $"AdminID:{admin.UserID}"; paramstr += $"||AdminAccount:{admin.UserAccount}"; paramstr += $"||ID:{sensitiveMailInfo.ID}"; paramstr += $"||Keywords:{sensitiveMailInfo.Keywords}"; paramstr += $"||StartTime:{sensitiveMailInfo.StartTime}"; paramstr += $"||EndTime:{sensitiveMailInfo.EndTime}"; string funname = "ModifySensitiveMail"; try { do { error = sensitiveMailInfo.ChangeCheckProp(); if (error.Code != ErrorCode.None) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } SensitiveMailDBProvider provider = new SensitiveMailDBProvider(); SensitiveMailInfo oldSensitiveMailInfo = new SensitiveMailInfo(); oldSensitiveMailInfo.ID = sensitiveMailInfo.ID; if (!provider.GetSensitiveMailInfo(transactionid, admin, ref oldSensitiveMailInfo, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } if (oldSensitiveMailInfo.Status == SensitiveMailStatus.Executing) { error.Code = ErrorCode.SensitiveMailIsExecuting; strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } #region DirectoryEntry entry = new DirectoryEntry(); CommonProvider commonProvider = new CommonProvider(); List <SensitiveMailObject> members = new List <SensitiveMailObject>(); List <string> distinguishedNames = new List <string>(); for (int i = 0; i < sensitiveMailInfo.Objects.Count; i++) { if (!commonProvider.GetADEntryByGuid(sensitiveMailInfo.Objects[i].ObjectID, out entry, out message)) { LoggerHelper.Error("ModifiedSensitiveMail调用GetADEntryByGuid异常", paramstr, message, transactionid); continue; } SensitiveMailObject mailObject = new SensitiveMailObject(); mailObject.ObjectID = sensitiveMailInfo.Objects[i].ObjectID; mailObject.ObjectType = (NodeType)Enum.Parse(typeof(NodeType), entry.SchemaClassName); mailObject.ObjectName = Convert.ToString(entry.Properties["name"].Value); members.Add(mailObject); distinguishedNames.Add(Convert.ToString(entry.Properties["distinguishedName"].Value)); } if (!CheckdistinguishedNames(transactionid, distinguishedNames, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SensitiveMailManager调用ModifiedSensitiveMail异常", paramstr, error.Info, transactionid); result = false; break; } #endregion sensitiveMailInfo.Status = SensitiveMailStatus.Enable; if (!provider.ModifySensitiveMail(transactionid, admin, sensitiveMailInfo, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } for (int i = 0; i < members.Count; i++) { members[i].SensitiveMailID = sensitiveMailInfo.ID; if (!provider.AddSensitiveMailObjects(transactionid, admin, members[i], out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } } error.Code = ErrorCode.None; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), true, transactionid); strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info); #region 操作日志 LogInfo operateLog = new LogInfo(); operateLog.AdminID = admin.UserID; operateLog.AdminAccount = admin.UserAccount; operateLog.RoleID = admin.RoleID; operateLog.ClientIP = _clientip; operateLog.OperateResult = true; operateLog.OperateType = "修改敏感邮件规则"; operateLog.OperateLog = $"{admin.UserAccount}于{DateTime.Now}修改敏感邮件规则。" + $"原关键字:{oldSensitiveMailInfo.Keywords},现关键字:{sensitiveMailInfo.Keywords};" + $"原开始时间:{oldSensitiveMailInfo.StartTime},现开始时间:{sensitiveMailInfo.StartTime};" + $"原结束时间:{oldSensitiveMailInfo.EndTime},现结束时间:{sensitiveMailInfo.EndTime}"; LogManager.AddOperateLog(transactionid, operateLog); #endregion result = true; } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SensitiveMailManager调用ModifySensitiveMail异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }