Exemple #1
0
 public void GetServers()
 {
     try
     {
         GroupServerList gsl = null;
         updateDate = DateTime.MinValue;
         servers    = null;
         if (File.Exists(Serializer.CreateInstance().applicationFolder + "Servers.xml"))
         {
             gsl = (Serializer.CreateInstance().DeserializeFromXML(typeof(GroupServerList), "Servers.xml") as GroupServerList);
         }
         if (gsl == null)
         {
             gsl = GroupServerList.CreateInstance();
         }
         if (gsl.GetServerList(groupName) != null && gsl.GetServerList(groupName).servers.Count != 0)
         {
             updateDate = gsl.GetServerList(groupName).updateDate;
             servers    = gsl.GetServerList(groupName).servers;
         }
     }
     catch (Exception exception)
     { Console.WriteLine(exception.Message); }
 }
Exemple #2
0
        public void ReloadGroupServerDatabaseListAndSaveToXML()
        {
            inProgress = true;
            OnUpdated(EventArgs.Empty);

            GroupList        groupList = GroupList.instance;
            GroupServerList  gsl;
            ServerList       serverList = new ServerList();
            TravelServerList tsl;
            TravelServer     travelServer = new TravelServer();

            InternetExplorer ie = new InternetExplorer();

            groupList.GetGroupsFromWeb(ie, false);
            groupList.SaveListToXML();

            foreach (string group in groupList.groups)
            {
                //Get server pairs from files or web site
                serverList.groupName = group;
                if (group.ToUpper().Equals("PPE"))
                {
                    serverList.GetServersFromFile(null);
                }
                else
                {
                    serverList.GetServersFromWeb(ie, false);
                }
                //Save server pairs to XML file
                if (File.Exists(Serializer.CreateInstance().applicationFolder + "Servers.xml"))
                {
                    gsl = (Serializer.CreateInstance().DeserializeFromXML(typeof(GroupServerList), "Servers.xml") as GroupServerList);
                    gsl.groupServers.Remove(gsl.GetServerList(serverList.groupName));
                }
                else
                {
                    gsl = GroupServerList.CreateInstance();
                }
                gsl.groupServers.Add(serverList);
                gsl.SaveListToXML();

                foreach (Server serverPair in serverList.servers)
                {
                    //Get databases from registry
                    travelServer.MachineName = serverPair.travelServer;
                    travelServer.GetDatabasesFromRegistryAndChangeProgressBar(null);
                    //Save databases to XML file
                    if (File.Exists(Serializer.CreateInstance().applicationFolder + "Databases.xml"))
                    {
                        tsl = (Serializer.CreateInstance().DeserializeFromXML(typeof(TravelServerList), "Databases.xml") as TravelServerList);
                        tsl.travelServers.Remove(tsl.GetTravelServer(travelServer.MachineName));
                    }
                    else
                    {
                        tsl = TravelServerList.CreateInstance();
                    }
                    tsl.travelServers.Add(travelServer);
                    tsl.SaveListToXml();
                }
            }

            ie.Quit();
            inProgress = false;
            OnUpdated(EventArgs.Empty);
        }