예제 #1
0
파일: Common.cs 프로젝트: chenmj201601/UMP
        private static string GetComputerServiceStatus(string AStrServiceName)
        {
            string LStrSatus = string.Empty;

            try
            {
                ManagementObjectCollection ObjectCollection;
                ObjectCollection = GetServiceCollection("SELECT * FROM Win32_Service WHERE Name = '" + AStrServiceName + "'");
                foreach (ManagementObject ObjectSingleReturn in ObjectCollection)
                {
                    try
                    {
                        if (ObjectSingleReturn["Started"].Equals(true))
                        {
                            LStrSatus = "1";
                        }
                        else
                        {
                            LStrSatus = "0";
                        }
                        break;
                    }
                    catch (Exception ex)
                    {
                        LStrSatus = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                LStrSatus = string.Empty;
                UMPService00.WriteLog(LogMode.Error, "GetComputerServiceStatus error : " + ex.Message);
            }
            return(LStrSatus);
        }
예제 #2
0
파일: Common.cs 프로젝트: chenmj201601/UMP
        /// <summary>
        /// 获取当前服务安装的路径
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentBaseDirectory()
        {
            string LStrReturn = string.Empty;

            try
            {
                //LStrReturn = AppDomain.CurrentDomain.BaseDirectory;
                //string[] LStrDirectoryArray = LStrReturn.Split('\\');
                //LStrReturn = string.Empty;
                //foreach (string LStrDirectorySingle in LStrDirectoryArray)
                //{
                //    if (LStrDirectorySingle == "WinServices") { break; }
                //    LStrReturn += LStrDirectorySingle + "\\";
                //}
                string path = AppDomain.CurrentDomain.BaseDirectory;
                path       = path.Substring(0, path.LastIndexOf("\\"));
                path       = path.Substring(0, path.LastIndexOf("\\"));
                LStrReturn = path;
                UMPService00.WriteLog(LogMode.Error, "Read AppDomain.CurrentDomain.BaseDirectory : " + LStrReturn);
            }
            catch (Exception ex)
            {
                LStrReturn = string.Empty;
                UMPService00.WriteLog(LogMode.Error, "Read AppDomain.CurrentDomain.BaseDirectory Failed\n" + ex.ToString());
            }

            return(LStrReturn);
        }
예제 #3
0
        public static void SendMsg(_TAG_NETPACK_DISTINGUISHHEAD_VER1 netpackHead, byte[] byteFollowData, Socket socket)
        {
            byte[] byteNetpackHead   = Common.StructToBytes(netpackHead);
            int    iFollowDataLength = 0;

            if (byteFollowData != null)
            {
                iFollowDataLength = byteFollowData.Length;
            }
            byte[] byteSend = new byte[iFollowDataLength + byteNetpackHead.Length];
            byteNetpackHead.CopyTo(byteSend, 0);
            if (byteFollowData != null)
            {
                byteFollowData.CopyTo(byteSend, byteNetpackHead.Length);
            }
            if (socket.Connected)
            {
                socket.Send(byteSend);
            }
            else
            {
                //UMPService00.IEventLog.WriteEntry("Socket connection closed,send message error", EventLogEntryType.Warning);
                UMPService00.WriteLog(LogMode.Error, "Socket connection closed,send message error");
            }
        }
예제 #4
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);
        }
예제 #5
0
        /// <summary>
        /// 检查是否是ump服务器
        /// </summary>
        /// <param name="strPath"></param>
        /// <param name="strFileName"></param>
        /// <returns></returns>
        public static bool CheckIsUMPServer()
        {
            bool bResult = false;

            try
            {
                string        strPath        = Common.GetCurrentBaseDirectory().Trim('\\') + "\\GlobalSettings";
                List <string> lstFiles       = Directory.GetFiles(strPath).ToList();
                string        strXmlFilePath = strPath + @"\" + "UMP.Server.01.xml";
                UMPService00.WriteLog("check umpserver  path = " + strXmlFilePath);
                if (lstFiles.Contains(strXmlFilePath))
                {
                    bResult = true;
                }
                else
                {
                    bResult = false;
                }
            }
            catch
            {
                bResult = false;
            }
            return(bResult);
        }
예제 #6
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);
        }
