Exemplo n.º 1
0
        public virtual void PMEnsureInitialized()
        {
            if (_historyLoaded == null)
            {
                _reportPeriods = new RMReportPeriods <PMHistory>(this.Base);

                var accountGroupSelect = new PXSelect <PMAccountGroup>(this.Base);
                accountGroupSelect.View.Clear();
                accountGroupSelect.Cache.Clear();

                var projectSelect = new PXSelect <PMProject, Where <PMProject.isTemplate, Equal <False>, And <PMProject.nonProject, Equal <False>, And <PMProject.baseType, Equal <PMProject.ProjectBaseType> > > > >(this.Base);
                projectSelect.View.Clear();
                projectSelect.Cache.Clear();

                var taskSelect = new PXSelectJoin <PMTask, InnerJoin <PMProject, On <PMTask.projectID, Equal <PMProject.contractID> > >, Where <PMProject.isTemplate, Equal <False>, And <PMProject.nonProject, Equal <False> > > >(this.Base);
                taskSelect.View.Clear();
                taskSelect.Cache.Clear();

                var itemSelect = new PXSelectJoinGroupBy <InventoryItem, InnerJoin <PMHistory, On <InventoryItem.inventoryID, Equal <PMHistory.inventoryID> > >, Aggregate <GroupBy <InventoryItem.inventoryID> > >(this.Base);
                itemSelect.View.Clear();
                itemSelect.Cache.Clear();

                if (Base.Report.Current.ApplyRestrictionGroups == true)
                {
                    projectSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                    taskSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                    itemSelect.WhereAnd <Where <Match <Current <AccessInfo.userName> > > >();
                }

                accountGroupSelect.Select();
                projectSelect.Select();
                taskSelect.Select();

                foreach (InventoryItem item in itemSelect.Select())
                {
                    //The PXSelectJoinGroupBy is read-only, and Inventory items won't be added to the cache. Add them manually.
                    itemSelect.Cache.SetStatus(item, PXEntryStatus.Notchanged);
                }

                _historySegments       = new HashSet <PMHistoryKeyTuple>();
                _pmhistoryPeriodsByKey = new Dictionary <PMHistoryKeyTuple, Dictionary <string, PMHistory> >();
                _historyLoaded         = new HashSet <int>();

                _accountGroupsRangeCache = new RMReportRange <PMAccountGroup>(Base, PM.AccountGroupAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);
                _projectsRangeCache      = new RMReportRange <PMProject>(Base, PM.ProjectAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);
                _tasksRangeCache         = new RMReportRange <PMTask>(Base, PM.ProjectTaskAttribute.DimensionName, RMReportConstants.WildcardMode.Normal, RMReportConstants.BetweenMode.Fixed);
                _itemRangeCache          = new RMReportRange <InventoryItem>(Base, IN.InventoryAttribute.DimensionName, RMReportConstants.WildcardMode.Fixed, RMReportConstants.BetweenMode.Fixed);

                //Add Inventory <OTHER> with InventoryID=0
                InventoryItem other = new InventoryItem
                {
                    InventoryCD = RMReportWildcard.EnsureWildcardForFixed(Messages.OtherItem, _itemRangeCache.Wildcard),
                    InventoryID = PMInventorySelectorAttribute.EmptyInventoryID,
                    Descr       = Messages.OtherItemDescription
                };
                itemSelect.Cache.SetStatus(other, PXEntryStatus.Notchanged);
            }
        }
Exemplo n.º 2
0
        public void Clear(Action del)
        {
            del();

            _historyLoaded           = null;
            _accountGroupsRangeCache = null;
            _projectsRangeCache      = null;
            _tasksRangeCache         = null;
            _itemRangeCache          = null;
        }