private void Controller_RefreshComplete() { Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh complete"); RefreshButton(true); actioncontroller.ActionRunOnRefresh(); if (EDCommander.Current.SyncToInara && history.GetLast != null) { EliteDangerousCore.Inara.InaraSync.Refresh(LogLine, history.GetLast, EDCommander.Current); } if (DLLManager.Count > 0) { HistoryEntry lastfileh = history.GetLastHistoryEntry(x => x.EntryType == JournalTypeEnum.Fileheader); if (lastfileh != null) { for (int i = lastfileh.EntryNumber - 1; i < history.Count; i++) // play thru last history entries up to last file position for the DLLs, indicating stored { //System.Diagnostics.Debug.WriteLine("{0} : {1} {2}", i, history.EntryOrder[i].EventTimeUTC, history.EntryOrder[i].EventSummary); DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, history[i]), true); } } DLLManager.Refresh(EDCommander.Current.Name, EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, history.GetLast)); } FrontierCAPI.Disconnect(); // Disconnect capi from current user, but don't clear their credential file // available, and not hidden commander, and we have logged in previously if (FrontierCAPI.ClientIDAvailable && EDCommander.Current.Id >= 0 && FrontierCAPI.HasUserBeenLoggedIn(EDCommander.Current.Name)) { System.Threading.Tasks.Task.Run(() => // don't hold up the main thread, do it in a task, as its a HTTP operation { if (FrontierCAPI.LogIn(EDCommander.Current.Name)) // try and get to Active. May cause a new frontier login { LogLine(FrontierCAPI.Active ? "CAPI User Logged in" : "CAPI User requires new log in"); } }); } Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh complete finished"); if (EDCommander.Current.SyncToEdsm) // no sync, no credentials, no action { EDSMClass edsm = new EDSMClass(); if (edsm.ValidCredentials) { EDSMSend(); } } }
// Called on foreground after history has refreshed private void ForegroundHistoryRefreshCompleteonUI(HistoryList hist) { Debug.Assert(System.Windows.Forms.Application.MessageLoop); if (!PendingClose) { Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history worker completed"); if (hist != null) { history.Copy(hist); OnRefreshCommanders?.Invoke(); EdsmLogFetcher.StopCheck(); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays"); OnHistoryChange?.Invoke(history); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh Displays Completed"); } Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " JM On"); journalmonitor.StartMonitor(true); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Call Refresh Complete"); OnRefreshComplete?.Invoke(); // History is completed FrontierCAPI.Disconnect(); // Disconnect capi from current user, but don't clear their credential file // available, and not hidden commander, and we have logged in before if (FrontierCAPI.ClientIDAvailable && EDCommander.Current.Id >= 0 && FrontierCAPI.GetUserState(EDCommander.Current.Name) != CAPI.CompanionAPI.UserState.NeverLoggedIn) { System.Threading.Tasks.Task.Run(() => // don't hold up the main thread, do it in a task, as its a HTTP operation { FrontierCAPI.LogIn(EDCommander.Current.Name); // try and get to Active. May cause a new frontier login if (FrontierCAPI.Active) // if active, indicate { LogLine("CAPI User Logged in"); } else { LogLine("CAPI Require Log in"); } }); } if (history.CommanderId >= 0) { EdsmLogFetcher.Start(EDCommander.Current); } refreshHistoryRequestedFlag = 0; readyForNewRefresh.Set(); // say i'm okay for another refresh System.Diagnostics.Debug.WriteLine("Refresh completed, allow another refresh"); LogLine("History refresh complete.".T(EDTx.EDDiscoveryController_HRC)); ReportRefreshProgress(-1, ""); Trace.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Refresh history complete"); } }