예제 #7
0
파일: Common.cs 프로젝트: chenmj201601/UMP
        /// <summary>
        /// 拷贝文件 尝试拷贝5次 通过比较最后修改时间来判断是否拷贝成功 每次拷贝间隔2秒
        /// </summary>
        /// <param name="strSrcDir">源文件路径</param>
        /// <param name="strTargetDir">目标文件路径</param>
        public static bool CopyFile(string strSrcDir, string strTargetDir)
        {
            string        strTarget = strTargetDir.Substring(0, strTargetDir.LastIndexOf('\\'));
            DirectoryInfo dir       = new DirectoryInfo(strTarget);

            if (!dir.Exists)
            {
                UMPService00.WriteLog(LogMode.Warn, "strTargetDir  not exists");
                dir.Create();
            }

            FileInfo targetFile = null;
            FileInfo sourceFile = null;

            for (int i = 0; i < 5; i++)
            {
                sourceFile = new FileInfo(strSrcDir);
                targetFile = new FileInfo(strTargetDir);
                if (targetFile.Exists)
                {
                    if (sourceFile.LastWriteTime == targetFile.LastWriteTime)
                    {
                        break;
                    }
                    else
                    {
                        File.Copy(strSrcDir, strTargetDir, true);
                    }
                }
                else
                {
                    File.Copy(strSrcDir, strTargetDir, true);
                }
                Thread.Sleep(2000);
            }
            sourceFile = new FileInfo(strSrcDir);
            targetFile = new FileInfo(strTargetDir);
            if (targetFile.Exists)
            {
                if (targetFile.LastWriteTime == sourceFile.LastWriteTime)
                {
                    File.Delete(strSrcDir);
                    return(true);
                }
                else
                {
                    File.Delete(strSrcDir);
                    return(false);
                }
            }
            else
            {
                File.Delete(strSrcDir);
                return(false);
            }
        }
예제 #8
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);
        }
예제 #9
0
        /// <summary>
        /// 日志压缩和回删
        /// </summary>
        public void LogCompressionAndDelete()
        {
            string   strProgramDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            DateTime dtCurrTime;
            DateTime strLastModifyTime;
            int      iLogSaveTime     = 0; //日志保存时长  默认30天
            int      iLogCompressTime = 0; //压缩多久前的日志  默认24小时

            try
            {
                while (true)
                {
                    //获得日志路径
                    string        strLocalMachineDir = strProgramDataPath + "\\VoiceCyber\\UMP\\config";
                    DirectoryInfo dir = new DirectoryInfo(strLocalMachineDir);
                    if (!dir.Exists)
                    {
                        //如果没有C:\ProgramData\VoiceCyber\UMP\config文件夹  说明程序有误 因为这个文件夹在服务启动时生成
                        UMPService00.WriteLog(LogMode.Error, "Can not find the path : " + strLocalMachineDir);
                        break;
                    }
                    IniOperation ini        = new IniOperation(strLocalMachineDir + "\\localmachine.ini");
                    string       strLogPath = ini.IniReadValue("LocalMachine", "LogPath");
                    if (string.IsNullOrEmpty(strLogPath))
                    {
                        //如果没有配置日志路径 暂停5分钟
                        UMPService00.WriteLog(LogMode.Error, "No configuration log path , pause 5 minutes");
                        Thread.Sleep(5 * 60 * 1000);
                        continue;
                    }
                    //判断日志路径是否存在
                    dir = new DirectoryInfo(strLogPath);
                    if (!dir.Exists)
                    {
                        UMPService00.WriteLog(LogMode.Error, "Can not find the log file path : " + strLogPath + ", pause 5 minutes");
                        Thread.Sleep(5 * 60 * 1000);
                        continue;
                    }
                    GetLogParam(ref iLogSaveTime, ref iLogCompressTime);
                    // UMPService00.IEventLog.WriteEntry("iLogSaveTime = " + iLogSaveTime + " ; iLogCompressTime = " + iLogCompressTime, EventLogEntryType.Warning);
                    //获得当前时间
                    dtCurrTime = DateTime.Now;
                    LogFileOperate(dir, dtCurrTime, iLogSaveTime, iLogCompressTime);
                    UMPService00.WriteLog("ok ,sleep 3 mins");
                    Thread.Sleep(3 * 60 * 1000);
                }
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog(LogMode.Error, "LogCompressionAndDelete() error : " + ex.Message);
            }
        }
예제 #10
0
 /// <summary>
 /// 修改属性
 /// </summary>
 /// <param name="XmlPathNode">属性所在的节点</param>
 /// <param name="Attrib">属性名</param>
 /// <param name="Content">属性值</param>
 /// <returns></returns>
 public bool UpdateAttrib(string XmlPathNode, string Attrib, string AttribContent)
 {
     try
     {
         //修改属性值
         XmlDoc.SelectSingleNode(XmlPathNode).Attributes[Attrib].Value = AttribContent;
         return(true);
     }
     catch (Exception ex)
     {
         UMPService00.WriteLog("error : " + ex.Message);
         return(false);
     }
 }
예제 #11
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);
     }
 }
