Ejemplo n.º 1
0
        }                                                                       // SPECIAL USE ONLY - DOES NOT COMPUTE ALL THE OTHER STUFF

        #region Entry processing

        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in.  May return null or empty list, or multiple entries.

        public List <HistoryEntry> AddJournalEntryToHistory(JournalEntry je, Action <string> logerror)
        {
            HistoryEntry he = HistoryEntry.FromJournalEntry(je, hlastprocessed);     // we may check edsm for this entry

            he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je, hlastprocessed?.journalEntry, he.Status.TravelState == HistoryEntryStatus.TravelStateType.SRV));

            // IN THIS order, so suits can be added, then weapons, then loadouts
            he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System));
            he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System));
            he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System));

            // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data

            he.UpdateStats(je, statisticsaccumulator, he.StationFaction);
            he.UpdateSystemNote();

            CashLedger.Process(je);
            he.Credits = CashLedger.CashTotal;

            Shipyards.Process(je);
            Outfitting.Process(je);

            Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System);

            he.UpdateShipInformation(ret.Item1);
            he.UpdateShipStoredModules(ret.Item2);

            he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI));

            hlastprocessed = he;

            var reorderlist = ReorderRemove(he);

            foreach (var heh in reorderlist.EmptyIfNull())
            {
                heh.Index = historylist.Count; // store its index
                historylist.Add(heh);          // then add to history
                AddToVisitsScan(logerror);     // add to scan database and complain if can't add. Do this after history add, so it has a list.
            }

            return(reorderlist);
        }
Ejemplo n.º 2
0
        // Called on a New Entry, by EDDiscoveryController:NewEntry, to add an journal entry in.  May return null if don't want it in history

        public HistoryEntry AddJournalEntryToHistory(JournalEntry je, Action <string> logerror)
        {
            HistoryEntry hprev = GetLast;

            HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev);     // we may check edsm for this entry

            he.UpdateMaterialsCommodities(MaterialCommoditiesMicroResources.Process(je));

            if (CheckForRemoval(he, hprev))                                     // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data
            {
                return(null);
            }

            he.UpdateStats(je, statisticsaccumulator, he.StationFaction);
            he.UpdateSystemNote();

            CashLedger.Process(je);
            he.Credits = CashLedger.CashTotal;

            Shipyards.Process(je);
            Outfitting.Process(je);

            Tuple <ShipInformation, ModulesInStore> ret = ShipInformationList.Process(je, he.WhereAmI, he.System);

            he.UpdateShipInformation(ret.Item1);
            he.UpdateShipStoredModules(ret.Item2);

            he.UpdateMissionList(MissionListAccumulator.Process(je, he.System, he.WhereAmI));

            he.UpdateWeapons(WeaponList.Process(je, he.WhereAmI, he.System));          // update the entries in suit entry list
            he.UpdateSuits(SuitList.Process(je, he.WhereAmI, he.System));
            he.UpdateLoadouts(SuitLoadoutList.Process(je, WeaponList, he.WhereAmI, he.System));

            historylist.Add(he);                                         // then add to history

            AddToVisitsScan(this, this.historylist.Count - 1, logerror); // add to scan database and complain if can't add. Do this after history add, so it has a list.

            return(he);
        }
