Example #1
0
        public uint Process(JournalEntry je, JournalEntry lastentry, bool insrv)
        {
            if (je is ICommodityJournalEntry || je is IMaterialJournalEntry || je is IMicroResourceJournalEntry)
            {
                items.NextGeneration();     // increment number, its cheap operation even if nothing gets changed

                //System.Diagnostics.Debug.WriteLine("***********************" + je.EventTimeUTC + " GENERATION " + items.Generation);

                if (je is ICommodityJournalEntry)
                {
                    ICommodityJournalEntry e = je as ICommodityJournalEntry;
                    e.UpdateCommodities(this, insrv);
                }

                if (je is IMaterialJournalEntry)
                {
                    IMaterialJournalEntry e = je as IMaterialJournalEntry;
                    e.UpdateMaterials(this);
                }

                if (je is IMicroResourceJournalEntry)
                {
                    IMicroResourceJournalEntry e = je as IMicroResourceJournalEntry;
                    e.UpdateMicroResource(this, lastentry);
                }

                if (items.UpdatesAtThisGeneration == 0)         // if nothing changed, abandon it.
                {
                    // System.Diagnostics.Debug.WriteLine("*********************** {0} {1} No changes for Generation {2} Abandon", je.EventTimeUTC.ToString(), je.EventTypeStr, items.Generation);
                    items.AbandonGeneration();
                }
                else
                {
                    //   System.Diagnostics.Debug.WriteLine("*********************** {0} {1} Generation {2} Changes {3}",je.EventTimeUTC.ToString(), je.EventTypeStr, items.Generation,items.UpdatesAtThisGeneration);
                }
            }

            return(items.Generation);        // return the generation we are on.
        }
Example #2
0
        static public MaterialCommoditiesList Process(JournalEntry je, MaterialCommoditiesList oldml)
        {
            MaterialCommoditiesList newmc = (oldml == null) ? new MaterialCommoditiesList() : oldml;

            if (je is ICommodityJournalEntry || je is IMaterialJournalEntry) // could be both
            {
                newmc = newmc.Clone();                                       // so we need a new one, makes a new list, but copies the items..

                if (je is ICommodityJournalEntry)
                {
                    ICommodityJournalEntry e = je as ICommodityJournalEntry;
                    e.UpdateCommodities(newmc);
                }

                if (je is IMaterialJournalEntry)
                {
                    IMaterialJournalEntry e = je as IMaterialJournalEntry;
                    e.UpdateMaterials(newmc);
                }
            }

            return(newmc);
        }