예제 #12
0
파일: Common.cs 프로젝트: chenmj201601/UMP
 /// <summary>
 /// 杀进程
 /// </summary>
 /// <param name="AStrProcessId"></param>
 private static void KillProcess(string AStrProcessId)
 {
     try
     {
         ManagementObjectCollection ObjectCollection;
         ObjectCollection = GetServiceCollection("Select * from win32_process where ProcessID = '" + AStrProcessId + "'");
         foreach (ManagementObject SingleCollenction in ObjectCollection)
         {
             SingleCollenction.InvokeMethod("Terminate", null);
         }
     }
     catch (Exception ex)
     {
         UMPService00.WriteLog(LogMode.Error, "KillProcess error : " + ex.Message);
     }
 }
예제 #13
0
        /// <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);
        }
예제 #14
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="strMessage">xml文件路径</param>
        public static bool SendBroadcastMessage(string strMessage)
        {
            string       strProgramDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config";
            string       strLocalMachineIni = strProgramDataPath + "\\localmachine.ini";
            IniOperation ini            = new IniOperation(strLocalMachineIni);
            string       strHostAndPort = ini.IniReadValue("LocalMachine", "SubscribeAddress");

            //IP端口字符串不正确
            if (string.IsNullOrEmpty(strHostAndPort) || !strHostAndPort.Contains(','))
            {
                // UMPService00.IEventLog.WriteEntry("localmachine.ini  SubscribeAddress value is error", EventLogEntryType.Error);
                UMPService00.WriteLog(LogMode.Error, "localmachine.ini  SubscribeAddress value is error");
                return(false);
            }
            string strHost      = strHostAndPort.Substring(0, strHostAndPort.IndexOf(','));
            int    iPort        = int.Parse(strHostAndPort.Substring(strHostAndPort.IndexOf(',') + 1));
            string strMachineID = ini.IniReadValue("LocalMachine", "MachineID");

            IPAddress address = IPAddress.Parse(strHost);
            // IPAddress address = IPAddress.Parse("fe80::c4c2:9114:91e8:fbad%12");
            Socket socket = null;

            if (address.AddressFamily == AddressFamily.InterNetwork)
            {
                //UMPService00.IEventLog.WriteEntry("IPV4", EventLogEntryType.Warning);
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            }
            else if (address.AddressFamily == AddressFamily.InterNetworkV6)
            {
                // UMPService00.IEventLog.WriteEntry("IPV6", EventLogEntryType.Warning);
                socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
            }
            // UMPService00.IEventLog.WriteEntry("strHost = " + strHost + "\r\niPort = " + iPort.ToString(), EventLogEntryType.Warning);
            socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(address));
            //SocketOptionName.MulticastTimeToLive  IP多路广播生存时间。
            socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 2);
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            IPEndPoint ipep = new IPEndPoint(address, iPort);

            socket.Connect(ipep);
            SendDgramMsg(strMessage, strMachineID, socket);
            return(true);
        }
예제 #15
0
        /// <summary>
        /// 从ProgramData获得中获得IIS信息(IP、端口)
        /// </summary>
        /// <returns></returns>
        public bool GetWebSitePort(ref int iPort, ref string strHost)
        {
            bool bResult = false;

            try
            {
                XmlNode node    = xmlOperator.SelectNodeByAttribute("UMPSetted/IISBindingProtocol/ProtocolBind", "Used", "1");
                string  strPort = xmlOperator.SelectAttrib(node, "BindInfo");
                iPort   = int.Parse(strPort);
                strHost = xmlOperator.SelectAttrib(node, "IPAddress");
                bResult = true;
            }
            catch (Exception ex)
            {
                bResult = false;
                UMPService00.WriteLog("Get port error as voiceserver : " + ex.Message + ".\r\nIf not voiceserver, please ignore this message");
            }
            return(bResult);
        }
예제 #16
0
        /// <summary>
        /// 压缩到期的log文件 并删掉压缩完成对log文件
        /// </summary>
        private void CompressFile(DirectoryInfo dir, int iLogCompressTime, DateTime dtCurrTime)
        {
            List <FileInfo> lstFiles       = dir.GetFiles("*.log").ToList();
            ZipOutputStream zipOutStream   = null;
            string          strZipFileName = string.Empty;
            TimeSpan        tspan;

            foreach (FileInfo file in lstFiles)
            {
                try
                {
                    tspan = dtCurrTime - file.LastWriteTime;
                    if (tspan.TotalHours < iLogCompressTime)
                    {
                        continue;
                    }

                    strZipFileName = file.Name + ".zip";
                    zipOutStream   = new ZipOutputStream(File.Create(System.IO.Path.Combine(file.DirectoryName, strZipFileName)));
                    zipOutStream.SetLevel(9);
                    byte[]   LByteBuffer = new byte[1024];
                    ZipEntry LZipEntry   = new ZipEntry(file.Name);
                    LZipEntry.DateTime = DateTime.UtcNow;
                    zipOutStream.PutNextEntry(LZipEntry);
                    using (FileStream LFileStream = File.OpenRead(file.FullName))
                    {
                        int LIntSourceBytes;
                        do
                        {
                            LIntSourceBytes = LFileStream.Read(LByteBuffer, 0, LByteBuffer.Length);
                            zipOutStream.Write(LByteBuffer, 0, LIntSourceBytes);
                        } while (LIntSourceBytes > 0);
                    }
                    zipOutStream.Finish(); zipOutStream.Close();
                    file.Delete();
                }
                catch (Exception ex)
                {
                    UMPService00.WriteLog("CompressFile() error : " + ex.Message);
                }
            }
        }
