private IList<KeyValuePair<string, string>> GetTemplet(string section) { if (this.iniFile == null) { lock (lockObj) { if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); IDictionary<string,NameValueCollection> templets = this.iniFile.GetIniFile("TXTTemplate.ini"); this.mailTempletList = BuildTempletList(templets, "Email"); this.scriptionTemletList = BuildTempletList(templets, "Scripts"); this.smsTempletList = BuildTempletList(templets, "SMS"); } } } IList<KeyValuePair<string, string>> templet = null; switch (section) { case "Email": templet = this.mailTempletList; break; case "Scripts": templet = this.scriptionTemletList; break; case "SMS": templet = this.smsTempletList; break; } return templet; }
private IList <KeyValuePair <string, string> > GetTemplet(string section) { if (this.iniFile == null) { lock (lockObj) { if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); IDictionary <string, NameValueCollection> templets = this.iniFile.GetIniFile("TXTTemplate.ini"); this.mailTempletList = BuildTempletList(templets, "Email"); this.scriptionTemletList = BuildTempletList(templets, "Scripts"); this.smsTempletList = BuildTempletList(templets, "SMS"); } } } IList <KeyValuePair <string, string> > templet = null; switch (section) { case "Email": templet = this.mailTempletList; break; case "Scripts": templet = this.scriptionTemletList; break; case "SMS": templet = this.smsTempletList; break; } return(templet); }
/// <summary> /// /// </summary> /// <param name="AccessInformation"></param> /// <param name="AlertInformation"></param> /// <returns></returns> public UpdateAlertResult UpdateEmailAlert(AccessControl AccessInformation, EmailAlert AlertInformation,bool checkname) { UpdateAlertResult Result = new UpdateAlertResult(); string estr = ""; bool ret = true; string strServer = ""; string strUser = ""; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } strServer = "localhost"; strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (checkname) { if (IsAlertNameExist(AccessInformation, AlertInformation.BaseInfo.Name)) { ret = false; estr = keytext[ErrorInfo.AlertNameError.ToString()]; break; } } //email���� //if (string.IsNullOrEmpty(AlertInformation.EmailAddresss)) //{ // ret = false; // estr = keytext[ErrorInfo.EmailAddresssError.ToString()]; // break; //} //if (!string.IsNullOrEmpty(AlertInformation.EmailAddresss)) //{ // if (!CheckEmail(AlertInformation.OtherAddress)) // { // ret = false; // estr = keytext[ErrorInfo.EmailAddresssError.ToString()]; // break; // } //} if (!string.IsNullOrEmpty(AlertInformation.UpgradeTimes)) { if (!IsAlphaNumber(AlertInformation.UpgradeTimes)) { ret = false; estr = keytext[ErrorInfo.AlertTimesError.ToString()]; break; } } if (!string.IsNullOrEmpty(AlertInformation.StopTimes)) { if (!IsAlphaNumber(AlertInformation.StopTimes)) { ret = false; estr = keytext[ErrorInfo.AlertTimesError.ToString()]; break; } } break; } string strAlertIndex = ""; while (ret) { strAlertIndex = AlertInformation.BaseInfo.ID; //���ݴ洢���� ret = SetIniBaseAlertInfo(AccessInformation, AlertInformation.BaseInfo, estr); if (!ret) { break; } //email���� if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "EmailAdress", AlertInformation.EmailAddresss); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "OtherAdress", AlertInformation.OtherAddress); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "EmailTemplate", AlertInformation.EmailTemplate); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "WatchSheet", AlertInformation.WatchSheet); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "Upgrade", AlertInformation.UpgradeTimes); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "UpgradeTo", AlertInformation.ReceiverAddress); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "Stop", AlertInformation.StopTimes); if (queue == null) { this.queue = new QueueDaoImpl(); } //send message to service bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + strAlertIndex + ",EDIT"); if (!meseagebool) { estr = keytext[ErrorInfo.PushMessageError.ToString()]; } break; } Result.ErrorInformation = estr; Result.UpdateAlertOK = ret; return Result; }
public QueryAlertRuleResult QueryAlertRule(AccessControl AccessInformation, AlertRuleQueryCondition QueryCondition) { QueryAlertRuleResult Result = new QueryAlertRuleResult(); string estr = ""; bool ret = true; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = ""; break; } ret = GetAlertRuleQueryCondition(QueryCondition); if (!ret) { estr = ""; break; } break; } if (ret) { string strServer = "localhost"; string strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } IDictionary<string, NameValueCollection> sectionlists = this.iniFile.GetIniFile("alert.ini"); BaseAlert[] baseAlerts = new BaseAlert[sectionlists.Count]; int i = 0; foreach (string key in sectionlists.Keys) { baseAlerts[i] = GetIniBaseAlertInfo(key, sectionlists); i = i + 1; } Result.ResponseData = baseAlerts; } Result.ErrorInformation = estr; Result.QueryAlertRuleOK = ret; return Result; }
/// <summary> /// Sound����������Ϣ��ȡ�� /// </summary> /// <param name="AccessInformation"></param> /// <param name="AlertIndex"></param> /// <returns></returns> public GetSoundAlertResult GetSoundAlert(AccessControl AccessInformation, string AlertIndex) { GetSoundAlertResult Result = new GetSoundAlertResult(); SoundAlert sound = new SoundAlert(); string estr = ""; bool ret = true; ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } string strServer = "localhost"; string strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } while (ret) { if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } IDictionary<string, NameValueCollection> sectionlists = this.iniFile.GetIniFileBySection("alert.ini", AlertIndex); sound.BaseInfo = GetIniBaseAlertInfo(AlertIndex, sectionlists); sound.ServerName = sectionlists[AlertIndex]["Server"]; sound.LoginName = sectionlists[AlertIndex]["LoginName"]; sound.LoginPassword = sectionlists[AlertIndex]["LoginPwd"]; break; } Result.ErrorInformation = estr; Result.GetSoundAlertOK = ret; Result.ResponseData = sound; return Result; }
/// <summary> /// SMS����������Ϣ��ȡ�� /// </summary> /// <param name="AccessInformation"></param> /// <param name="AlertIndex"></param> /// <returns></returns> public GetSMSAlertResult GetSMSAlert(AccessControl AccessInformation, string AlertIndex) { GetSMSAlertResult Result = new GetSMSAlertResult(); SMSAlert sms = new SMSAlert(); string estr = ""; bool ret = true; ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } string strServer = "localhost"; string strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } while (ret) { if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } IDictionary<string, NameValueCollection> sectionlists = this.iniFile.GetIniFileBySection("alert.ini", AlertIndex); sms.BaseInfo = GetIniBaseAlertInfo(AlertIndex, sectionlists); sms.SmsNumber = sectionlists[AlertIndex]["SmsNumber"]; sms.OtherNumber = sectionlists[AlertIndex]["OtherNumber"]; sms.SendMode = sectionlists[AlertIndex]["SmsSendMode"]; sms.SMSTemplate = sectionlists[AlertIndex]["SmsTemplate"]; sms.UpgradeTimes = sectionlists[AlertIndex]["Upgrade"]; sms.ReceiverAddress = sectionlists[AlertIndex]["UpgradeTo"]; sms.StopTimes = sectionlists[AlertIndex]["Stop"]; sms.WatchSheet = sectionlists[AlertIndex]["WatchSheet"]; break; } Result.ErrorInformation = estr; Result.GetSMSAlertOK = ret; Result.ResponseData = sms; return Result; }
public DeleteAlertResult DeleteAlert(AccessControl AccessInformation, BaseAlert AlertInformation) { DeleteAlertResult Result = new DeleteAlertResult(); string estr = ""; bool ret = true; string strServer = ""; string strUser = ""; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } strServer = "localhost"; strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.DeleteIniFileBySection("alert.ini", AlertInformation.ID); if (queue == null) { this.queue = new QueueDaoImpl(); } //send message to service bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + AlertInformation.ID + ",DELETE"); if (!meseagebool) { estr = keytext[ErrorInfo.PushMessageError.ToString()]; } break; } Result.ErrorInformation = estr; Result.DeleteAlertOK = ret; return Result; }
public AddAlertResult AddSoundAlert(AccessControl AccessInformation, SoundAlert AlertInformation) { AddAlertResult Result = new AddAlertResult(); string estr = ""; bool ret = true; string strServer = ""; string strUser = ""; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } strServer = "localhost"; strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (IsAlertNameExist(AccessInformation, AlertInformation.BaseInfo.Name)) { ret = false; estr = keytext[ErrorInfo.AlertNameError.ToString()]; break; } //script���� break; } string strAlertIndex = ""; while (ret) { strAlertIndex = GenerateAlertIndex(AccessInformation); AlertInformation.BaseInfo.ID = strAlertIndex; //���ݴ洢���� ret = SetIniBaseAlertInfo(AccessInformation, AlertInformation.BaseInfo, estr); if (!ret) { break; } //email���� if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "Server", AlertInformation.ServerName); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "LoginName", AlertInformation.LoginName); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "LoginPwd", AlertInformation.LoginPassword); if (queue == null) { this.queue = new QueueDaoImpl(); } //send message to service bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + strAlertIndex + ",ADD"); if (!meseagebool) { estr = keytext[ErrorInfo.PushMessageError.ToString()]; } break; } Result.ErrorInformation = estr; Result.AddAlertOK = ret; Result.AlertIndex = strAlertIndex; return Result; }
/// <summary> /// SMS ���� /// </summary> /// <param name="AccessInformation"></param> /// <param name="AlertInformation"></param> /// <returns></returns> public AddAlertResult AddSMSAlert(AccessControl AccessInformation, SMSAlert AlertInformation) { AddAlertResult Result = new AddAlertResult(); string estr = ""; bool ret = true; string strServer = ""; string strUser = ""; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } strServer = "localhost"; strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (IsAlertNameExist(AccessInformation, AlertInformation.BaseInfo.Name)) { ret = false; estr = keytext[ErrorInfo.AlertNameError.ToString()]; break; } //sms���� if (string.IsNullOrEmpty(AlertInformation.SmsNumber)) { ret = false; break; } if (!string.IsNullOrEmpty(AlertInformation.UpgradeTimes)) { if (!IsAlphaNumber(AlertInformation.UpgradeTimes)) { ret = false; estr = keytext[ErrorInfo.UpgradeTimesError.ToString()]; break; } } if (!string.IsNullOrEmpty(AlertInformation.StopTimes)) { if (!IsAlphaNumber(AlertInformation.StopTimes)) { ret = false; estr = keytext[ErrorInfo.StopTimesError.ToString()]; break; } } break; } string strAlertIndex = ""; while (ret) { strAlertIndex = GenerateAlertIndex(AccessInformation); AlertInformation.BaseInfo.ID = strAlertIndex; //���ݴ洢���� ret = SetIniBaseAlertInfo(AccessInformation, AlertInformation.BaseInfo, estr); if (!ret) { break; } //email���� if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SmsNumber", AlertInformation.SmsNumber); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "OtherNumber", AlertInformation.OtherNumber); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SmsSendMode", AlertInformation.SendMode); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SmsTemplate", AlertInformation.SMSTemplate); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "WatchSheet", AlertInformation.WatchSheet); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "Upgrade", AlertInformation.UpgradeTimes); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "UpgradeTo", AlertInformation.ReceiverAddress); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "Stop", AlertInformation.StopTimes); if (queue == null) { this.queue = new QueueDaoImpl(); } //send message to service bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + strAlertIndex + ",ADD"); if (!meseagebool) { estr = keytext[ErrorInfo.PushMessageError.ToString()]; } break; } Result.ErrorInformation = estr; Result.AddAlertOK = ret; Result.AlertIndex = strAlertIndex; return Result; }
/// <summary> /// ����BaseAlert��Ϣ /// </summary> /// <param name="alertInfo"></param> /// <param name="estr"></param> /// <returns></returns> bool SetIniBaseAlertInfo(AccessControl AccessInformation, BaseAlert alertInfo, string estr) { bool ret = true; while (ret) { string strTemp; string strAlertIndex = alertInfo.ID; string strServer = "localhost"; string strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (string.IsNullOrEmpty(strAlertIndex)) { ret = false; estr = keytext[ErrorInfo.AlertIDError.ToString()]; break; } if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "nIndex", alertInfo.ID); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertTarget", alertInfo.Target); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertName", alertInfo.Name); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertType", alertInfo.Type.ToString()); if (alertInfo.Category == AlertCategory.Normal) { strTemp = "����"; } else if (alertInfo.Category == AlertCategory.Danger) { strTemp = "Σ��"; } else if (alertInfo.Category == AlertCategory.Error) { strTemp = "����"; } else { //�����֧�߲�����·��AlertCategoryError ret = false; estr = keytext[ErrorInfo.AlertCategoryError.ToString()]; break; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertCategory", strTemp); this.iniFile.WriteIniFileInt("alert.ini", strAlertIndex, "AlertCond", alertInfo.Times.GetHashCode()); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", "1"); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "OnlyTimes", "1"); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes1", "2"); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes2", "3"); if (alertInfo.Times == AlertTimes.Always) { if (!IsAlphaNumber(alertInfo.Always)) {//AlertAlwaysError AlertOnlyError ret = false; estr = keytext[ErrorInfo.AlertAlwaysError.ToString()]; break; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", alertInfo.Always); } else if (alertInfo.Times == AlertTimes.Only) { if (!IsAlphaNumber(alertInfo.Only)) { ret = false; estr = keytext[ErrorInfo.AlertOnlyError.ToString()]; break; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlwaysTimes", alertInfo.Only); } else { if (!IsAlphaNumber(alertInfo.Select1)) {// ret = false; estr = keytext[ErrorInfo.AlertSelect1Error.ToString()]; break; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes1", alertInfo.Select1); if (!IsAlphaNumber(alertInfo.Select2)) { ret = false; estr = keytext[ErrorInfo.AlertSelect2Error.ToString()]; break; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "SelTimes2", alertInfo.Select2); } if (alertInfo.State == AlertState.Enable) { strTemp = "Enable"; } else { strTemp = "��ֹ"; } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "AlertState", strTemp); break; } return ret; }
/// <summary> /// �����Ƿ��Ѵ��� /// </summary> /// <param name="strAlertName"></param> /// <returns></returns> bool IsAlertNameExist(AccessControl AccessInformation, string strAlertName) { string strTemp = ""; IList<string> keylist = new List<string>(); string strServer = "localhost"; string strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } bool bExist = false; //��ini��ȡ�û��б� if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } IDictionary<string, NameValueCollection> sectionlists = this.iniFile.GetIniFile("alert.ini"); keylist.Clear(); foreach (string key in sectionlists.Keys) { string alertName = string.IsNullOrEmpty(sectionlists[key]["AlertName"]) ? "" : sectionlists[key]["AlertName"]; keylist.Add(alertName); } if (keylist.Contains(strAlertName)) { bExist = true; } return bExist; }
private string GenerateAlertIndex(AccessControl access) { string strServer = "localhost"; string strUser = "******"; if (access.LimitServer) { strServer = access.SVDBServer; } if (access.LimitUser) { strUser = access.UserID; } string strAlertIndex = ""; uint index = 0; while (true) { index = RandIndex(); if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } IDictionary<string, NameValueCollection> rs = this.iniFile.GetIniFileBySection("alert.ini", index.ToString()); if (rs.ContainsKey(index.ToString())) { continue; } else { strAlertIndex = index.ToString(); break; } } return strAlertIndex; }
/// <summary> /// /// </summary> /// <param name="AccessInformation"></param> /// <param name="AlertInformation"></param> /// <returns></returns> public UpdateAlertResult UpdateScriptAlert(AccessControl AccessInformation, ScriptAlert AlertInformation,bool checkname) { UpdateAlertResult Result = new UpdateAlertResult(); string estr = ""; bool ret = true; string strServer = ""; string strUser = ""; while (ret) { ret = GetAccessControlInformation(AccessInformation); if (!ret) { estr = keytext[ErrorInfo.AccessControlError.ToString()]; } strServer = "localhost"; strUser = "******"; if (AccessInformation.LimitServer) { strServer = AccessInformation.SVDBServer; } if (AccessInformation.LimitUser) { strUser = AccessInformation.UserID; } if (checkname) { if (IsAlertNameExist(AccessInformation, AlertInformation.BaseInfo.Name)) { ret = false; estr = keytext[ErrorInfo.AlertNameError.ToString()]; break; } } //script���� break; } string strAlertIndex = ""; while (ret) { strAlertIndex = AlertInformation.BaseInfo.ID; //���ݴ洢���� ret = SetIniBaseAlertInfo(AccessInformation, AlertInformation.BaseInfo, estr); if (!ret) { break; } //email���� if (this.iniFile == null) { this.iniFile = new IniFileDaoImpl(); } this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "ScriptServer", AlertInformation.ScriptServer); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "ScriptServerID", AlertInformation.ServerID); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "ScriptFile", AlertInformation.ScriptFile); this.iniFile.WriteIniFileString("alert.ini", strAlertIndex, "ScriptParam", AlertInformation.ScriptParam); if (queue == null) { this.queue = new QueueDaoImpl(); } //send message to service bool meseagebool = this.queue.PushStringMessage("SiteView70-Alert", "IniChange", "alert.ini," + strAlertIndex + ",EDIT"); if (!meseagebool) { estr = keytext[ErrorInfo.PushMessageError.ToString()]; } break; } Result.ErrorInformation = estr; Result.UpdateAlertOK = ret; return Result; }