public void TestGetLogs() { StarMapService service = new StarMapService("secret", "McDonald", "http://beta.edsm.net:8000/"); Dictionary <string, StarMapLogInfo> logs = service.getStarMapLog(); Assert.AreEqual(1, logs.Count); }
public static void obtainEdsmLogs(StarMapConfiguration starMapConfiguration, string commanderName, IProgress <string> progress) { StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName); try { Dictionary <string, StarMapLogInfo> systems = starMapService.getStarMapLog(); Dictionary <string, string> comments = starMapService.getStarMapComments(); int total = systems.Count; int i = 0; foreach (string system in systems.Keys) { progress.Report("Obtaining log " + i++ + "/" + total); StarSystem CurrentStarSystem = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(system, false); CurrentStarSystem.visits = systems[system].visits; CurrentStarSystem.lastvisit = systems[system].lastVisit; if (comments.ContainsKey(system)) { CurrentStarSystem.comment = comments[system]; } StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem); } progress.Report("Obtained log"); } catch (EDSMException edsme) { progress.Report("EDSM error received: " + edsme.Message); } }
/// <summary> /// Obtain the EDSM log and sync it with the local datastore /// </summary> private void edsmObtainLogClicked(object sender, RoutedEventArgs e) { IEDDIStarSystemRepository starSystemRepository = new EDDIStarSystemSqLiteRepository(); StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); string commanderName; if (String.IsNullOrEmpty(starMapConfiguration.commanderName)) { // Fetch the commander name from the companion app CompanionAppService companionAppService = new CompanionAppService(debug); Commander cmdr = companionAppService.Profile(); if (cmdr != null && cmdr.Name != null) { commanderName = cmdr.Name; } else { edsmFetchLogsButton.IsEnabled = false; edsmFetchLogsButton.Content = "Companion app not configured and no name supplied; cannot obtain logs"; return; } } else { commanderName = starMapConfiguration.commanderName; } edsmFetchLogsButton.IsEnabled = false; edsmFetchLogsButton.Content = "Obtaining log..."; StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName); Dictionary <string, StarMapLogInfo> systems = starMapService.getStarMapLog(); foreach (string system in systems.Keys) { EDDIStarSystem CurrentStarSystemData = starSystemRepository.GetEDDIStarSystem(system); if (CurrentStarSystemData == null) { // We have no record of this system; set it up CurrentStarSystemData = new EDDIStarSystem(); CurrentStarSystemData.Name = system; // Due to the potential large number of systems being imported we don't pull individual system data at this time } CurrentStarSystemData.TotalVisits = systems[system].visits; CurrentStarSystemData.LastVisit = systems[system].lastVisit; CurrentStarSystemData.PreviousVisit = systems[system].previousVisit; starSystemRepository.SaveEDDIStarSystem(CurrentStarSystemData); } edsmFetchLogsButton.Content = "Log obtained"; }
public static void obtainEdsmLogs(StarMapConfiguration starMapConfiguration, string commanderName, IProgress <string> progress) { StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName); Dictionary <string, StarMapLogInfo> systems = starMapService.getStarMapLog(); Dictionary <string, string> comments = starMapService.getStarMapComments(); foreach (string system in systems.Keys) { progress.Report(system); StarSystem CurrentStarSystem = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(system, false); CurrentStarSystem.visits = systems[system].visits; CurrentStarSystem.lastvisit = systems[system].lastVisit; if (comments.ContainsKey(system)) { CurrentStarSystem.comment = comments[system]; } StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem); } }
public static void obtainEdsmLogs(StarMapConfiguration starMapConfiguration, string commanderName, IProgress <string> progress) { StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName); try { Dictionary <string, StarMapLogInfo> systems = starMapService.getStarMapLog(); Dictionary <string, string> comments = starMapService.getStarMapComments(); int total = systems.Count; int i = 0; List <StarSystem> syncSystems = new List <StarSystem>(); foreach (string system in systems.Keys) { ++i; progress.Report($"{Properties.EDSMResources.log_button_fetching_progress} {i}/{total}"); StarSystem CurrentStarSystem = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(system, false); CurrentStarSystem.visits = systems[system].visits; CurrentStarSystem.lastvisit = systems[system].lastVisit; if (comments.ContainsKey(system)) { CurrentStarSystem.comment = comments[system]; } syncSystems.Add(CurrentStarSystem); if (syncSystems.Count == StarMapService.syncBatchSize) { StarMapService.saveStarSystems(syncSystems); syncSystems.Clear(); } } if (syncSystems.Count > 0) { StarMapService.saveStarSystems(syncSystems); } progress.Report(Properties.EDSMResources.log_button_fetched); } catch (EDSMException edsme) { progress.Report(Properties.EDSMResources.log_button_error_received + edsme.Message); } }
public void TestGetLogs() { StarMapService service = new StarMapService("secret", "McDonald", "http://beta.edsm.net:8000/"); Dictionary<string, StarMapLogInfo> logs = service.getStarMapLog(); Assert.AreEqual(1, logs.Count); }
public static void obtainEdsmLogs(StarMapConfiguration starMapConfiguration, string commanderName, IProgress<string> progress) { StarMapService starMapService = new StarMapService(starMapConfiguration.apiKey, commanderName); Dictionary<string, StarMapLogInfo> systems = starMapService.getStarMapLog(); Dictionary<string, string> comments = starMapService.getStarMapComments(); foreach (string system in systems.Keys) { progress.Report(system); StarSystem CurrentStarSystem = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(system, false); CurrentStarSystem.visits = systems[system].visits; CurrentStarSystem.lastvisit = systems[system].lastVisit; if (comments.ContainsKey(system)) { CurrentStarSystem.comment = comments[system]; } StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem); } }