public static TravelServerList CreateInstance() { if (instance == null) { instance = new TravelServerList(); } return(instance); }
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); }