public static FromFile ( string filename = null ) : |
||
filename | string | |
리턴 |
public void Sync(DateTime?since = null) { Logging.Info("Syncing with EDSM"); try { Dictionary <string, StarMapLogInfo> systems = getStarMapLog(since); Dictionary <string, string> comments = getStarMapComments(); int total = systems.Count; foreach (string system in systems.Keys) { 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); } StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); starMapConfiguration.lastSync = DateTime.UtcNow; starMapConfiguration.ToFile(); Logging.Info("EDSM sync completed"); } catch (EDSMException edsme) { Logging.Debug("EDSM error received: " + edsme.Message); } }
private void SendQueuedEvents(CancellationToken cancellationToken) { var queue = new List <IDictionary <string, object> >(); try { // The `GetConsumingEnumerable` method blocks the thread while the underlying collection is empty // If we haven't extracted events to send to EDSM, this will wait / pause background sync until `queuedEvents` is no longer empty. foreach (var pendingEvent in queuedEvents.GetConsumingEnumerable(cancellationToken)) { queue.Add(pendingEvent); if (queue.Count > 0 && queuedEvents.Count == 0) { break; } } StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); SendEventBatch(queue, starMapConfiguration); } catch (OperationCanceledException) { // Operation was cancelled. Return any events we've extracted back to the primary queue. foreach (var pendingEvent in queue) { queuedEvents.Add(pendingEvent); } } }
public static void saveStarSystems(List <StarSystem> syncSystems) { StarSystemSqLiteRepository.Instance.SaveStarSystems(syncSystems); StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); starMapConfiguration.lastSync = DateTime.UtcNow; starMapConfiguration.ToFile(); }
private void SendQueuedEvents() { StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); var queue = new List <IDictionary <string, object> >(); // The `GetConsumingEnumerable` method blocks the thread while the underlying collection is empty // If we haven't extracted events to send to Inara, this will wait / pause background sync until `queuedAPIEvents` is no longer empty. foreach (var pendingEvent in queuedEvents.GetConsumingEnumerable()) { queue.Add(pendingEvent); if (queue.Count > 0 && queuedEvents.Count == 0) { break; } } SendEventBatch(queue, starMapConfiguration); }
public void SetEdsmCredentials() { StarMapConfiguration starMapCredentials = StarMapConfiguration.FromFile(); if (!string.IsNullOrEmpty(starMapCredentials?.apiKey)) { // Commander name might come from EDSM credentials or from the game and companion app string cmdrName = starMapCredentials.commanderName ?? commanderFrontierApiName; if (!string.IsNullOrEmpty(cmdrName)) { apiKey = starMapCredentials.apiKey?.Trim(); commanderName = cmdrName?.Trim(); } else { Logging.Warn("EDSM Responder not configured: Commander name not set."); } } else { Logging.Warn("EDSM Responder not configured: API key not set."); } }
public StarMapService() { // Set up the star map service StarMapConfiguration starMapCredentials = StarMapConfiguration.FromFile(); if (starMapCredentials != null && starMapCredentials.apiKey != null) { // Commander name might come from star map credentials or the companion app's profile string commanderName = null; if (starMapCredentials.commanderName != null) { commanderName = starMapCredentials.commanderName; } if (commanderName != null) { instance = new StarMapService(starMapCredentials.apiKey, commanderName); Logging.Info("EDDI access to EDSM is enabled"); } } if (instance == null) { Logging.Info("EDDI access to EDSM is disabled"); } }
private void SendEvents(List <IDictionary <string, object> > queue) { StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); SendEventBatch(queue, starMapConfiguration); }