예제 #17
0
        /// <summary>
        /// 获得认证服务器信息(Host,port)
        /// </summary>
        /// <returns></returns>
        public bool GetAuthenticateServerInfo(ref List <string> ALstResult)
        {
            bool bResult = false;

            try
            {
                XmlNode node = xmlOperator.SelectNodeByAttribute("UMPSetted/IISBindingProtocol/ProtocolBind", "Protocol", "http");
                ALstResult.Add(xmlOperator.SelectAttrib(node, "IPAddress"));
                ALstResult.Add(xmlOperator.SelectAttrib(node, "BindInfo"));
                bResult = true;
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog(EventLogEntryType.Warning, "GetAuthenticateServerInfo() error : " + ex.Message);
                ALstResult.Add(string.Empty);
                ALstResult.Add(string.Empty);
                bResult = false;
            }
            return(bResult);
        }
예제 #18
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);
        }
예제 #19
0
파일: Common.cs 프로젝트: chenmj201601/UMP
        /// <summary>
        /// 在文件不存在时创建xml文档
        /// </summary>
        /// <param name="strPath">文件路径(如果没有 就创建)</param>
        /// <param name="strFileName">文件名</param>
        /// <param name="strRootEleName">根节点名</param>
        /// <returns></returns>
        public static XmlDocument CreateXmlDocumentIfNotExists(string strPath, string strFileName, string strRootEleName)
        {
            DirectoryInfo dir = new DirectoryInfo(strPath);

            if (!dir.Exists)
            {
                dir.Create();
            }
            XmlDocument xmlDocument = null;

            try
            {
                List <string> lstFiles       = Directory.GetFiles(strPath).ToList();
                string        strXmlFilePath = strPath + @"\" + strFileName;
                if (!lstFiles.Contains(strXmlFilePath))
                {
                    xmlDocument = new XmlDocument();
                    XmlNode root = xmlDocument.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                    xmlDocument.AppendChild(root);
                    XmlElement ele = xmlDocument.CreateElement(strRootEleName);
                    xmlDocument.AppendChild(ele);
                    xmlDocument.Save(strXmlFilePath);
                }
                else
                {
                    xmlDocument = new XmlDocument();
                    xmlDocument.Load(strXmlFilePath);
                }
                return(xmlDocument);
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog(LogMode.Error, "Load xml error :" + ex.Message);
                return(null);
            }
        }
예제 #20
0
        /// <summary>
        /// 从umpparam_simp.xml中读取License信息
        /// </summary>
        /// <returns></returns>
        public List <LicenseServer> GetLicenseServerOnVoiceServer()
        {
            List <LicenseServer> lstServers = new List <LicenseServer>();

            try
            {
                XmlNode       serversNode             = xmlOperator.SelectNode("Configurations/Configuration/Sites/Site/Resources/LicenseServers", "");
                LicenseServer server                  = null;
                string        LStrVerificationCode001 = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M101);
                if (serversNode == null)
                {
                    return(lstServers);
                }
                string strEnable      = string.Empty;
                string strHostAddress = string.Empty;
                string strPort        = string.Empty;
                foreach (XmlNode node in serversNode.ChildNodes)
                {
                    if (!node.Name.Equals("LicenseServer"))
                    {
                        continue;
                    }
                    strEnable = xmlOperator.SelectAttrib(node, "Enable");
                    if (!strEnable.Equals("1"))
                    {
                        continue;
                    }
                    server = new LicenseServer();
                    bool bLicIsNotNul = false;
                    foreach (XmlNode nodeChild in node.ChildNodes)
                    {
                        bLicIsNotNul = false;
                        if (nodeChild.Name.Equals("HostAddress"))
                        {
                            strHostAddress = xmlOperator.SelectAttrib(nodeChild, "Value");
                            if (string.IsNullOrEmpty(strHostAddress))
                            {
                                UMPService00.WriteLog("GetLicenseServerOnVoiceServer4 ");
                                break;
                            }
                        }
                        if (nodeChild.Name.Equals("HostPort"))
                        {
                            strPort = xmlOperator.SelectAttrib(nodeChild, "Value");
                            if (string.IsNullOrEmpty(strPort))
                            {
                                UMPService00.WriteLog("GetLicenseServerOnVoiceServer5 ");
                                break;
                            }
                        }
                        bLicIsNotNul = true;
                    }
                    if (bLicIsNotNul)
                    {
                        server.Host = EncryptionAndDecryption.EncryptDecryptString(strHostAddress, LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101);
                        server.Port = int.Parse(EncryptionAndDecryption.EncryptDecryptString(strPort, LStrVerificationCode001, EncryptionAndDecryption.UMPKeyAndIVType.M101));
                        lstServers.Add(server);
                    }
                }
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog("GetLicenseServerOnVoiceServer() " + ex.Message);
            }
            return(lstServers);
        }
