Exemple #1
0
        public static DataBaseManager GetDataBaseManager()
        {
            lock (mutex)
            {
                if (_instance == null)
                {
                    _instance = new DataBaseManager();
                }
            }

            return(_instance);
        }
        public List <Server> GetServers(string XmlPath)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                if (string.IsNullOrEmpty(XmlPath) || string.IsNullOrWhiteSpace(XmlPath))
                {
                    XmlPath = ReadKey(XML_NAME_DEFAULT);
                }

                xmlDoc.Load(XmlPath);
                XmlNodeList nodes = xmlDoc.SelectNodes(ROOT);
                foreach (XmlNode rootNode in nodes)
                {
                    XmlNodeList channelNodeList = rootNode.SelectNodes(Server);
                    foreach (XmlNode chNode in channelNodeList)
                    {
                        Server newServer = new Server();


                        if (newServer != null)
                        {
                            newServer.ServerId    = int.Parse(chNode.Attributes[Server_ID].Value);
                            newServer.ServerName  = chNode.Attributes[Server_NAME].Value;
                            newServer.UserName    = chNode.Attributes[User_Name].Value;
                            newServer.Passwerd    = int.Parse(chNode.Attributes[Passwerd].Value);
                            newServer.Description = chNode.Attributes[DESCRIPTION].Value;
                            newServer.DataBase    = DataBaseManager.GetDevices(chNode);
                            SQLServers.Add(newServer);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EventscadaException?.Invoke(GetType().Name, ex.Message);
            }

            return(SQLServers);
        }