diff --git a/Observatory/CodexReader.cs b/Observatory/IGAUReader.cs similarity index 70% rename from Observatory/CodexReader.cs rename to Observatory/IGAUReader.cs index 81f7c66..9f82b9a 100644 --- a/Observatory/CodexReader.cs +++ b/Observatory/IGAUReader.cs @@ -8,8 +8,7 @@ namespace Observatory { - static class CodexReader - + static class IGAUReader { public static void ProcessCodex(CodexEntry codexEntry) { @@ -45,6 +44,39 @@ public static void ProcessCodex(CodexEntry codexEntry) } } + public static void ProcessOrganic(ScanOrganicEvent scanOrganicEvent) + { + if (Properties.Observatory.Default.SendToIGAU) + { + JObject POST_content = JObject.FromObject( + new + { + timestamp = scanOrganicEvent.Timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ"), + EntryID = "-", + Name = scanOrganicEvent.Species + .Replace("$", string.Empty) + .Replace(";", string.Empty) + .Replace("_Name", string.Empty) + .ToLower(), + Name_Localised = scanOrganicEvent.Species_Localised, + System = scanOrganicEvent.CurrentSystem, + SystemAddress = scanOrganicEvent.SystemAddress.ToString(), + App_Name = "Elite_Observatory", + App_Version = Application.ProductVersion + }); + + var request = new HttpRequestMessage + { + Method = HttpMethod.Post, + RequestUri = new Uri($"https://ddss70885k.execute-api.us-west-1.amazonaws.com/Prod"), + Content = new StringContent(POST_content.ToString(Formatting.None)) + }; + + QueueRequest(request); + + } + } + private static List RequestQueue; private static bool RequestsSending; diff --git a/Observatory/LogMonitor.cs b/Observatory/LogMonitor.cs index 2b90641..14c5a27 100644 --- a/Observatory/LogMonitor.cs +++ b/Observatory/LogMonitor.cs @@ -22,10 +22,12 @@ class LogMonitor private string LogDirectory; public bool LastScanValid { get; private set; } public bool LastCodexValid { get; private set; } + public bool LastOrganicValid { get; private set; } public bool ReadAllInProgress { get; private set; } public bool ReadAllComplete { get; private set; } public ScanEvent LastScan { get; private set; } public CodexEntry LastCodex { get; private set; } + public ScanOrganicEvent LastOrganic { get; private set; } public Dictionary<(string System, long Body), ScanEvent> SystemBody { get; private set; } public UserInterest UserInterest { get; private set; } private JournalPoker Poker; @@ -115,6 +117,7 @@ public void ReadAll(ProgressBar progressBar) CurrentLogLine.Contains("\"event\":\"Location\"") || CurrentLogLine.Contains("\"event\":\"FSDJump\"") || CurrentLogLine.Contains("\"event\":\"CodexEntry\"") || + CurrentLogLine.Contains("\"event\":\"ScanOrganic\"") || CurrentLogLine.Contains("\"event\":\"SupercruiseExit\"")) { ProcessLine(CurrentLogLine); @@ -212,6 +215,7 @@ private void LogChanged(object source, FileSystemEventArgs e) checkLine.Contains("\"event\":\"Location\"") || checkLine.Contains("\"event\":\"FSDJump\"") || checkLine.Contains("\"event\":\"CodexEntry\"") || + checkLine.Contains("\"evnet\":\"ScanOrganic\"") || checkLine.Contains("\"event\":\"SupercruiseExit\"")) { CurrentLogLine = checkLine; @@ -250,6 +254,7 @@ private void ProcessLine(string logLine) } LastScanValid = false; LastCodexValid = false; + LastOrganicValid = false; //Journals prior to Elite Dangerous 2.3 "The Commanders" had differently formatted scan events which I can't be bothered to support. if (DateTime.TryParseExact(lastEvent["timestamp"].ToString(), "yyyy-MM-ddTHH:mm:ssZ", null, System.Globalization.DateTimeStyles.RoundtripKind, out DateTime eventTime)) { @@ -289,6 +294,14 @@ private void ProcessLine(string logLine) LastCodexValid = true; } break; + case "ScanOrganic": + if (LastOrganic?.Timestamp != lastEvent.ToObject().Timestamp) + { + LastOrganic = lastEvent.ToObject(); + LastOrganic.CurrentSystem = currentSystem; + LastOrganicValid = true; + } + break; case "SupercruiseExit": if (lastEvent["Body"]?.ToString().Length > 0) currentBody = lastEvent["Body"].ToString(); diff --git a/Observatory/Observatory.csproj b/Observatory/Observatory.csproj index 9770999..3eddeed 100644 --- a/Observatory/Observatory.csproj +++ b/Observatory/Observatory.csproj @@ -80,7 +80,7 @@ - + @@ -122,6 +122,7 @@ + Form diff --git a/Observatory/ObservatoryFrm.cs b/Observatory/ObservatoryFrm.cs index 83d5b8c..0d9eeb3 100644 --- a/Observatory/ObservatoryFrm.cs +++ b/Observatory/ObservatoryFrm.cs @@ -160,7 +160,7 @@ private void LogEvent(object source, EventArgs e) } else if (logMonitor.LastCodexValid) { - CodexReader.ProcessCodex(logMonitor.LastCodex); + IGAUReader.ProcessCodex(logMonitor.LastCodex); if (Properties.Observatory.Default.IncludeCodex) { @@ -180,6 +180,10 @@ private void LogEvent(object source, EventArgs e) }); } } + else if (logMonitor.LastOrganicValid) + { + IGAUReader.ProcessOrganic(logMonitor.LastOrganic); + } } private void RemoveUninteresting() diff --git a/Observatory/ScanOrganicEvent.cs b/Observatory/ScanOrganicEvent.cs new file mode 100644 index 0000000..f6f711a --- /dev/null +++ b/Observatory/ScanOrganicEvent.cs @@ -0,0 +1,37 @@ +using System; +using Newtonsoft.Json; + +namespace Observatory +{ + public class ScanOrganicEvent + { + [JsonProperty("timestamp")] + public DateTime Timestamp { get; set; } + + [JsonProperty("event")] + public string Event { get; set; } + + [JsonProperty("ScanType")] + public string ScanType { get; set; } + + [JsonProperty("Genus")] + public string Genus { get; set; } + + [JsonProperty("Genus_Localised")] + public string Genus_Localised { get; set; } + + [JsonProperty("Species")] + public string Species { get; set; } + + [JsonProperty("Species_Localised")] + public string Species_Localised { get; set; } + + [JsonProperty("SystemAddress")] + public ulong SystemAddress { get; set; } + + [JsonProperty("Body")] + public int Body { get; set; } + + public string CurrentSystem; + } +}