예제 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strHost"></param>
        /// <param name="iPort"></param>
        /// <param name="moduleTypeID">用来区分是管理员方式连接 和 取license的客户端连接</param>
        /// <param name="sslStream"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public int ConnectToLicenseServer(string strHost, int iPort, int moduleTypeID, ref SslStream sslStream, ref TcpClient client)
        {
            int iResult = 0;

            try
            {
                client = new TcpClient();
                for (int i = 0; i < 3; i++)
                {
                    try
                    {
                        client.Connect(strHost, iPort);
                        if (client.Connected)
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        UMPService00.WriteLog("ConnLic", string.Format("Fail.\t{0}", ex.Message));
                        continue;
                    }
                }
                if (!client.Connected)
                {
                    return(-1);
                }
                sslStream = new SslStream(client.GetStream(), false, Common.ServerValidation, null);
                sslStream.AuthenticateAsClient(client.Client.RemoteEndPoint.ToString());
                string          strResult     = string.Empty;
                NetPacketHeader header        = new NetPacketHeader();
                byte[]          byteFollowMsg = new byte[1];
                ReceiveMessage(ref header, ref byteFollowMsg, sslStream, client);
                bIsEncryted = (header.State & 4) != 0;
                string     strMsg = Processmessage(header, byteFollowMsg);
                JsonObject obj    = new JsonObject(strMsg);
                strSession = obj[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_SESSION].GetValue().ToString();
                int iMessageID = int.Parse(obj[LicenseDefine.KEYWORD_MSG_MESSAGEID].ToString());
                if (iMessageID != 1)
                {
                    UMPService00.WriteLog("The welcome package error");
                    return(-1);
                }

                if (iMessageID == 1)       //收到的是welcome 则返回logon数据包
                {
                    strMsg = string.Empty;
                    JsonObject json = new JsonObject();
                    json[LicenseDefine.KEYWORD_MSG_CLASSDESC]   = new JsonProperty("\"authenticate\"");
                    json[LicenseDefine.KEYWORD_MSG_CLASSID]     = new JsonProperty(LicenseDefine.LICENSE_MSG_CLASS_AUTHENTICATE);
                    json[LicenseDefine.KEYWORD_MSG_CURRENTTIME] = new JsonProperty(DateTime.Now.ToString("\""
                                                                                                         + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""));
                    json[LicenseDefine.KEYWORD_MSG_DATA] = new JsonProperty(new JsonObject());
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_HEARTBEAT]    = new JsonProperty(LicenseDefine.NET_HEARTBEAT_INTEVAL);
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_MODULENAME]   = new JsonProperty("\"License Test\"");
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_MODULENUMBER] = new JsonProperty(-1);
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_MODULETYPEID] = new JsonProperty(moduleTypeID);
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_PROTOCOL]     = new JsonProperty("\"" + LicenseDefine.NET_PROTOCOL_VERSION + "\"");
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_SESSION]      = new JsonProperty(strSession);
                    json[LicenseDefine.KEYWORD_MSG_DATA][LicenseDefine.KEYWORD_MSG_VERIFICATION] = new JsonProperty("\"" + Common.GetValidication(strSession) + "\"");
                    json[LicenseDefine.KEYWORD_MSG_MESSAGEDESC] = new JsonProperty("\"longon\"");
                    json[LicenseDefine.KEYWORD_MSG_MESSAGEID]   = new JsonProperty(LicenseDefine.LICENSE_MSG_CLASS_CONNECTION);
                    strMsg = json.ToString();
                    SendMessage(json.ToString(), bIsEncryted, sslStream);
                    ReceiveMessage(ref header, ref byteFollowMsg, sslStream, client);
                    strMsg     = Processmessage(header, byteFollowMsg);
                    obj        = new JsonObject(strMsg);
                    iMessageID = int.Parse(obj[LicenseDefine.KEYWORD_MSG_MESSAGEID].GetValue().ToString());
                    if (iMessageID != 3)
                    {
                        UMPService00.WriteLog("License server verification error : ");
                        return(-1);
                    }
                }
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog("ConnLic", string.Format("Fail.\t{0}", ex.Message));
                iResult = -1;
            }
            return(iResult);
        }