Ejemplo n.º 3
0
        // History load system, read DB for entries and make a history up

        public static HistoryList LoadHistory(Action <string> reportProgress,
                                              int CurrentCommander,
                                              int fullhistoryloaddaylimit, string essentialitems
                                              )
        {
            HistoryList hist = new HistoryList();

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL", true).Item1 + " History Load");

            reportProgress("Reading Database");

            List <JournalEntry> jlist;       // returned in date ascending, oldest first order.

            if (fullhistoryloaddaylimit > 0)
            {
                var list = (essentialitems == nameof(JournalEssentialEvents.JumpScanEssentialEvents)) ? JournalEssentialEvents.JumpScanEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.JumpEssentialEvents)) ? JournalEssentialEvents.JumpEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.NoEssentialEvents)) ? JournalEssentialEvents.NoEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.FullStatsEssentialEvents)) ? JournalEssentialEvents.FullStatsEssentialEvents :
                           JournalEssentialEvents.EssentialEvents;

                jlist = JournalEntry.GetAll(CurrentCommander,
                                            ids: list,
                                            allidsafterutc: DateTime.UtcNow.Subtract(new TimeSpan(fullhistoryloaddaylimit, 0, 0, 0))
                                            );
            }
            else
            {
                jlist = JournalEntry.GetAll(CurrentCommander);
            }

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " Journals read from DB");

            reportProgress("Creating History");

            HistoryEntry hprev = null;

            foreach (JournalEntry je in jlist)
            {
                if (MergeOrDiscardEntries(hprev?.journalEntry, je))        // if we merge, don't store into HE
                {
                    continue;
                }

                // Clean up "UnKnown" systems from EDSM log
                if (je is JournalFSDJump && ((JournalFSDJump)je).StarSystem == "UnKnown")
                {
                    JournalEntry.Delete(je.Id);
                    continue;
                }

                if (je is EliteDangerousCore.JournalEvents.JournalMusic)      // remove music.. not shown.. now UI event. remove it for backwards compatibility
                {
                    //System.Diagnostics.Debug.WriteLine("**** Filter out " + je.EventTypeStr + " on " + je.EventTimeLocal.ToString());
                    continue;
                }

                HistoryEntry he = HistoryEntry.FromJournalEntry(je, hprev);     // create entry

                he.UpdateMaterialsCommodities(hist.MaterialCommoditiesMicroResources.Process(je));

                if (CheckForRemoval(he, hprev))                                 // check here to see if we want to remove the entry.. can move this lower later, but at first point where we have the data
                {
                    continue;
                }

                hist.historylist.Add(he);                                       // now add it to the history

                hprev = he;
            }

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " History List Created");
            reportProgress("Analysing History");

            for (int i = 0; i < hist.historylist.Count; i++)
            {
                HistoryEntry he = hist.historylist[i];
                JournalEntry je = he.journalEntry;

                he.UpdateStats(je, hist.statisticsaccumulator, he.StationFaction);
                he.UpdateSystemNote();

                hist.CashLedger.Process(je);            // update the ledger
                he.Credits = hist.CashLedger.CashTotal;

                hist.Shipyards.Process(je);
                hist.Outfitting.Process(je);

                Tuple <ShipInformation, ModulesInStore> ret = hist.ShipInformationList.Process(je, he.WhereAmI, he.System);  // the ships
                he.UpdateShipInformation(ret.Item1);
                he.UpdateShipStoredModules(ret.Item2);

                he.UpdateMissionList(hist.MissionListAccumulator.Process(je, he.System, he.WhereAmI));

                he.UpdateWeapons(hist.WeaponList.Process(je, he.WhereAmI, he.System));          // update the entries in suit entry list
                he.UpdateSuits(hist.SuitList.Process(je, he.WhereAmI, he.System));
                he.UpdateLoadouts(hist.SuitLoadoutList.Process(je, hist.WeaponList, he.WhereAmI, he.System));

                AddToVisitsScan(hist, i, null);          // add to scan but don't complain if can't add
            }

            //for (int i = hist.Count - 10; i < hist.Count; i++)  System.Diagnostics.Debug.WriteLine("Hist {0} {1} {2}", hist[i].EventTimeUTC, hist[i].Indexno , hist[i].EventSummary);

            // now database has been updated due to initial fill, now fill in stuff which needs the user database

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " Anaylsis End");

            hist.CommanderId = CurrentCommander;

#if LISTSCANS
            {
                using (var fileout = new System.IO.StreamWriter(@"c:\code\scans.csv"))
                {
                    fileout.WriteLine($"System,0,fullname,ownname,customname,bodyname,bodydesignation, bodyid,parentlist");
                    foreach (var sn in hist.StarScan.ScansSortedByName())
                    {
                        foreach (var body in sn.Bodies)
                        {
                            string pl = body.ScanData?.ParentList();

                            fileout.WriteLine($"{sn.System.Name},0, {body.FullName},{body.OwnName},{body.CustomName},{body.ScanData?.BodyName},{body.ScanData?.BodyDesignation},{body.BodyID},{pl}");
                        }
                    }
                }
            }
#endif

            return(hist);
        }
