Exemple #1
0
        /// <summary>
        /// 获得网站的端口信息
        /// </summary>
        /// <returns></returns>
        public bool GetWebSitePort(ref int iPort)
        {
            bool bResult = false;

            try
            {
                XmlNode node    = xmlOperator.SelectNodeByAttribute("UMPSetted/IISBindingProtocol/ProtocolBind", "Used", "1");
                string  strPort = xmlOperator.SelectAttrib(node, "BindInfo");
                iPort   = int.Parse(strPort);
                bResult = true;
            }
            catch (Exception ex)
            {
                iPort = 0;

                UMPService00.WriteLog("Get port error as umpserver: " + ex.Message + ".\r\nIf not umpserver, please ignore this message");
            }
            return(bResult);
        }
        /// <summary>
        /// 启用备机 更新xml
        /// </summary>
        /// <param name="strSourceKey">备机key</param>
        /// <param name="strTargetKey">主机key</param>
        public static void StartBackupMachine(string strSourceKey, string strTargetKey)
        {
            DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config");

            if (!dir.Exists)
            {
                UMPService00.WriteLog(System.Diagnostics.EventLogEntryType.Error, "Config director is not exists");
                return;
            }
            FileInfo[]  lstFileList = dir.GetFiles("*.xml");
            XmlDocument xmlDoc      = null;
            XMLOperator xmlOperator = null;

            foreach (FileInfo file in lstFileList)
            {
                //如果不是参数的xml 跳过
                if (!file.Name.ToLower().StartsWith("umpparam_"))
                {
                    continue;
                }
                UMPService00.WriteLog("File Name = " + file.Name);
                xmlDoc = new XmlDocument();
                xmlDoc.Load(file.FullName);
                xmlOperator = new XMLOperator(xmlDoc);
                #region 修改备机xml部分
                XmlNode node = xmlOperator.SelectNodeByAttribute("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer", "ModuleNumber", strSourceKey);
                if (node != null)
                {
                    string strStandByRole = xmlOperator.SelectAttrib(node, "StandByRole");
                    if (!strStandByRole.Equals("3"))
                    {
                        UMPService00.WriteLog(System.Diagnostics.EventLogEntryType.Error, "The backup machine module number is error");
                        break;
                    }
                    //查找这个属性 如果返回值为空 表示没有这个属性
                    string strAttrContent = xmlOperator.SelectAttrib(node, "ReplaceModuleNumber");

                    UMPService00.WriteLog("old ReplaceModuleNumber = " + strAttrContent);
                    if (string.IsNullOrEmpty(strAttrContent))
                    {
                        //没有这个属性 则增加
                        xmlOperator.InsertAttrib(node, "ReplaceModuleNumber", strTargetKey);
                    }
                    else
                    {
                        bool bo = xmlOperator.UpdateAttrib(node, "ReplaceModuleNumber", strTargetKey);
                    }
                }
                else
                {
                    UMPService00.WriteLog("file " + file.Name + ", module number = " + strSourceKey + " in voice server ,node is null");;
                }

                #endregion

                #region 修改主机xml部分
                node = xmlOperator.SelectNodeByAttribute("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer", "ModuleNumber", strTargetKey);
                if (node != null)
                {
                    string strStandByRole = xmlOperator.SelectAttrib(node, "StandByRole");
                    if (!strStandByRole.Equals("0"))
                    {
                        UMPService00.WriteLog(System.Diagnostics.EventLogEntryType.Error, "The main machine module number is error,StandByRole = " + strStandByRole);
                        break;
                    }
                    //查找这个属性 如果返回值为空 表示没有这个属性
                    string strAttrContent = xmlOperator.SelectAttrib(node, "ReplaceModuleNumber");
                    UMPService00.WriteLog("old ReplaceModuleNumber = " + strAttrContent);
                    if (string.IsNullOrEmpty(strAttrContent))
                    {
                        //没有这个属性 则增加
                        xmlOperator.InsertAttrib(node, "ReplaceModuleNumber", strSourceKey);
                    }
                    else
                    {
                        bool bo = xmlOperator.UpdateAttrib(node, "ReplaceModuleNumber", strSourceKey);
                    }
                }
                else
                {
                    UMPService00.WriteLog("file " + file.Name + ", module number = " + strSourceKey + " in voice server ,node is null");
                }

                #endregion

                xmlOperator.Save(file.FullName);
                UMPService00.WriteLog("save file " + file.FullName);
            }
        }