Example #1
0
        /// <summary>
        /// Script����������Ϣ��ȡ��
        /// </summary>
        /// <param name="AccessInformation"></param>
        /// <param name="AlertIndex"></param>
        /// <returns></returns>
        public GetScriptAlertResult GetScriptAlert(AccessControl AccessInformation, string AlertIndex)
        {
            GetScriptAlertResult Result = new GetScriptAlertResult();
            ScriptAlert script = new ScriptAlert();
            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);
                script.BaseInfo = GetIniBaseAlertInfo(AlertIndex, sectionlists);

                script.ScriptServer = sectionlists[AlertIndex]["ScriptServer"];
                script.ServerID = sectionlists[AlertIndex]["ScriptServerID"];
                script.ScriptFile = sectionlists[AlertIndex]["ScriptFile"];
                script.ScriptParam = sectionlists[AlertIndex]["ScriptParam"];
                break;
            }
            Result.ErrorInformation = estr;
            Result.GetScriptAlertOK = ret;
            Result.ResponseData = script;
            return Result;
        }
Example #2
0
        /// <summary>
        /// Script ����
        /// </summary>
        /// <param name="AccessInformation"></param>
        /// <param name="AlertInformation"></param>
        /// <returns></returns>
        public AddAlertResult AddScriptAlert(AccessControl AccessInformation, ScriptAlert 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, "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 + ",ADD");

                if (!meseagebool)
                {
                    estr = keytext[ErrorInfo.PushMessageError.ToString()];
                }

                break;
            }
            Result.ErrorInformation = estr;
            Result.AddAlertOK = ret;
            Result.AlertIndex = strAlertIndex;

            return Result;
        }