/// <summary> /// 在Voice服务器上创建UMP网站的地址和端口 /// </summary> /// <param name="strWebSiteHost"></param> /// <param name="iIISPort"></param> /// <returns></returns> public bool WriteWebSiteInfoOnVoiceServer(string strWebSiteHost, int iIISPort) { bool bIsSucccess = false; try { XmlNode IISNode = xmlOperator.SelectNode("UMPSetted/IISBindingProtocol", ""); if (IISNode == null) { XmlNode rootNode = xmlOperator.SelectNode("UMPSetted", ""); IISNode = xmlOperator.InsertNode("IISBindingProtocol", rootNode); } bool bIsExistsBinding = false; foreach (XmlNode node in IISNode.ChildNodes) { if (node.Name.Equals("ProtocolBind")) { if (xmlOperator.SelectAttrib(node, "Used") == "1") { bIsExistsBinding = true; xmlOperator.UpdateAttrib(node, "BindInfo", iIISPort.ToString()); xmlOperator.UpdateAttrib(node, "IPAddress", strWebSiteHost); xmlOperator.Save(strFileName); break; } } } //如果不存在ProtocolBind节点 则增加 if (!bIsExistsBinding) { XmlNode node = xmlOperator.InsertNode("ProtocolBind", IISNode); List <AttribEntry> lstAttribs = new List <AttribEntry>(); lstAttribs.Add(new AttribEntry("BindInfo", iIISPort.ToString())); lstAttribs.Add(new AttribEntry("IPAddress", strWebSiteHost)); lstAttribs.Add(new AttribEntry("Used", "1")); xmlOperator.InsertAttribs(node, lstAttribs); xmlOperator.Save(strFileName); } bIsSucccess = true; } catch (Exception ex) { UMPService00.WriteLog("WriteWebSiteInfoOnVoiceServer() error : " + ex.Message); } return(bIsSucccess); }
/// <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); } }
/// <summary> /// 在voice服务器上生成数据库连接的xml /// </summary> /// <param name="dbInfo"></param> /// <returns></returns> public static bool WriteDBInfoInVoiceServer(DatabaseInfo dbInfo, string strPath) { bool isSuccess = false; try { string strXmlFileDir = strPath + "\\UMP.Server"; string strXmlFileName = "Args01.UMP.xml"; XmlDocument xmlDoc = Common.CreateXmlDocumentIfNotExists(strXmlFileDir, strXmlFileName, "DatabaseParameters"); XMLOperator xmlOperator = new XMLOperator(xmlDoc); XmlNode paramNode = xmlOperator.SelectNode("DatabaseParameters", ""); bool bIsExistsDB = false; foreach (XmlNode node in paramNode) { if (node.Name == "Database") { string strIsUsed = xmlOperator.SelectAttrib(node, "P03"); string LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M104); strIsUsed = EncryptionAndDecryption.EncryptDecryptString(strIsUsed, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); if (strIsUsed == "1") { bIsExistsDB = true; LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M004); xmlOperator.UpdateAttrib(node, "P02", dbInfo.TypeID.ToString()); xmlOperator.UpdateAttrib(node, "P03", EncryptionAndDecryption.EncryptDecryptString("1", LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P04", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Host, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P05", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Port.ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P06", EncryptionAndDecryption.EncryptDecryptString(dbInfo.DBName, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P07", EncryptionAndDecryption.EncryptDecryptString(dbInfo.LoginName, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P08", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Password, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)); xmlOperator.UpdateAttrib(node, "P10", dbInfo.TypeName); xmlOperator.Save(strXmlFileDir + "\\" + strXmlFileName); break; } } } if (!bIsExistsDB) { string LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M004); XmlNode DatabaseNode = xmlOperator.InsertNode("Database", paramNode); List <AttribEntry> lstAttribs = new List <AttribEntry>(); lstAttribs.Add(new AttribEntry("P01", "1")); lstAttribs.Add(new AttribEntry("P02", dbInfo.TypeID.ToString())); lstAttribs.Add(new AttribEntry("P03", EncryptionAndDecryption.EncryptDecryptString("1", LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P04", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Host, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P05", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Port.ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P06", EncryptionAndDecryption.EncryptDecryptString(dbInfo.DBName, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P07", EncryptionAndDecryption.EncryptDecryptString(dbInfo.LoginName, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P08", EncryptionAndDecryption.EncryptDecryptString(dbInfo.Password, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004))); lstAttribs.Add(new AttribEntry("P09", "")); lstAttribs.Add(new AttribEntry("P10", dbInfo.TypeName)); xmlOperator.InsertAttribs(DatabaseNode, lstAttribs); xmlOperator.Save(strXmlFileDir + "\\" + strXmlFileName); } isSuccess = true; } catch (Exception ex) { isSuccess = false; } return(isSuccess); }