Ejemplo n.º 4
0
        // History load system, read DB for entries and make a history up

        public static HistoryList LoadHistory(Action <string> reportProgress,
                                              int CurrentCommander,
                                              int fullhistoryloaddaylimit, string essentialitems
                                              )
        {
            HistoryList hist = new HistoryList();

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL", true).Item1 + " History Load");

            reportProgress("Reading Database");

            List <JournalEntry> jlist;       // returned in date ascending, oldest first order.

            if (fullhistoryloaddaylimit > 0)
            {
                var list = (essentialitems == nameof(JournalEssentialEvents.JumpScanEssentialEvents)) ? JournalEssentialEvents.JumpScanEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.JumpEssentialEvents)) ? JournalEssentialEvents.JumpEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.NoEssentialEvents)) ? JournalEssentialEvents.NoEssentialEvents :
                           (essentialitems == nameof(JournalEssentialEvents.FullStatsEssentialEvents)) ? JournalEssentialEvents.FullStatsEssentialEvents :
                           JournalEssentialEvents.EssentialEvents;

                jlist = JournalEntry.GetAll(CurrentCommander,
                                            ids: list,
                                            allidsafterutc: DateTime.UtcNow.Subtract(new TimeSpan(fullhistoryloaddaylimit, 0, 0, 0))
                                            );
            }
            else
            {
                jlist = JournalEntry.GetAll(CurrentCommander);
            }

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " Journals read from DB");

            reportProgress("Creating History");

            hist.hlastprocessed = null;

            foreach (JournalEntry je in jlist)
            {
                if (MergeOrDiscardEntries(hist.hlastprocessed?.journalEntry, je))        // if we merge, don't store into HE
                {
                    continue;
                }

                // Clean up "UnKnown" systems from EDSM log
                if (je is JournalFSDJump && ((JournalFSDJump)je).StarSystem == "UnKnown")
                {
                    JournalEntry.Delete(je.Id);
                    continue;
                }

                HistoryEntry he = HistoryEntry.FromJournalEntry(je, hist.hlastprocessed);     // create entry

                he.UpdateMaterialsCommodities(hist.MaterialCommoditiesMicroResources.Process(je, hist.hlastprocessed?.journalEntry, he.Status.TravelState == HistoryEntryStatus.TravelStateType.SRV));

                // IN THIS order, so suits can be added, then weapons, then loadouts
                he.UpdateSuits(hist.SuitList.Process(je, he.WhereAmI, he.System));
                he.UpdateWeapons(hist.WeaponList.Process(je, he.WhereAmI, he.System));          // update the entries in suit entry list
                he.UpdateLoadouts(hist.SuitLoadoutList.Process(je, hist.WeaponList, he.WhereAmI, he.System));

                he.UpdateStats(je, hist.statisticsaccumulator, he.StationFaction);
                he.UpdateSystemNote();

                hist.CashLedger.Process(je);            // update the ledger
                he.Credits = hist.CashLedger.CashTotal;

                hist.Shipyards.Process(je);
                hist.Outfitting.Process(je);

                Tuple <ShipInformation, ModulesInStore> ret = hist.ShipInformationList.Process(je, he.WhereAmI, he.System);  // the ships
                he.UpdateShipInformation(ret.Item1);
                he.UpdateShipStoredModules(ret.Item2);

                he.UpdateMissionList(hist.MissionListAccumulator.Process(je, he.System, he.WhereAmI));

                hist.hlastprocessed = he;

                var reorderlist = hist.ReorderRemove(he);

                foreach (var heh in reorderlist.EmptyIfNull())
                {
                    // System.Diagnostics.Debug.WriteLine("   ++ {0} {1}", heh.EventTimeUTC.ToString(), heh.EntryType);
                    heh.Index = hist.historylist.Count; // store its index for quick ordering, after all removal etc
                    hist.historylist.Add(heh);          // then add to history
                    hist.AddToVisitsScan(null);         // add to scan database but don't complain
                }
            }

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " History List Created");

            foreach (var s in hist.StarScan.ToProcess)
            {
                System.Diagnostics.Debug.WriteLine("StarScan could not find " + s.Item2.SystemAddress + " at " + s.Item1.EventTimeUTC);
            }

            //for (int i = hist.Count - 10; i < hist.Count; i++)  System.Diagnostics.Debug.WriteLine("Hist {0} {1} {2}", hist[i].EventTimeUTC, hist[i].Indexno , hist[i].EventSummary);

            // now database has been updated due to initial fill, now fill in stuff which needs the user database

            Trace.WriteLine(BaseUtils.AppTicks.TickCountLapDelta("HLL").Item1 + " Anaylsis End");

            hist.CommanderId = CurrentCommander;

#if LISTSCANS
            {
                using (var fileout = new System.IO.StreamWriter(@"c:\code\scans.csv"))
                {
                    fileout.WriteLine($"System,0,fullname,ownname,customname,bodyname,bodydesignation, bodyid,parentlist");
                    foreach (var sn in hist.StarScan.ScansSortedByName())
                    {
                        foreach (var body in sn.Bodies)
                        {
                            string pl = body.ScanData?.ParentList();

                            fileout.WriteLine($"{sn.System.Name},0, {body.FullName},{body.OwnName},{body.CustomName},{body.ScanData?.BodyName},{body.ScanData?.BodyDesignation},{body.BodyID},{pl}");
                        }
                    }
                }
            }
#endif

            return(hist);
        }