예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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);
        }
예제 #5
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);
        }
예제 #6
0
        /// <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);
            }
        }
예제 #7
0
        /// <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);
        }