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); } }
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 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); } }