/// <summary> /// 从GloableSetting中读取LicenseServer信息 /// </summary> /// <returns></returns> public List <LicenseServer> GetLicenseServersOnUMPServer() { List <LicenseServer> lstServers = new List <LicenseServer>(); try { XmlNode serversNode = xmlOperator.SelectNode("Parameters02/LicenseServer", ""); LicenseServer server = null; string LStrVerificationCode001 = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M101); foreach (XmlNode node in serversNode.ChildNodes) { if (!node.Name.Equals("LicServer")) { continue; } server = new LicenseServer(); int iEnable = int.Parse(EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P02"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101)); if (iEnable == 1) { server = new LicenseServer(); server.IsMain = int.Parse(xmlOperator.SelectAttrib(node, "P01")); server.Host = EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P03"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101); server.Port = int.Parse(EncryptionAndDecryption.EncryptDecryptString(xmlOperator.SelectAttrib(node, "P04"), LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101)); lstServers.Add(server); } } } catch (Exception ex) { UMPService00.WriteLog("GetLicenseServersOnUMPServer() " + ex.Message); } return(lstServers); }
/// <summary> /// 根据ModuleNumber从voicexml中读取IP /// </summary> /// <param name="strModuleNumber"></param> /// <returns></returns> public static string GetVoiceServerHostByModuleNumber(int strModuleNumber) { string strHost = string.Empty; try { DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config"); if (!dir.Exists) { UMPService00.WriteLog("Config director is not exists"); return(strHost); } string strFileName = string.Format("umpparam_voc{0:0000}.xml", strModuleNumber); string strVoiceleFilePath = dir.FullName + "\\" + strFileName; FileInfo fileInfo = new FileInfo(strVoiceleFilePath); if (!fileInfo.Exists) { UMPService00.WriteLog("umpparam_simp.xml is not exists"); return(strHost); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strVoiceleFilePath); XMLOperator xmlOperator = new XMLOperator(xmlDoc); XmlNode hostNode = xmlOperator.SelectNode("Configurations/Configuration/Sites/Site/VoiceServers/VoiceServer/HostAddress", ""); strHost = xmlOperator.SelectAttrib(hostNode, "Value"); string LStrVerificationCode101 = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M101); strHost = EncryptionAndDecryption.EncryptDecryptString(strHost, LStrVerificationCode101, EncryptionAndDecryption.UMPKeyAndIVType.M101); UMPService00.WriteLog(EventLogEntryType.Warning, "Host = " + strHost); } catch (Exception ex) { UMPService00.WriteLog("GetVoiceServerHostByModuleNumber error:" + ex.Message); } return(strHost); }
/// <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> /// 写入日志路径到LocalMachine.ini中 /// </summary> public static bool WriteLogPath(string strPath) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(strPath); XMLOperator xmlOperator = new XMLOperator(xmldoc); XmlNode LocalMachineNode = xmlOperator.SelectNode("Configurations/Configuration/LocalMachine", ""); string strLogPath = xmlOperator.SelectAttrib(LocalMachineNode, "LogPath"); string strProgramDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config"; string strLocalMachineIni = strProgramDataPath + "\\localmachine.ini"; IniOperation ini = new IniOperation(strLocalMachineIni); ini.IniWriteValue("LocalMachine", "LogPath", strLogPath); // UMPService00.IEventLog.WriteEntry("LogPath = " + strLogPath, EventLogEntryType.Warning); return(true); }
/// <summary> /// 获取备机代替的主机Key/ModuleNumber /// </summary> public static string GetBackupMachineInfo() { string strKey = string.Empty; DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config"); if (!dir.Exists) { UMPService00.WriteLog("Config director is not exists"); return(strKey); } string strSimpleFilePath = dir.FullName + "\\umpparam_simp.xml"; FileInfo fileInfo = new FileInfo(strSimpleFilePath); if (!fileInfo.Exists) { UMPService00.WriteLog("umpparam_simp.xml is not exists"); return(strKey); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strSimpleFilePath); XMLOperator xmlOp = new XMLOperator(xmlDoc); XmlNode VoiceServersNodes = xmlOp.SelectNode("Configurations/Configuration/Sites/Site/VoiceServers", ""); if (VoiceServersNodes.ChildNodes.Count <= 0) { UMPService00.WriteLog("No voiceserver"); return(strKey); } foreach (XmlNode node in VoiceServersNodes.ChildNodes) { strKey = xmlOp.SelectAttrib(node, "ReplaceModuleNumber"); if (!string.IsNullOrEmpty(strKey)) { break; } } //strKey = xmlOp.SelectAttrib() return(strKey); }
/// <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); }