Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public GloableParamOperation(string strPath)
        {
            strFileName = strPath + "\\GlobalSettings\\UMP.Server.01.xml";

            UMPService00.WriteLog("path = " + strFileName);
            xmlDoc = Common.CreateXmlDocumentIfNotExists(strPath + "\\GlobalSettings", "UMP.Server.01.xml", "UMPSetted");
            if (xmlDoc == null)
            {
                UMPService00.WriteLog("xmlDoc is null");
            }
            xmlOperator = new XMLOperator(xmlDoc);
        }
Ejemplo n.º 3
0
 private void GetLogParam(ref int iLogSaveTime, ref int iLogCompressTime)
 {
     try
     {
         string strProgramDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
         //获得日志保存时间
         string        strLogParamDirPath = strProgramDataPath + "\\VoiceServer\\UMP.Server";
         DirectoryInfo dir = new DirectoryInfo(strProgramDataPath);
         if (!dir.Exists)
         {
             //在安装出错的情况下 会不存在
             //dir.Create();
             iLogCompressTime = 24;
             iLogSaveTime     = 30;
             return;
         }
         //从Args03.UMP.xml读取日志参数
         //XmlDocument xmlDoc = Common.CreateXmlDocumentIfNotExists(strLogParamDirPath, "Args03.UMP.xml", "Parameters03");
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(strLogParamDirPath + "\\Args03.UMP.xml");
         XMLOperator xmlOperator    = new XMLOperator(xmlDoc);
         string      strLogSaveTime = xmlOperator.SelectNodeText("Parameters03/LogConfig/SaveTime");
         if (string.IsNullOrEmpty(strLogSaveTime))
         {
             iLogSaveTime = 30;
         }
         else
         {
             int.TryParse(strLogSaveTime, out iLogSaveTime);
             iLogSaveTime = iLogSaveTime == 0 ? 30 : iLogSaveTime;
         }
         string strLogCompressTime = xmlOperator.SelectNodeText("Parameters03/LogConfig/CompressTime");
         if (string.IsNullOrEmpty(strLogCompressTime))
         {
             iLogCompressTime = 24;
         }
         else
         {
             int.TryParse(strLogCompressTime, out iLogCompressTime);
             iLogCompressTime = iLogCompressTime == 0 ? 24 : iLogCompressTime;
         }
     }
     catch (Exception ex)
     {
         iLogCompressTime = 24;
         iLogSaveTime     = 30;
     }
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 在获取License信息时调用 需要传入当前服务所在的路径 拼出xml地址
 /// </summary>
 /// <param name="strFilePath"></param>
 public LicenseServerOperation(string strFilePath, string strFileName)
 {
     try
     {
         strXmlFilePath = strFilePath + strFileName;
         xmlDoc         = new XmlDocument();
         xmlDoc.Load(strXmlFilePath);
         xmlOperator = new XMLOperator(xmlDoc);
         bIsLoadXml  = true;
     }
     catch (Exception ex)
     {
         bIsLoadXml = false;
         UMPService00.WriteLog("LicenseServerOperation() error : " + ex.Message);
     }
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
        }