예제 #22
0
        /// <summary>
        /// 在服务启动时 生成参数xml
        /// </summary>
        private void GenerateXmlOnStart()
        {
            try
            {
                bool bIsUMPServer = false;
                //判断是不是UMP服务器
                bIsUMPServer = GloableParamOperation.CheckIsUMPServer();
                string strCurrentPath         = Common.GetCurrentBaseDirectory().Trim('\\');
                GloableParamOperation gbParam = null;
                int    iWebPort            = 0;
                string strWebHost          = string.Empty;
                bool   bResult             = false;
                string strAuthenServerHost = string.Empty;
                string strAuthenServerPort = string.Empty;

                //如果获取端口出错 就假设是Voice服务器  从ProgramData\VoiceServer下获取IIS绑定信息
                if (!bIsUMPServer)
                {
                    UMPService00.WriteLog("voice server ");

                    gbParam             = new GloableParamOperation(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceServer");
                    bResult             = gbParam.GetWebSitePort(ref iWebPort, ref strWebHost);
                    strAuthenServerHost = strWebHost;
                    strAuthenServerPort = iWebPort.ToString();
                }
                else
                {
                    //如果能获取到IIS绑定信息 则Host=127.0.0.1 并获取认证服务器信息
                    //UMPService00.IEventLog.WriteEntry("UMP server");
                    UMPService00.WriteLog("UMP server ");
                    gbParam      = new GloableParamOperation(strCurrentPath.Trim('\\'));
                    bResult      = gbParam.GetWebSitePort(ref iWebPort);
                    bIsUMPServer = true;
                    strWebHost   = "127.0.0.1";
                    List <string> lstAuthenServerInfo = new List <string>();
                    bool          IsGetAuthenServer   = gbParam.GetAuthenticateServerInfo(ref lstAuthenServerInfo);
                    if (!IsGetAuthenServer)
                    {
                        //UMPService00.IEventLog.WriteEntry("Get Authenticate Server Info error", EventLogEntryType.Error);
                        UMPService00.WriteLog(LogMode.Error, "Get Authenticate Server Info error");
                    }
                    else
                    {
                        strAuthenServerHost = lstAuthenServerInfo[0];
                        strAuthenServerPort = lstAuthenServerInfo[1];
                    }
                }
                if (!bResult)
                {
                    // UMPService00.IEventLog.WriteEntry("GenerateXmlOnStart() error : Get website info error", EventLogEntryType.Warning);
                    UMPService00.WriteLog(LogMode.Warn, "GenerateXmlOnStart() error : Get website info error");

                    return;
                }

                //先假设本机为UMP服务器 从ProgramData\UMP.Server下获得数据库信息
                string       strDBFilePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                DatabaseInfo dbInfo        = null;
                bResult = DataBaseXmlOperator.GetDBInfo(strDBFilePath, ref dbInfo);

                if (!bResult)
                {
                    strDBFilePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceServer";
                    bResult       = DataBaseXmlOperator.GetDBInfo(strDBFilePath, ref dbInfo);
                }
                //如果没有获取到数据库信息 那假设本机为Voice服务器 从C:\ProgramData\VoiceServer\UMP.Server下获取数据库信息
                if (!bResult)
                {
                    //UMPService00.IEventLog.WriteEntry("GenerateXmlOnStart() error : Get database info error", EventLogEntryType.Warning);
                    UMPService00.WriteLog(LogMode.Warn, "GenerateXmlOnStart() error : Get database info error");
                    return;
                }
                //UMPService00.IEventLog.WriteEntry("GenerateXmlOnStart dbinfo = "+dbInfo.TypeName + "," + dbInfo.Host + ":" + dbInfo.Port + "," + dbInfo.LoginName + "," + dbInfo.Password + "," + dbInfo.DBName, EventLogEntryType.Warning);

                AppServerInfo serverInfo = new AppServerInfo();
                serverInfo.Protocol     = "http";
                serverInfo.Address      = strWebHost;
                serverInfo.Port         = iWebPort;
                serverInfo.SupportHttps = false;

                int iResult = 0;
                try
                {
                    string      strPath         = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Temp";
                    GenerateXml generate        = new GenerateXml(strPath, dbInfo, serverInfo, strAuthenServerHost, strAuthenServerPort);
                    bool        bIsParamsExists = false;
                    iResult = generate.Generate(bIsUMPServer, ref bIsParamsExists);
                    generate.ClenData();
                }
                catch (Exception ex)
                {
                    //UMPService00.IEventLog.WriteEntry("GenerateXmlOnStart() Geneerate xml failed ,ErrorInfo : " + ex.Message, EventLogEntryType.Error);
                    UMPService00.WriteLog(LogMode.Error, "GenerateXmlOnStart() Geneerate xml failed ,ErrorInfo : " + ex.Message);
                }

                if (iResult == 0)
                {
                    // UMPService00.IEventLog.WriteEntry("Replace param xml success", EventLogEntryType.Information);
                    UMPService00.WriteLog(LogMode.Info, "Replace param xml success");
                    //创建socket 开始发送广播
                    string strSimpFilePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config" + "\\umpparam_simp.xml";
                    SendBroadcastData.WriteLogPath(strSimpFilePath);
                    SendBroadcastData.SendBroadcastMessage(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\VoiceCyber\\UMP\\config");
                }
            }
            catch (Exception ex)
            {
                // UMPService00.IEventLog.WriteEntry("GenerateXmlOnStart() Error : " + ex.Message, EventLogEntryType.Error);

                UMPService00.WriteLog(LogMode.Error, "GenerateXmlOnStart() Error : " + ex.Message);
            }
        }
예제 #23
0
파일: Common.cs 프로젝트: chenmj201601/UMP
        /// <summary>
        /// 重启服务
        /// </summary>
        /// <param name="strServiceName"></param>
        public static bool RestartService(string strServiceName)
        {
            try
            {
                InvokeMethodOptions  OperationMethodOptions = new InvokeMethodOptions(null, new TimeSpan(0, 10, 0));
                ManagementBaseObject LOutStopService;

                ManagementObjectCollection ObjectCollection;
                ObjectCollection = GetServiceCollection(string.Format("SELECT * FROM Win32_Service WHERE Name = '{0}'", strServiceName));
                int    i               = ObjectCollection.Count;
                string LStrProcessId   = string.Empty;
                string LStrDisplayName = string.Empty;
                int    LIntReturnValue = -1;

                foreach (ManagementObject SingleCollenction in ObjectCollection)
                {
                    LStrProcessId   = SingleCollenction["ProcessId"].ToString();
                    LStrDisplayName = SingleCollenction["DisplayName"].ToString();
                    LOutStopService = SingleCollenction.InvokeMethod("StopService", null, OperationMethodOptions);
                    LIntReturnValue = int.Parse(LOutStopService["ReturnValue"].ToString());
                    UMPService00.WriteLog("StopService ReturnValue = " + LIntReturnValue.ToString());
                    if (LIntReturnValue != 0)
                    {
                        int    LIntWaitCount            = 0;
                        string LStrServiceCurrentStatus = GetComputerServiceStatus(strServiceName);
                        if (string.IsNullOrEmpty(LStrServiceCurrentStatus))
                        {
                            UMPService00.WriteLog("GetComputerServiceStatus null");
                            return(false);
                        }
                        while (LStrServiceCurrentStatus != "0" && LIntWaitCount < 30)
                        {
                            System.Threading.Thread.Sleep(2000);
                            LIntWaitCount           += 1;
                            LStrServiceCurrentStatus = GetComputerServiceStatus(strServiceName);
                            UMPService00.WriteLog("GetComputerServiceStatus LStrServiceCurrentStatus = " + LStrServiceCurrentStatus.ToString());
                            if (string.IsNullOrEmpty(LStrServiceCurrentStatus))
                            {
                                UMPService00.WriteLog("GetComputerServiceStatus LStrServiceCurrentStatus is null ,return false");
                                return(false);
                            }
                        }
                        if (LStrServiceCurrentStatus == "0")
                        {
                            LIntReturnValue = 0;
                        }
                        else
                        {
                            KillProcess(LStrProcessId); LIntReturnValue = 0;
                        }

                        //for (int iStartCount = 0; iStartCount < 30; iStartCount++)
                        //{
                        //    Thread.Sleep(2000);
                        //    try
                        //    {
                        //        UMPService00.IEventLog.WriteEntry("start service begin " + iStartCount.ToString());
                        //        LOutStopService = SingleCollenction.InvokeMethod("StartService", null, OperationMethodOptions);
                        //        LIntReturnValue = int.Parse(LOutStopService["ReturnValue"].ToString());
                        //        UMPService00.IEventLog.WriteEntry("Restart service " + strServiceName + ", " + iStartCount.ToString() + ", result = " + LIntReturnValue.ToString(), EventLogEntryType.Warning);
                        //        if (LIntReturnValue == 0)
                        //        {
                        //            return true;
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        UMPService00.IEventLog.WriteEntry("start service exception : " + ex.Message);
                        //    }
                        //}
                    }
                    UMPService00.WriteLog("stop server success", EventLogEntryType.Information);
                    for (int iStartCount = 0; iStartCount < 30; iStartCount++)
                    {
                        Thread.Sleep(2000);
                        try
                        {
                            UMPService00.WriteLog("start service begin " + iStartCount.ToString());
                            LOutStopService = SingleCollenction.InvokeMethod("StartService", null, OperationMethodOptions);
                            LIntReturnValue = int.Parse(LOutStopService["ReturnValue"].ToString());
                            UMPService00.WriteLog(LogMode.Error, "Restart service " + strServiceName + ", " + iStartCount.ToString() + ", result = " + LIntReturnValue.ToString());
                            if (LIntReturnValue == 0)
                            {
                                return(true);
                            }
                        }
                        catch (Exception ex)
                        {
                            UMPService00.WriteLog("start service exception : " + ex.Message);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                UMPService00.WriteLog(EventLogEntryType.Error, "Restart service " + strServiceName + " error : " + ex.Message);
                return(false);
            }
        }
예제 #24
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);
            }
        }
예제 #25
0
        /// <summary>
        /// 从配置文件中读取数据库信息
        /// </summary>
        /// <returns></returns>
        public static string GetDBInfo(string strFilePath)
        {
            try
            {
                DatabaseInfo dbInfo          = new DatabaseInfo();
                string       LStrXmlFileName = string.Empty;
                //LStrXmlFileName = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                LStrXmlFileName = Path.Combine(strFilePath, @"UMP.Server\Args01.UMP.xml");
                if (!File.Exists(LStrXmlFileName))
                {
                    UMPService00.WriteLog(LogMode.Error, "GetDatabaseConnectionProfile() \nThe Database Connection Parameters Is Not Configured");

                    return("Error01");
                }
                XmlDocument LXmlDocArgs01 = new XmlDocument();
                LXmlDocArgs01.Load(LStrXmlFileName);
                XmlNodeList LXmlNodeListDatabase = LXmlDocArgs01.SelectSingleNode("DatabaseParameters").ChildNodes;

                if (LXmlNodeListDatabase.Count <= 0)
                {
                    UMPService00.WriteLog(LogMode.Error, "LXmlNodeListDatabase.Count:  " + LXmlNodeListDatabase.Count);
                    UMPService00.WriteLog(LogMode.Error, "GetDatabaseConnectionProfile() \nThe Database Connection Parameters Is Not Configured");
                    return("Error02");
                }

                string LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M104);
                string LStrAttributesData   = string.Empty;
                #region 数据库连接参数
                foreach (XmlNode LXmlNodeSingleDatabase in LXmlNodeListDatabase)
                {
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P03"].Value;
                    LStrAttributesData = EncryptionAndDecryption.EncryptDecryptString(LStrAttributesData, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104);
                    //UMPService00.IEventLog.WriteEntry("Database Enable: " + LStrAttributesData);
                    if (LStrAttributesData != "1")
                    {
                        continue;
                    }

                    //数据库类型
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P02"].Value;
                    dbInfo.TypeID      = int.Parse(LStrAttributesData);


                    //数据库服务器名或IP地址
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P04"].Value;
                    dbInfo.Host        = LStrAttributesData;

                    //数据库服务端口
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P05"].Value;
                    dbInfo.Port        = int.Parse(EncryptionAndDecryption.EncryptDecryptString(LStrAttributesData, LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104));

                    //数据库名或Service Name
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P06"].Value;
                    dbInfo.DBName      = LStrAttributesData;

                    //登录用户
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P07"].Value;
                    dbInfo.LoginName   = LStrAttributesData;

                    //登录密码
                    LStrAttributesData = LXmlNodeSingleDatabase.Attributes["P08"].Value;
                    dbInfo.Password    = LStrAttributesData;
                    break;
                }
                #endregion
                switch (dbInfo.TypeID)
                {
                case 2:
                    dbInfo.TypeName = "MSSQL";
                    break;

                case 3:
                    dbInfo.TypeName = "ORCL";
                    break;
                }
                LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M004);
                string strResult = dbInfo.TypeID + Common.AscCodeToChr(27) + dbInfo.TypeName + Common.AscCodeToChr(27) + dbInfo.Host + Common.AscCodeToChr(27);
                strResult += EncryptionAndDecryption.EncryptDecryptString(dbInfo.Port.ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M004)
                             + Common.AscCodeToChr(27) + dbInfo.LoginName + Common.AscCodeToChr(27);
                strResult += dbInfo.Password + Common.AscCodeToChr(27);
                strResult += dbInfo.DBName;
                return(strResult);
            }
            catch (Exception ex)
            {
                return("Error 002: " + ex.Message);
            }
        }