예제 #1
0
        // EDSM flight log synchronization
        public void syncFromStarMapService(DateTime?lastSync = null)
        {
            if (edsmService != null)
            {
                try
                {
                    List <StarMapResponseLogEntry> flightLogs = edsmService.getStarMapLog(lastSync);
                    if (flightLogs?.Count > 0)
                    {
                        Logging.Debug("Syncing from EDSM");
                        Dictionary <string, string> comments = edsmService.getStarMapComments();
                        int total = flightLogs.Count;
                        int i     = 0;

                        while (i < total)
                        {
                            int batchSize = Math.Min(total, StarMapService.syncBatchSize);
                            List <StarMapResponseLogEntry> flightLogBatch = flightLogs.Skip(i).Take(batchSize).ToList();
                            syncEdsmLogBatch(flightLogBatch, comments);
                            i += batchSize;
                        }
                    }
                    Logging.Info("EDSM sync completed");
                }
                catch (EDSMException edsme)
                {
                    Logging.Debug("EDSM error received: " + edsme.Message);
                }
                catch (ThreadAbortException e)
                {
                    Logging.Debug("EDSM update stopped by user: " + e.Message);
                }
            }
        }
예제 #2
0
        public static void obtainEdsmLogs(IEdsmService edsmService, IProgress <string> progress)
        {
            if (edsmService != null)
            {
                try
                {
                    DataProviderService            dataProviderService = new DataProviderService(edsmService);
                    List <StarMapResponseLogEntry> flightLogs          = edsmService.getStarMapLog();
                    Dictionary <string, string>    comments            = edsmService.getStarMapComments();
                    int total = flightLogs.Count;
                    int i     = 0;

                    while (i < total)
                    {
                        int batchSize = Math.Min(total, StarMapService.syncBatchSize);
                        List <StarMapResponseLogEntry> flightLogBatch = flightLogs.Skip(i).Take(batchSize).ToList();
                        dataProviderService.syncEdsmLogBatch(flightLogs.Skip(i).Take(batchSize).ToList(), comments);
                        i += batchSize;
                        progress.Report($"{Properties.EDSMResources.log_button_fetching_progress} {i}/{total}");
                    }
                    progress.Report(Properties.EDSMResources.log_button_fetched);
                }
                catch (EDSMException edsme)
                {
                    progress.Report(Properties.EDSMResources.log_button_error_received + edsme.Message);
                }
            }
        }