Example #1
0
        /// <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;
        }
Example #2
0
        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;
        }
Example #3
0
        /// <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;
        }
Example #4
0
        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;
        }
Example #5
0
        /// <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;
        }