public void TestSolLog() { StarMapService service = new StarMapService("secret", "McDonald", "http://beta.edsm.net:8080/"); service.sendStarMapLog("Sol"); StarMapInfo info = service.getStarMapInfo("Sol"); Assert.IsTrue(info.Visits >= 1); // can be any number thanks to repeated testing }
public void TestProximaCentauriComment() { StarMapService service = new StarMapService("secret", "McDonald", "http://beta.edsm.net:8080/"); service.sendStarMapLog("Proxima Centauri"); service.sendStarMapComment("Proxima Centauri", "Not so far away"); StarMapInfo info = service.getStarMapInfo("Proxima Centauri"); Assert.AreEqual("Not so far away", info.Comment); }
public void TestProximaDistance() { StarMapService service = new StarMapService("secret", "McDonald", "http://beta.edsm.net:8080/"); service.sendStarMapDistance("Sol", "HIP 11658", 350.35M); }
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); }
/// <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(eddiConfiguration.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 VA_Init1(ref Dictionary<string, object> state, ref Dictionary<string, Int16?> shortIntValues, ref Dictionary<string, string> textValues, ref Dictionary<string, int?> intValues, ref Dictionary<string, decimal?> decimalValues, ref Dictionary<string, Boolean?> booleanValues, ref Dictionary<string, DateTime?> dateTimeValues, ref Dictionary<string, object> extendedValues) { if (!initialised) { lock (initLock) { if (!initialised) { try { logInfo("EDDI " + PLUGIN_VERSION + " starting"); // Set up and/or open our database String dataDir = Environment.GetEnvironmentVariable("AppData") + "\\EDDI"; System.IO.Directory.CreateDirectory(dataDir); // Set up our local star system repository starSystemRepository = new EDDIStarSystemSqLiteRepository(); // Set up the EDDI configuration EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); setString(ref textValues, "Home system", eddiConfiguration.HomeSystem != null && eddiConfiguration.HomeSystem.Trim().Length > 0 ? eddiConfiguration.HomeSystem : null); setString(ref textValues, "Home system (spoken)", eddiConfiguration.HomeSystem != null && eddiConfiguration.HomeSystem.Trim().Length > 0 ? Translations.StarSystem(eddiConfiguration.HomeSystem) : null); setString(ref textValues, "Home station", eddiConfiguration.HomeStation != null && eddiConfiguration.HomeStation.Trim().Length > 0 ? eddiConfiguration.HomeStation : null); setDecimal(ref decimalValues, "Insurance", eddiConfiguration.Insurance); if (eddiConfiguration.HomeSystem != null && eddiConfiguration.HomeSystem.Trim().Length > 0) { EDDIStarSystem HomeStarSystemData = starSystemRepository.GetEDDIStarSystem(eddiConfiguration.HomeSystem.Trim()); if (HomeStarSystemData == null) { // We have no record of this system; set it up HomeStarSystemData = new EDDIStarSystem(); HomeStarSystemData.Name = eddiConfiguration.HomeSystem.Trim(); HomeStarSystemData.StarSystem = DataProviderService.GetSystemData(eddiConfiguration.HomeSystem.Trim()); HomeStarSystemData.LastVisit = DateTime.Now; HomeStarSystemData.StarSystemLastUpdated = HomeStarSystemData.LastVisit; HomeStarSystemData.TotalVisits = 1; starSystemRepository.SaveEDDIStarSystem(HomeStarSystemData); } HomeStarSystem = HomeStarSystemData.StarSystem; } enableDebugging = eddiConfiguration.Debug; setBoolean(ref booleanValues, "EDDI debug", enableDebugging); // Set up the app service appService = new CompanionAppService(enableDebugging); if (appService.CurrentState == CompanionAppService.State.READY) { // Carry out initial population of profile InvokeUpdateProfile(ref state, ref shortIntValues, ref textValues, ref intValues, ref decimalValues, ref booleanValues, ref dateTimeValues, ref extendedValues); } if (Cmdr != null && Cmdr.Name != null) { setString(ref textValues, "EDDI plugin profile status", "Enabled"); logInfo("EDDI access to the companion app is enabled"); } else { // If InvokeUpdatePlugin failed then it will have have left an error message, but this once we ignore it setPluginStatus(ref textValues, "Operational", null, null); setString(ref textValues, "EDDI plugin profile status", "Disabled"); logInfo("EDDI access to the companion app is disabled"); // We create a commander anyway, as data such as starsystem uses it Cmdr = new Commander(); } // 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; } else if (Cmdr.Name != null) { commanderName = Cmdr.Name; } if (commanderName != null) { starMapService = new StarMapService(starMapCredentials.apiKey, commanderName); setString(ref textValues, "EDDI plugin EDSM status", "Enabled"); logInfo("EDDI access to EDSM is enabled"); } } if (starMapService == null) { setString(ref textValues, "EDDI plugin EDSM status", "Disabled"); logInfo("EDDI access to EDSM is disabled"); } setString(ref textValues, "EDDI version", PLUGIN_VERSION); speechService = new SpeechService(SpeechServiceConfiguration.FromFile()); InvokeNewSystem(ref state, ref shortIntValues, ref textValues, ref intValues, ref decimalValues, ref booleanValues, ref dateTimeValues, ref extendedValues); CurrentEnvironment = ENVIRONMENT_NORMAL_SPACE; setString(ref textValues, "Environment", CurrentEnvironment); // Set up log monitor NetLogConfiguration netLogConfiguration = NetLogConfiguration.FromFile(); if (netLogConfiguration != null && netLogConfiguration.path != null) { logWatcherThread = new Thread(() => StartLogMonitor(netLogConfiguration)); logWatcherThread.IsBackground = true; logWatcherThread.Name = "EDDI netlog watcher"; logWatcherThread.Start(); setString(ref textValues, "EDDI plugin NetLog status", "Enabled"); logInfo("EDDI netlog monitor is enabled for " + netLogConfiguration.path); } else { setString(ref textValues, "EDDI plugin NetLog status", "Disabled"); logInfo("EDDI netlog monitor is disabled"); } setPluginStatus(ref textValues, "Operational", null, null); initialised = true; } catch (Exception ex) { setPluginStatus(ref textValues, "Failed", "Failed to initialise", ex); } } } } }