// Called by controller before any HL removal reorder. The raw HE stream. The MCMR etc databases have been updated public void Controller_NewHistoryEntryUnfiltered(HistoryEntry he) { //he.FillInformation(out string ed, out string edi);System.Diagnostics.Debug.WriteLine($"HE Unfiltered {he.EntryType} {he.EventSummary} {ed}"); System.Diagnostics.Debug.WriteLine($"HE Unfiltered {he.EntryType}"); // EDSM needs the raw stream, so send it here.. if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } // as does Inara. Note the MCMR has been updated. Needed here due to using materials/cargo if (EDCommander.Current.SyncToInara) { var mcmr = history.MaterialCommoditiesMicroResources.GetDict(he.MaterialCommodity); EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he, mcmr); } if (DLLManager.Count > 0) { DLLManager.NewUnfilteredJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he)); // give DLL the unfiltered stream } }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); var lastent = history.GetLast; if (!object.ReferenceEquals(he, lastent)) { LogLineHighlight(string.Format("Current history entry is not last in history - possible re-entrancy.\nAlert the EDDiscovery developers using either discord or Github (see help) and attach log file {0}", BaseUtils.TraceLog.LogFileName)); Trace.WriteLine($"Current history entry is not last in history"); Trace.WriteLine($"Current entry: {he.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Last entry: {lastent.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Stack Trace:"); Trace.WriteLine(new StackTrace(true).ToString()); } if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) // send this one, if allowed. { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } if (EDCommander.Current.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, hl, he); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToEDAstro) { EliteDangerousCore.EDAstro.EDAstroSync.SendEDAstroEvents(new List <HistoryEntry>() { he }); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, he); } DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); screenshotconverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); }
public void EDSMSend() { var helist = EDSMJournalSync.GetListToSend(history.EntryOrder()); // find out what to send.. if (helist.Count >= 500) { ExtendedControls.ConfigurableForm cf = new ExtendedControls.ConfigurableForm(); int width = 400; DateTime lasthe = helist.Last().EventTimeUTC; cf.Add(new ExtendedControls.ConfigurableForm.Entry("UC", typeof(Label), string.Format("There are {0} EDSM reports to send, this will take time and bandwidth, choose from the following what to do. Entries before this will be marked as sent.".T(EDTx.EDDiscoveryForm_SendEDSMCaption), helist.Count), new Point(5, 30), new Size(width - 5 - 20, 100), null) { textboxmultiline = true }); cf.Add(new ExtendedControls.ConfigurableForm.Entry("All", typeof(ExtendedControls.ExtButton), "Send All to EDSM".T(EDTx.EDDiscoveryForm_SendEDSMAll), new Point(5, 130), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Today", typeof(ExtendedControls.ExtButton), "Send Last 24 Hours of entries to EDSM".T(EDTx.EDDiscoveryForm_SendEDSM24), new Point(5, 180), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Custom", typeof(ExtendedControls.ExtButton), "Send From".T(EDTx.EDDiscoveryForm_SendEDSMFrom), new Point(5, 230), new Size(80, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Date", typeof(ExtendedControls.ExtDateTimePicker), lasthe.AddDays(-28).ToStringZulu(), new Point(100, 230), new Size(width - 100 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("None", typeof(ExtendedControls.ExtButton), "EDSM is up to date - send Nothing more".T(EDTx.EDDiscoveryForm_SendEDSMNone), new Point(5, 280), new Size(width - 5 - 20, 24), null)); cf.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "I'll decide later, do nothing".T(EDTx.EDDiscoveryForm_SendEDSMCancel), new Point(5, 330), new Size(width - 5 - 20, 24), null)); DateTime date = DateTime.UtcNow; cf.Trigger += (dialogname, controlname, tag) => { if (controlname.Contains("All")) { date = new DateTime(1900, 1, 1); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Today")) { date = lasthe.AddDays(-1); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Custom")) { date = cf.GetDateTime("Date").Value.ToUniversalTime(); cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("None")) { cf.ReturnResult(DialogResult.OK); } else if (controlname.Contains("Cancel")) { cf.ReturnResult(DialogResult.Cancel); } }; if (cf.ShowDialogCentred(this.FindForm(), this.FindForm().Icon, "Sending a large number of EDSM Entries".T(EDTx.EDDiscoveryForm_SendEDSMTitle)) == DialogResult.Cancel) { return; } var jes = helist.Where(x => x.EventTimeUTC < date).Select(x => x.journalEntry).ToList(); JournalEntry.SetEdsmSyncList(jes); helist = EDSMJournalSync.GetListToSend(history.EntryOrder()); // find out what to send.. } if (helist.Count > 0) { EDSMJournalSync.SendEDSMEvents(l => LogLine(l), helist); } }
HistoryEntry lastuihe = null; // last he that the ui was updated on.. used during store to try and prevent too much thrash public void HistoryEvent(HistoryEntry he, bool stored, bool recent) // recent is true on stored for last few entries.. { bool dontupdateui = (lasthe != null && stored && !recent); if (!dontupdateui) // so, if we have displayed one, and we are in stored reply, and not a recent entry.. don't update UI { bool reposbut = false; if (lastuihe == null || !he.Commander.Name.Equals(lastuihe.Commander.Name)) { labelCmdr.Text = he.Commander.Name; if (EDCommander.Current.Name != he.Commander.Name) { labelCmdr.Text += " Report clash " + EDCommander.Current.Name; } } if (lastuihe == null || he.Credits != lastuihe.Credits) { labelCredits.Text = he.Credits.ToString("N0"); } if (!labelSystem.Text.Equals(he.System.Name)) // because of StartJump rewriting the previous entry, we can't detect system names changes using UI { // which ends up we never seeing lastui.system.name being different to he.system.name extButtonEDSMSystem.Enabled = extButtonInaraSystem.Enabled = extButtonEDDBSystem.Enabled = true; labelSystem.Text = he.System.Name; reposbut = true; } if (lastuihe == null || !he.WhereAmI.Equals(lastuihe.WhereAmI)) { labelLocation.Text = he.WhereAmI; reposbut = true; } bool hasmarketid = he?.MarketID.HasValue ?? false; bool hasbodyormarketid = hasmarketid || he.FullBodyID.HasValue; if (lastuihe == null || extButtonInaraStation.Enabled != hasmarketid) { extButtonInaraStation.Enabled = extButtonEDDBStation.Enabled = hasmarketid; } if (lastuihe == null || extButtonSpanshStation.Enabled != hasbodyormarketid) { extButtonSpanshStation.Enabled = hasbodyormarketid; } if ((he.ShipInformation != null) != extButtonEDSY.Enabled) // enabled/visible causes effort, only do it if different { extButtonEDSY.Enabled = extButtonCoriolis.Enabled = he.ShipInformation != null; } if (he.ShipInformation != null && (lastuihe == null || lastuihe.ShipInformation == null || he.ShipInformation.ShipNameIdentType != lastuihe.ShipInformation.ShipNameIdentType)) { labelShip.Text = he.ShipInformation.ShipNameIdentType ?? "Unknown"; reposbut = true; } if (reposbut) { int maxx = Math.Max(labelSystem.Right, labelLocation.Right) + 2; extButtonEDSMSystem.Left = maxx; extButtonInaraSystem.Left = extButtonEDSMSystem.Right + 2; extButtonEDDBSystem.Left = extButtonInaraSystem.Right + 2; extButtonSpanshSystem.Left = extButtonEDDBSystem.Right + 2; extButtonInaraStation.Left = maxx; extButtonEDDBStation.Left = extButtonInaraStation.Right + 2; extButtonSpanshStation.Left = extButtonEDDBStation.Right + 2; extButtonCoriolis.Left = labelShip.Right + 2; extButtonEDSY.Left = extButtonCoriolis.Right + 2; } if (lastuihe == null || he.MaterialCommodity.DataCount != lastuihe.MaterialCommodity.DataCount || he.MaterialCommodity.CargoCount != lastuihe.MaterialCommodity.CargoCount || he.MaterialCommodity.MaterialsCount != lastuihe.MaterialCommodity.MaterialsCount) { labelData.Text = he.MaterialCommodity.DataCount.ToString(); labelCargo.Text = he.MaterialCommodity.CargoCount.ToString(); labelMaterials.Text = he.MaterialCommodity.MaterialsCount.ToString(); } he.journalEntry.FillInformation(out string info, out string detailed); LogLine(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(he.EventTimeUTC) + " " + he.journalEntry.SummaryName(he.System) + ": " + info); if (he.MissionList != null) { labelMissionCount.Text = he.MissionList.Missions.Count.ToString(); string mtext = ""; if (he.MissionList.Missions.Count > 0) { var list = he.MissionList.GetAllCurrentMissions(DateTime.Now); if (list.Count > 0) { var last = list[0]; mtext = BaseUtils.FieldBuilder.Build("", last.Mission.LocalisedName, "", last.Mission.Expiry, "", last.Mission.DestinationSystem, "", last.Mission.DestinationStation); } } labelLatestMission.Text = mtext; } lastuihe = he; System.Diagnostics.Debug.WriteLine("Set lastuihe to " + lastuihe.System.Name); } if (!stored) { if (he.Commander.SyncToEdsm) { EDSMJournalSync.SendEDSMEvents(LogLine, he); } if (he.Commander.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EliteDangerousCore.EDDN.EDDNClass.IsEDDNMessage(he.EntryType, he.EventTimeUTC) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && he.Commander.SyncToEddn == true) { EliteDangerousCore.EDDN.EDDNSync.SendEDDNEvents(LogLine, he); } if (he.Commander.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } screenshot.NewJournalEntry(he.journalEntry); } if (DLLManager.Count > 0) // if worth calling.. { DLLManager.NewJournalEntry(EDDDLLCallerHE.CreateFromHistoryEntry(he, stored), stored); } lasthe = he; }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); var lastent = history.GetLast; if (!object.ReferenceEquals(he, lastent)) { LogLineHighlight(string.Format("Current history entry is not last in history - possible re-entrancy.\nAlert the EDDiscovery developers using either discord or Github (see help) and attach log file {0}", BaseUtils.TraceLog.LogFileName)); Trace.WriteLine($"Current history entry is not last in history"); Trace.WriteLine($"Current entry: {he.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Last entry: {lastent.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Stack Trace:"); Trace.WriteLine(new StackTrace(true).ToString()); } if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) // send this one, if allowed. { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } if (EDCommander.Current.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, he); } DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); screenshotconverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); // finally, CAPI, if docked, try and get commodity data, and if so, create a new EDD record // placed here because it causes a new set of newentries to be called if (he.EntryType == JournalTypeEnum.Docked && FrontierCAPI.Active) { System.Threading.Tasks.Task.Run(() => // don't hold up the main thread, do it in a task, as its a HTTP operation { var dockevt = he.journalEntry as EliteDangerousCore.JournalEvents.JournalDocked; string marketjson = FrontierCAPI.Market(); CAPI.Market mk = new CAPI.Market(marketjson); if (mk.IsValid) { System.IO.File.WriteAllText(@"c:\code\market.json", marketjson); if (dockevt.StationName.Equals(mk.Name, StringComparison.InvariantCultureIgnoreCase)) { System.Diagnostics.Debug.WriteLine($"CAPI got market {mk.Name}"); var entry = new EliteDangerousCore.JournalEvents.JournalEDDCommodityPrices(he.EventTimeUTC.AddSeconds(1), mk.ID, mk.Name, he.System.Name, EDCommander.CurrentCmdrID, mk.Commodities); var jo = entry.ToJSON(); // get json of it, and add it to the db entry.Add(jo); BeginInvoke((System.Windows.Forms.MethodInvoker) delegate { Debug.Assert(System.Windows.Forms.Application.MessageLoop); System.Diagnostics.Debug.WriteLine("CAPI fire new entry"); NewEntry(entry); // then push it thru. this will cause another set of calls to NewEntry First/Second // EDDN handler will pick up EDDCommodityPrices and send it. }); } else { System.Diagnostics.Trace.WriteLine($"CAPI disagree on market {dockevt.StationName} vs {mk.Name}"); } } else { System.Diagnostics.Trace.WriteLine($"CAPI market invalid {marketjson}"); } }); } }
public void HistoryEvent(HistoryEntry he, bool stored) { if (lasthe == null || he.Commander.Name != lasthe.Commander.Name) { labelCmdr.Text = he.Commander.Name; if (EDCommander.Current.Name != he.Commander.Name) { labelCmdr.Text += " Report clash " + EDCommander.Current.Name; } } if (lasthe == null || he.System.Name != lasthe.System.Name) { extButtonEDSM.Enabled = true; extButtonInaraSystem.Enabled = true; labelSystem.Text = he.System.Name; } if (lasthe == null || he.WhereAmI != lasthe.WhereAmI) { labelLocation.Text = he.WhereAmI; } extButtonEDSY.Enabled = extButtonCoriolis.Enabled = he.ShipInformation != null; if (he.ShipInformation != null && (lasthe == null || lasthe.ShipInformation == null || he.ShipInformation.ShipNameIdentType != lasthe.ShipInformation.ShipNameIdentType)) { labelShip.Text = he.ShipInformation.ShipNameIdentType ?? "Unknown"; } if (lasthe == null || he.MaterialCommodity.DataCount != lasthe.MaterialCommodity.DataCount || he.MaterialCommodity.CargoCount != lasthe.MaterialCommodity.CargoCount || he.MaterialCommodity.MaterialsCount != lasthe.MaterialCommodity.MaterialsCount) { labelData.Text = he.MaterialCommodity.DataCount.ToString(); labelCargo.Text = he.MaterialCommodity.CargoCount.ToString(); labelMaterials.Text = he.MaterialCommodity.MaterialsCount.ToString(); } if (lasthe == null || he.Credits != lasthe.Credits) { labelCredits.Text = he.Credits.ToString("N0"); } he.journalEntry.FillInformation(out string info, out string detailed); LogLine(he.EventTimeUTC + " " + he.journalEntry.EventTypeStr + " " + info); extButtonInaraStation.Enabled = he.IsDocked; if (he.MissionList != null) { labelMissionCount.Text = he.MissionList.Missions.Count.ToString(); string mtext = ""; if (he.MissionList.Missions.Count > 0) { var list = he.MissionList.GetAllCurrentMissions(DateTime.Now); if (list.Count > 0) { var last = list[0]; mtext = BaseUtils.FieldBuilder.Build("", last.Mission.LocalisedName, "", last.Mission.Expiry, "", last.Mission.DestinationSystem, "", last.Mission.DestinationStation); } } labelLatestMission.Text = mtext; } lasthe = he; if (!stored) { if (he.Commander.SyncToEdsm) { EDSMJournalSync.SendEDSMEvents(LogLine, he); } if (he.Commander.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EliteDangerousCore.EDDN.EDDNClass.IsEDDNMessage(he.EntryType, he.EventTimeUTC) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && he.Commander.SyncToEddn == true) { EliteDangerousCore.EDDN.EDDNSync.SendEDDNEvents(LogLine, he); } if (he.Commander.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } if (DLLManager.Count > 0) // if worth calling.. { DLLManager.NewJournalEntry(EDDDLLCallerHE.CreateFromHistoryEntry(he)); } screenshot.NewJournalEntry(he.journalEntry); } }