private void ImportProfileServersIfNeeded() { try { if (!Properties.Settings.Default.HaveImportedProfileServers) { var persister = new GameManagement.ServerPersister(ServerManager.GetServerDataFolder()); var allServers = persister.GetWildWestServerList(); foreach (var serverName in GetAllProfileServerNames()) { var existingServer = ServerManager.ServerList.FirstOrDefault(qq => streqi(qq.ServerName, serverName)); if (existingServer == null) { var servData = allServers.FirstOrDefault(qq => streqi(qq.ServerName, serverName)); if (servData != null) { var model = ServerModel.Create(servData); ServerManager.ServerList.Add(model); } else { Logger.WriteInfo($"Ignoring unknown server '{serverName}'"); } } } Properties.Settings.Default.HaveImportedProfileServers = true; Properties.Settings.Default.Save(); } } catch (Exception exc) { Logger.WriteError("Failed to import profile servers: " + exc.ToString()); } }
private void LoadServers() { _serverModels.Clear(); var persister = new GameManagement.ServerPersister(ServerManager.GetServerDataFolder()); var allServers = persister.GetWildWestServerList(); var availableServers = allServers.Where(q => !IsInOurServers(q)); foreach (var servdata in availableServers) { ServerModel model = ServerModel.Create(servdata); _serverModels.Add(model); } }
private static void AddOrUpdateServer(GameManagement.ServerPersister.ServerData servdata) { var existing = ServerList.FirstOrDefault(s => s.IsEqual(servdata)); if (existing != null) { existing.ServerName = servdata.ServerName; existing.ServerDescription = servdata.ServerDesc; existing.ServerIpAndPort = servdata.ConnectionString; existing.RodatSetting = servdata.RodatSetting; existing.VisibilitySetting = servdata.VisibilitySetting; existing.EMU = servdata.EMU; } else { ServerModel model = ServerModel.Create(servdata); ServerList.Add(model); } }