コード例 #1
0
        static public void ReCalcForecastItems()
        {
            forecastItems.Clear();

            foreach (ProductMasterItem productMasterItem in _productMasterList)
            {
                ForecastItem newForecastItem = new ForecastItem();
                newForecastItem.ProductCode        = productMasterItem.ProductionCode;
                newForecastItem.ProductDescription = productMasterItem.Description;

                double inventory =
                    InventoryItems.Where(x => x.ProductCode == productMasterItem.ProductionCode).Sum(x => x.Units);

                for (Int32 i = 0; i < newForecastItem.UnitsPerMonth.Length; i++)
                {
                    SalesItem[] foundItems = SalesItems.Where(x => x.MasterID == productMasterItem.MasterID &&
                                                              x.Date.Month == DateTime.Now.AddMonths(-(i + 1)).Month&& x.Date.AddYears(1).AddMonths(1) >= DateTime.Now).ToArray();

                    newForecastItem.UnitsPerMonth[i] = foundItems.Sum(x => (x.Units / productMasterItem.PiecesPerUnit));
                }

                newForecastItem.Units = inventory;

                forecastItems.Add(newForecastItem);
            }
        }
コード例 #2
0
        public override void GetData()
        {
            base.GetData();
            KitDefinitions       = DesktopApplication.Librarian.GetItems(typeof(KitDefinition), new List <RetrievalCriteria>());
            Radiopharmaceuticals = DesktopApplication.Librarian.GetItems(typeof(Chemical), new List <RetrievalCriteria>());

            RetrievalCriteria        rcMin  = new RetrievalCriteria("DateAdded", CriteraType.GreaterThan, BulkDoseDateMinimum);
            List <RetrievalCriteria> rcList = new List <RetrievalCriteria>();

            rcList.Add(rcMin);
            InventoryItems = DesktopApplication.Librarian.GetItems(typeof(BaseBulkDose), rcList);



            foreach (IDataStoreItem d in InventoryItems)
            {
                (d as BaseBulkDose).UnitDoseDrawn += InventoryItemAdded;
                if (d is Elution && (d as Elution).CalibrationDate.Date == DateTime.Today)
                {
                    //&& (d as Elution).CalibrationDate.Date == DateTime.Today
                    NumberOfElutionsToday++;
                    ActivityOfElutionsToday = ActivityOfElutionsToday + ((d as Elution).CurrentActivity);
                    if ((d as IInventory).Expired)
                    {
                        DisposableItems++;
                        DisposableActivity += (d as BaseRadioactiveInventoryItem).CurrentActivity;
                    }
                }
                else if (d is ReconstitutedColdKit)
                {
                    NumberOfColdKitsToday++;
                    ActivityOfColdKitsToday += (d as ReconstitutedColdKit).CurrentActivity;
                    if ((d as IInventory).Expired)
                    {
                        DisposableItems++;
                        DisposableActivity += (d as BaseRadioactiveInventoryItem).CurrentActivity;
                    }
                }
            }

            rcMin = new RetrievalCriteria("DateAdded", CriteraType.GreaterThan, UnitDoseDateMinimum);
            rcList.Clear();
            rcList.Add(rcMin);
            foreach (IDataStoreItem d in DesktopApplication.Librarian.GetItems(typeof(BaseUnitDose), rcList))
            {
                InventoryItems.Add(d);
                NumberOfUnitDosesToday++;
                ActivityOfUnitDosesToday += (d as BaseUnitDose).CurrentActivity;
                if ((d as IInventory).Expired)
                {
                    DisposableItems++;
                    DisposableActivity += (d as BaseRadioactiveInventoryItem).CurrentActivity;
                }
            }
            rcMin = new RetrievalCriteria("DateAdded", CriteraType.GreaterThan, GeneratorDateMinimum);
            rcList.Clear();
            rcList.Add(rcMin);
            foreach (IDataStoreItem d in DesktopApplication.Librarian.GetItems(typeof(Generator), rcList))
            {
                InventoryItems.Add(d);
                (d as Generator).GeneratorEluted += InventoryItemAdded;
            }

            rcMin = new RetrievalCriteria("DateAdded", CriteraType.GreaterThan, ColdKitDateMinimum);
            rcList.Clear();
            rcList.Add(rcMin);
            foreach (IDataStoreItem d in DesktopApplication.Librarian.GetItems(typeof(Kit), rcList))
            {
                InventoryItems.Add(d);
                (d as Kit).ColdKitReconstituted += InventoryItemAdded;
            }

            foreach (IDataStoreItem d in InventoryItems)
            {
                (d as IInventory).ItemDisposed   += RadiopharmacyModule_ItemDeleted;
                (d as IInventory).ItemUnDisposed += RadiopharmacyModule_ItemUnDisposed;
            }


            var isotopes = Platform.Retriever.RetrieveItems(typeof(Isotope), new List <RetrievalCriteria>());

            System.Diagnostics.Debug.WriteLine("Isotopes.count = " + isotopes.Count);
            foreach (var i in isotopes)
            {
                IsotopeLevel lvl = new IsotopeLevel();
                lvl.Isotope         = (Isotope)i;
                lvl.CurrentActivity = InventoryItems.Where(x => x is BaseRadioactiveInventoryItem).Where(y => (y as BaseRadioactiveInventoryItem).Disposed == DisposalStatus.NotDisposed && (y as BaseRadioactiveInventoryItem).Isotope == i).Sum(z => (z as BaseRadioactiveInventoryItem).CurrentActivity);
                if (lvl.CurrentActivity > 0)
                {
                    IsotopeLevels.Add(lvl);
                }
            }
            try
            {
                var a = Platform.Retriever.RetrieveItems(typeof(BaseUnitDose)).Where(x => (x as BaseUnitDose).Disposed == DisposalStatus.NotDisposed && (x as BaseUnitDose).Expired == true);
                var b = Platform.Retriever.RetrieveItems(typeof(BaseBulkDose)).Where(x => (x as BaseBulkDose).Disposed == DisposalStatus.NotDisposed && (x as BaseBulkDose).Expired == true);
                var c = Platform.Retriever.RetrieveItems(typeof(Generator)).Where(x => (x as BaseBulkDose).Disposed == DisposalStatus.NotDisposed && (x as BaseBulkDose).Expired == true);

                NumberOfExpiredItems  = a.Count();
                NumberOfExpiredItems += b.Count();
                NumberOfExpiredItems += c.Count();

                ActivityOfExpiredItems  = a.Select(x => (x as BaseRadioactiveInventoryItem).CurrentActivity).Sum();
                ActivityOfExpiredItems += b.Select(x => (x as BaseRadioactiveInventoryItem).CurrentActivity).Sum();
                ActivityOfExpiredItems += c.Select(x => (x as BaseRadioactiveInventoryItem).CurrentActivity).Sum();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception:  " + ex.Message);
            }
        }