Esempio n. 1
0
        public override void ProccessItem(PXGraph graph, TPrimary item)
        {
            PXCache  cache   = graph.Caches[typeof(TPrimary)];
            TPrimary newItem = (TPrimary)cache.CreateInstance();

            PXCache <TPrimary> .RestoreCopy(newItem, item);

            string entityType = CSAnswerType.GetAnswerType(cache.GetItemType());
            string entityID   = CSAnswerType.GetEntityID(cache.GetItemType());

            PXView primaryView = graph.Views[graph.PrimaryView];

            object[] searches    = new object[primaryView.Cache.BqlKeys.Count];
            string[] sortcolumns = new string[primaryView.Cache.BqlKeys.Count];
            for (int i = 0; i < cache.BqlKeys.Count(); i++)
            {
                sortcolumns[i] = cache.BqlKeys[i].Name;
                searches[i]    = cache.GetValue(newItem, sortcolumns[i]);
            }
            int startRow = 0, totalRows = 0;

            List <object> result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);

            newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));

            foreach (FieldValue fieldValue in Fields.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID == null && o.Selected == true))
            {
                PXFieldState  state    = cache.GetStateExt(newItem, fieldValue.Name) as PXFieldState;
                PXIntState    intState = state as PXIntState;
                PXStringState strState = state as PXStringState;
                if ((intState != null && intState.AllowedValues != null && intState.AllowedValues.Length > 0 &&
                     intState.AllowedValues.All(v => v != int.Parse(fieldValue.Value)))
                    ||
                    (strState != null && strState.AllowedValues != null && strState.AllowedValues.Length > 0 &&
                     strState.AllowedValues.All(v => v != fieldValue.Value)))
                {
                    throw new PXSetPropertyException(ErrorMessages.UnallowedListValue, fieldValue.Value, fieldValue.Name);
                }
                if (state != null && !Equals(state.Value, fieldValue.Value))
                {
                    cache.SetValueExt(newItem, fieldValue.Name, fieldValue.Value);
                    cache.Update(newItem);
                }

                result  = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);
                newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));
            }

            PXCache attrCache = cache.Graph.Caches[typeof(CSAnswers)];

            foreach (FieldValue attrValue in Attributes.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID != null && o.Selected == true))
            {
                CSAnswers attr = (CSAnswers)attrCache.CreateInstance();
                attr.AttributeID = attrValue.AttributeID;
                attr.EntityID    = cache.GetValue(newItem, entityID) as int?;
                attr.EntityType  = entityType;
                attr.Value       = attrValue.Value;
                attrCache.Update(attr);
            }
        }
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            FABookPeriod.Key periodKey =
                ReportParametersMask != ReportParametersFlag.None
                ? BookPeriodKeyProvider.GetKeyFromReportParameters(_Graph, PXView.Parameters, ReportParametersMask)
                : BookPeriodKeyProvider.GetKey(_Graph, cache, extCurrentRow);

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>();

            BqlCommand cmd = GetCommand(cache, extCurrentRow, parameters, periodKey);

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                return(view.Select(PXView.Currents, parameters.ToArray(), PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows));
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
Esempio n. 3
0
        public IEnumerable detailsView()
        {
            List <object> result = new List <object>();

            var currentSearchPeriod = ((LumINItemCostFilter)this.Caches[typeof(LumINItemCostFilter)].Current)?.FinPeriodID;

            if (currentSearchPeriod != null)
            {
                var           pars      = new List <PXSPParameter>();
                PXSPParameter period    = new PXSPInParameter("@period", PXDbType.Int, currentSearchPeriod);
                PXSPParameter companyID = new PXSPInParameter("@companyID", PXDbType.Int, PX.Data.Update.PXInstanceHelper.CurrentCompany);
                pars.Add(period);
                pars.Add(companyID);

                using (new PXConnectionScope())
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        PXDatabase.Execute("SP_GenerateLumINItemCostHist", pars.ToArray());
                        ts.Complete();
                    }
                }

                PXView select   = new PXView(this, true, DetailsView.View.BqlSelect);
                int    totalrow = 0;
                int    startrow = PXView.StartRow;
                result          = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
                PXView.StartRow = 0;
                return(result);
            }

            return(result);
        }
Esempio n. 4
0
        protected virtual IEnumerable fixedDemand()
        {
            PXView select = new PXView(Base, false, Base.FixedDemand.View.BqlSelect);

            Int32         totalrow = 0;
            Int32         startrow = PXView.StartRow;
            List <object> result   = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches,
                                                   PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);

            PXView.StartRow = 0;

            foreach (PXResult <POFixedDemand, InventoryItem, Vendor, POVendorInventory, CRLocation, SOOrder, SOLineSplit, SOLine, INItemClass, FSServiceOrder> rec in result)
            {
                var demand = (POFixedDemand)rec;
                var item   = (InventoryItem)rec;
                var vendor = (Vendor)rec;
                var price  = (POVendorInventory)rec;
                Base.EnumerateAndPrepareFixedDemandRow(demand, item, vendor, price);

                FSServiceOrder fsServiceOrderRow = (FSServiceOrder)rec;
                SOOrder        soOrderRow        = (SOOrder)rec;

                if (fsServiceOrderRow.CustomerID != null)
                {
                    soOrderRow.CustomerID = fsServiceOrderRow.CustomerID;
                }

                FSxPOFixedDemand fSxPOFixedDemandRow = Base.FixedDemand.Cache.GetExtension <FSxPOFixedDemand>(demand);
                fSxPOFixedDemandRow.FSRefNbr = fsServiceOrderRow.RefNbr;
            }

            return(result);
        }
            public IEnumerable transactions()
            {
                if (!IsCartRequired)
                {
                    return(null);
                }
                PXDelegateResult sorted = new PXDelegateResult
                {
                    IsResultSorted    = true,
                    IsResultFiltered  = true,
                    IsResultTruncated = true
                };
                var view     = new PXView(Base, false, Base.transactions.View.BqlSelect);
                int startRow = PXView.StartRow;
                int totalRow = 0;
                var lines    = view.Select(
                    PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                    ref startRow, PXView.MaximumRows, ref totalRow)
                               .OfType <INTran>()
                               .Select(x => new { Line = x, IsInCart = (GetCartQty(x) ?? 0) > 0 })
                               .OrderByDescending(x => x.IsInCart)
                               .Select(x => x.Line)
                               .ToList();

                sorted.AddRange(lines);
                return(sorted);
            }
Esempio n. 6
0
        public virtual void NavigateToItem(EPActivity current)
        {
            if (current != null)
            {
                var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(current);
                if (!PXAccess.VerifyRights(graphType))
                {
                    ReminderList.Ask(CR.Messages.AccessDenied, CR.Messages.FormNoAccessRightsMessage(graphType), MessageButtons.OK, MessageIcon.Error);
                }
                else
                {
                    var graph      = (PXGraph)PXGraph.CreateInstance(graphType);
                    var cache      = graph.Caches[current.GetType()];
                    var searchView = new PXView(
                        graph,
                        false,
                        BqlCommand.CreateInstance(typeof(Select <>), cache.GetItemType()));
                    var startRow  = 0;
                    var totalRows = 0;
                    var acts      = searchView.
                                    Select(null, null,
                                           new object[] { current.TaskID },
                                           new string[] { typeof(EPActivity.taskID).Name },
                                           null, null, ref startRow, 1, ref totalRows);

                    if (acts != null && acts.Count > 0)
                    {
                        var act = acts[0];
                        cache.Current = act;
                        PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
                    }
                }
            }
        }
Esempio n. 7
0
        private bool IsItemRuleTrue(IBqlTable item, EPAssignmentRule rule)
        {
            if (item is EPEmployee && rule.FieldName.Equals(typeof(EPEmployee.workgroupID).Name, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IsEmployeeInWorkgroup((EPEmployee)item, rule));
            }

            currentItem = item;
            Type   viewType = BqlCommand.Compose(typeof(Select <>), item.GetType());
            PXView itemView = new PXView(this, false, BqlCommand.CreateInstance(viewType),
                                         (PXSelectDelegate)getItemRecord);

            if (rule.Condition == null)
            {
                return(false);
            }

            PXFilterRow filter = new PXFilterRow(
                rule.FieldName,
                (PXCondition)rule.Condition.Value,
                GetFieldValue(item, rule.FieldName, rule.FieldValue),
                null);
            int startRow  = 0;
            int totalRows = 0;

            List <object> result = itemView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows);

            return(result.Count > 0);
        }
Esempio n. 8
0
        //TODO: need implementation

        /*public PXAction<CR.OwnedFilter> ExportCalendar;
         * [PXUIField(DisplayName = Messages.ExportCalendar)]
         * [PXButton(Tooltip = Messages.ExportCalendarTooltip)]
         * public IEnumerable exportCalendar(PXAdapter adapter)
         * {
         *      var events = Events.Select().RowCast<EPActivity>();
         *      var calendar = (vCalendarIcs)VCalendarProcessor.CreateVCalendar(events);
         *      throw new EPIcsExportRedirectException(calendar);
         * }
         *
         * public PXAction<CR.OwnedFilter> ExportCard;
         * [PXUIField(DisplayName = Messages.ExportCard)]
         * [PXButton(Tooltip = Messages.ExportCardTooltip)]
         * public IEnumerable exportCard(PXAdapter adapter)
         * {
         *      if (Events.Current == null) return adapter.Get();
         *      var card = VCalendarProcessor.CreateVEvent(Events.Current);
         *      throw new EPIcsExportRedirectException(card);
         * }*/

        #endregion

        #region Data Handlers
        protected virtual IEnumerable events()
        {
            BqlCommand command = new Select2 <EPActivity,
                                              LeftJoin <EPAttendee, On <EPAttendee.userID, Equal <Current <AccessInfo.userID> >,
                                                                        And <EPAttendee.eventID, Equal <EPActivity.taskID> > >,
                                                        LeftJoin <EPView,
                                                                  On <EPView.noteID, Equal <EPActivity.noteID>,
                                                                      And <EPView.userID, Equal <Current <AccessInfo.userID> > > > > >,
                                              Where <EPActivity.classID, Equal <CRActivityClass.events> >,
                                              OrderBy <Desc <EPActivity.priority, Asc <EPActivity.startDate, Asc <EPActivity.endDate> > > > >();

            var filter = Filter.Current;

            if (filter.OwnerID != null)
            {
                command = new Select2 <EPActivity,
                                       LeftJoin <EPAttendee, On <EPAttendee.userID, Equal <CurrentValue <CR.OwnedFilter.ownerID> >,
                                                                 And <EPAttendee.eventID, Equal <EPActivity.taskID> > >,
                                                 LeftJoin <EPView,
                                                           On <EPView.noteID, Equal <EPActivity.noteID>,
                                                               And <EPView.userID, Equal <Current <AccessInfo.userID> > > > > >,
                                       Where2 <Where <EPActivity.createdByID, Equal <CurrentValue <CR.OwnedFilter.ownerID> >, Or <EPAttendee.userID, IsNotNull> >,
                                               And <Where <EPActivity.classID, Equal <CRActivityClass.events> > > >,
                                       OrderBy <Desc <EPActivity.priority, Asc <EPActivity.startDate, Asc <EPActivity.endDate> > > > >();
            }

            var view      = new PXView(this, true, command);
            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                        ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
        protected virtual IEnumerable selectedItems()
        {
            EMailAccountSyncFilter filter = Filter.Current;

            BqlCommand cmd = SelectedItems.View.BqlSelect;

            if (filter != null && filter.ServerID != null)
            {
                cmd = cmd.WhereAnd <Where <EMailSyncAccount.serverID, Equal <Current <EMailAccountSyncFilter.serverID> > > >();
            }
            if (filter != null && !String.IsNullOrEmpty(filter.PolicyName))
            {
                cmd = cmd.WhereAnd <Where <EMailSyncAccount.policyName, Equal <Current <EMailAccountSyncFilter.policyName> > > >();
            }

            int    totalRows = 0;
            int    startRow  = PXView.StartRow;
            PXView view      = new PXView(this, false, cmd); view.Clear( );

            foreach (PXResult <EMailSyncAccount, EMailSyncServer, EPEmployee, Contact> item in
                     view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                Contact          contact = item;
                EMailSyncAccount account = item;
                account.Address = (contact != null ? contact.EMail : null) ?? account.Address;

                //SelectedItems.Cache.SetStatus(account, PXEntryStatus.Notchanged);

                yield return(item);
            }
        }
Esempio n. 10
0
        protected virtual IEnumerable viewHandler()
        {
            if (intView == null)
            {
                intView = CreateIntView(View.Graph);
            }
            int startRow = PXView.StartRow;
            int num      = 0;
            PXDelegateResult pXDelegateResult = new PXDelegateResult();

            foreach (object obj in intView.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref num))
            {
                var statu  = PXResult.Unwrap <RowToSelect>(obj);
                var statu1 = statu;
                var statu2 = (Cache.Locate(statu) as RowToSelect);
                if (statu2 != null)
                {
                    bool?value = (Cache.GetValue(statu2, Selected) as bool?);
                    if (value.GetValueOrDefault() & value.HasValue)
                    {
                        Cache.RestoreCopy(statu2, statu);
                        Cache.SetValue(statu2, Selected, true);
                        statu1 = statu2;
                    }
                }
                pXDelegateResult.Add(statu1);
            }
            PXView.StartRow = 0;
            if (PXView.ReverseOrder)
            {
                pXDelegateResult.Reverse();
            }
            pXDelegateResult.IsResultSorted = true;
            return(pXDelegateResult);
        }
Esempio n. 11
0
        protected virtual IEnumerable activities()
        {
            var command = Activities.View.BqlSelect;
            var filter  = Filter.Current;

            if (filter.OwnerID != null)
            {
                command = command.WhereOr(typeof(Where <EPActivity.owner, Equal <CurrentValue <OwnedFilter.ownerID> > >));
            }
            if (filter.WorkGroupID != null)
            {
                command = command.WhereAnd(typeof(Where <EPActivity.groupID, Equal <CurrentValue <OwnedFilter.workGroupID> > >));
            }
            if (filter.MyWorkGroup == true)
            {
                command = command.WhereAnd(typeof(Where <EPActivity.groupID, InMember <CurrentValue <OwnedFilter.currentOwnerID> > >));
            }
            command = command.WhereAnd(typeof(Where <EPActivity.classID, Equal <CRActivityClass.activity>,
                                                     Or <EPActivity.classID, Equal <CRActivityClass.email> > >));

            var view      = new PXView(this, true, command);
            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                        ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
Esempio n. 12
0
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            int?calendarOrganizationID = TakeBranchForSelectorFromQueryParams || TakeOrganizationForSelectorFromQueryParams
                                ? SourceOrganizationIDProvider.GetCalendarOrganizationID(PXView.Parameters, TakeBranchForSelectorFromQueryParams, TakeOrganizationForSelectorFromQueryParams)
                                : SourceOrganizationIDProvider.GetCalendarOrganizationID(cache.Graph, cache, extCurrentRow);

            calendarOrganizationID = calendarOrganizationID ?? FinPeriod.organizationID.MasterValue;

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>();

            BqlCommand cmd = GetCommand(cache, extCurrentRow, parameters, calendarOrganizationID);

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                IEnumerable <object> data = view.Select(PXView.Currents, parameters.ToArray(), PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);

                var r = data.Select(record => BuildFinPeriod(calendarOrganizationID, record)).ToArray();

                return(r);
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
            public override void CacheAttached(PXCache sender)
            {
                base.CacheAttached(sender);
                PXView outerview = new PXView(sender.Graph, true, _Select);
                PXView view      = sender.Graph.Views[_ViewName] = new PXView(sender.Graph, true, _Select, (PXSelectDelegate) delegate()
                {
                    int startRow  = PXView.StartRow;
                    int totalRows = 0;
                    List <object> res;

                    using (new PXReadBranchRestrictedScope())
                    {
                        res             = outerview.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
                        PXView.StartRow = 0;
                    }

                    PXCache cache = outerview.Graph.Caches[typeof(INSite)];

                    return(res.FindAll((item) =>
                    {
                        return _RestrictedSelect.Meet(cache, item is PXResult ? PXResult.Unwrap <INSite>(item) : item);
                    }));
                });

                if (_DirtyRead)
                {
                    view.IsReadOnly = false;
                }
            }
        protected virtual IEnumerable SelectOpportunities(List <string> fields)
        {
            ObfuscateType filter = Filter.Current;

            if (filter.MasterEntity != "OP")
            {
                return(new List <PXResult <CRContact, BAccount> >());
            }

            var view = new PXView(this, true, BqlCommand.CreateInstance(
                                      typeof(Select2 <, ,>),
                                      typeof(CRContact),
                                      typeof(LeftJoin <BAccount, On <BAccount.bAccountID, Equal <CRContact.bAccountID> > >),
                                      typeof(Where <, ,>),
                                      typeof(CRContactExt.pseudonymizationStatus), typeof(Equal <>), GetPseudonymizationStatus,
                                      typeof(Or <,>), typeof(CRContactExt.pseudonymizationStatus), typeof(IsNull)));

            List <PXFilterRow> filters = new List <PXFilterRow>();

            foreach (PXFilterRow filterRow in PXView.Filters)
            {
                filters.Add(filterRow);
            }

            if (!String.IsNullOrWhiteSpace(filter.Search))
            {
                for (int i = 0; i < fields.Count; i++)
                {
                    filters.Add(new PXFilterRow()
                    {
                        OrOperator    = true,
                        OpenBrackets  = i == 0 ? 1 : 0,
                        DataField     = fields[i],
                        Condition     = PXCondition.LIKE,
                        Value         = filter.Search,
                        CloseBrackets = i == fields.Count - 1 ? 1 : 0
                    });
                }
            }

            if (filter.ConsentExpired == true)
            {
                view.WhereAnd <Where <CRContact.consentExpirationDate, LessEqual <Now> > >();
            }

            if (filter.NoConsent == true)
            {
                view.WhereAnd <Where <CRContact.consentDate, IsNull> >();
            }

            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, null, null, filters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
Esempio n. 15
0
        public virtual IEnumerable tasks()
        {
            var command = new Select3 <EPActivity,
                                       LeftJoin <MyEPCompanyTree,
                                                 On <MyEPCompanyTree.workGroupID, Equal <EPActivity.groupID> >,
                                                 LeftJoin <EPView,
                                                           On <EPView.noteID, Equal <EPActivity.noteID>,
                                                               And <EPView.userID, Equal <Current <AccessInfo.userID> > > > > >,
                                       OrderBy <Asc <EPActivity.endDate,
                                                     Desc <EPActivity.priority,
                                                           Asc <EPActivity.startDate> > > > >() as BqlCommand;
            var filter = Filter.Current;

            if (filter.OwnerID == null && filter.WorkGroupID == null)
            {
                command = command.WhereAnd(
                    typeof(Where <EPActivity.groupID, Owned <CurrentValue <AccessInfo.userID> >,
                                  Or <Where <EPActivity.groupID, IsNull,
                                             And <EPActivity.owner, OwnedUser <CurrentValue <AccessInfo.userID> > > > > >));
            }
            else
            {
                if (filter.OwnerID != null)
                {
                    command = command.WhereOr(typeof(Where <EPActivity.owner, Equal <CurrentValue <TaskFilter.ownerID> > >));
                }
                if (filter.WorkGroupID != null)
                {
                    command = command.WhereAnd(typeof(Where <EPActivity.groupID, Equal <CurrentValue <TaskFilter.workGroupID> > >));
                }
                if (filter.MyWorkGroup == true)
                {
                    command = command.WhereAnd(typeof(Where <EPActivity.groupID, InMember <CurrentValue <TaskFilter.currentOwnerID> > >));
                }
                if (filter.IsEscalated == true)
                {
                    command = command.WhereOr(typeof(Where <EPActivity.groupID,
                                                            Escalated <CurrentValue <TaskFilter.ownerID>, EPActivity.groupID, EPActivity.owner, EPActivity.startDate> >));
                }
                if (filter.IsFollowUp == true)
                {
                    command = command.WhereOr(typeof(Where <EPActivity.createdByID, Equal <CurrentValue <TaskFilter.ownerID> > >));
                }
            }
            command = command.WhereAnd(typeof(Where <EPActivity.classID, Equal <CRActivityClass.task> >));

            var view      = new PXView(this, true, command);
            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                        ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
Esempio n. 16
0
        protected virtual IEnumerable filter()
        {
            PXCache cache = this.Caches[typeof(SchedulesFilter)];

            if (cache != null)
            {
                SchedulesFilter filter = cache.Current as SchedulesFilter;
                if (filter != null)
                {
                    int startRow  = 0;
                    int totalRows = 0;

                    filter.TotalDeferred  = 0;
                    filter.TotalScheduled = 0;

                    BqlCommand cmd = ComposeBQLCommandForRecords(filter);
                    if (cmd == null)
                    {
                        yield return(cache.Current);
                    }

                    cmd = cmd.AggregateNew <Aggregate <
                                                Sum <SchedulesInqResult.signTotalAmt,
                                                     Sum <SchedulesInqResult.signDefAmt> > > >();

                    PXView view = new PXView(this, true, cmd);

                    List <object> record = view.Select(new[] { filter },
                                                       null,
                                                       null,
                                                       null,
                                                       null,
                                                       Records.View.GetExternalFilters(),
                                                       ref startRow,
                                                       0,
                                                       ref totalRows);

                    if (record.Count > 0)
                    {
                        PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> rec =
                            (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem>)record[0];
                        filter.TotalScheduled = ((SchedulesInqResult)rec).SignTotalAmt;
                        filter.TotalDeferred  = ((SchedulesInqResult)rec).SignDefAmt;
                    }
                }
            }
            yield return(cache.Current);

            cache.IsDirty = false;
        }
Esempio n. 17
0
        public virtual IEnumerable ardocumentlist(PXAdapter adapter)
        {
            Type select = GetBQLStatement();

            PXView view      = new PXView(this, false, BqlCommand.CreateInstance(select));
            var    startRow  = PXView.StartRow;
            int    totalRows = 0;
            var    list      = view.
                               Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                      ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
Esempio n. 18
0
        private static IEnumerable SelectWithExternalParameters(PXView view, ref int startRow, ref int totalRows, object [] pars = null)
        {
            IEnumerable list = view.Select(
                PXView.Currents,
                pars ?? PXView.Parameters,
                PXView.Searches,
                view.GetExternalSorts(),
                view.GetExternalDescendings(),
                view.GetExternalFilters(),
                ref startRow,
                PXView.MaximumRows,
                ref totalRows);

            return(list);
        }
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            int?calendarOrganizationID = TakeBranchForSelectorFromQueryParams || TakeOrganizationForSelectorFromQueryParams
                                ? GetCalendarOrganizationIDProvider().GetCalendarOrganizationID(_Graph, PXView.Parameters, TakeBranchForSelectorFromQueryParams, TakeOrganizationForSelectorFromQueryParams)
                                : GetCalendarOrganizationIDProvider().GetCalendarOrganizationID(cache.Graph, cache, extCurrentRow);

            calendarOrganizationID = calendarOrganizationID ?? FinPeriod.organizationID.MasterValue;

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>();

            BqlCommand cmd = GetCommand(cache, extCurrentRow, parameters, calendarOrganizationID);

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                List <PXFilterRow> adjustedFilters = new List <PXFilterRow>();
                foreach (PXFilterRow f in PXView.Filters)
                {
                    // Attention: Conscious technomagic
                    // Depending on the need to use the master calendar, we either group by field FinPeriod.masterFinPeriodID or not.
                    // When using the master calendar, we also must use filtering by the FinPeriod.masterFinPeriodID field instead of the default FinPeriod.finPeriodID field.
                    if (calendarOrganizationID == FinPeriod.organizationID.MasterValue &&
                        MasterPeriodBasedOnOrganizationPeriods &&
                        string.Equals(f.DataField, nameof(FinPeriod.finPeriodID), StringComparison.OrdinalIgnoreCase))
                    {
                        f.DataField = nameof(FinPeriod.masterFinPeriodID);
                    }
                    adjustedFilters.Add(f);
                }

                IEnumerable <object> data = view.Select(PXView.Currents, parameters.ToArray(), PXView.Searches, PXView.SortColumns, PXView.Descendings, adjustedFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows);

                return(data.Select(record => BuildFinPeriod(calendarOrganizationID, record)).ToArray());
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
        protected virtual IEnumerable spdocs()
        {
            List <ARSPCommnDocResult> res = new List <ARSPCommnDocResult>();
            SPDocFilter filter            = Filter.Current;

            if (filter?.CommnPeriod != null)
            {
                PXSelectBase <ARSalesPerTran> sel = new PXSelectJoin <ARSalesPerTran,
                                                                      InnerJoin <ARRegister, On <ARSalesPerTran.docType, Equal <ARRegister.docType>,
                                                                                                 And <ARSalesPerTran.refNbr, Equal <ARRegister.refNbr> > >,
                                                                                 InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARRegister.customerID>,
                                                                                                                     And <Match <Customer, Current <AccessInfo.userName> > > > > >,
                                                                      Where <ARSalesPerTran.actuallyUsed, Equal <BQLConstants.BitOn> > >(this);

                if (filter.SalesPersonID != null)
                {
                    sel.WhereAnd <Where <ARSalesPerTran.salespersonID, Equal <Current <SPDocFilter.salesPersonID> > > >();
                }
                if (filter.CommnPeriod != null)
                {
                    sel.WhereAnd <Where <ARSalesPerTran.commnPaymntPeriod, Equal <Current <SPDocFilter.commnPeriod> > > >();
                }
                if (filter.CustomerID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerID, Equal <Current <SPDocFilter.customerID> > > >();
                }
                if (filter.LocationID != null)
                {
                    sel.WhereAnd <Where <ARRegister.customerLocationID, Equal <Current <SPDocFilter.locationID> > > >();
                }

                PXView        view              = sel.View;
                int           startRow          = PXView.StartRow;
                int           totalRows         = 0;
                List <object> windowedSelection = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
                PXView.StartRow = 0;

                foreach (PXResult <ARSalesPerTran, ARRegister, Customer> it in windowedSelection)
                {
                    ARSPCommnDocResult m = new ARSPCommnDocResult();
                    Copy(m, ((ARSalesPerTran)it));
                    Copy(m, ((ARRegister)it));
                    res.Add(m);
                }
            }
            return(res);
        }
Esempio n. 21
0
        private bool IsAttributeRuleTrue(object item, EPAssignmentRule rule)
        {
            string      field     = rule.FieldName.Substring(0, rule.FieldName.Length - "_Attribute".Length - 1);
            CSAttribute attribute = PXSelectReadonly <CSAttribute> .Search <CSAttribute.attributeID>(this, field);

            if (attribute == null || rule.Condition == null)
            {
                //Field Name is not a valid question.
                return(false);
            }

            var noteId = new EntityHelper(_Graph).GetEntityNoteID(item);

            CSAnswers ans = PXSelect <CSAnswers,
                                      Where <CSAnswers.refNoteID, Equal <Required <CSAnswers.refNoteID> >,
                                             And <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> > > > > .Select(_Graph ?? this, noteId, field);

            if (ans == null)
            {
                //Answer for the given question doesnot exist.
                switch (rule.Condition.Value)
                {
                case (int)PXCondition.ISNULL:
                    return(true);

                case (int)PXCondition.ISNOTNULL:
                    return(false);

                case (int)PXCondition.EQ:
                    return(string.IsNullOrEmpty(rule.FieldValue));

                case (int)PXCondition.NE:
                    return(!string.IsNullOrEmpty(rule.FieldValue));
                }
                return(false);
            }

            this.currentAttribute = ans;

            PXFilterRow filter    = new PXFilterRow(typeof(CSAnswers.value).Name, (PXCondition)rule.Condition.Value, rule.FieldValue, null);
            int         startRow  = 0;
            int         totalRows = 0;

            List <object> result = attributeView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows);

            return(result.Count > 0);
        }
Esempio n. 22
0
        private List <object> ExecuteRule(Table item, EPRule rule, ref bool isSuccessful)
        {
            try
            {
                List <EPRuleBaseCondition> conditions =
                    PXSelectReadonly <EPRuleCondition,
                                      Where <EPRuleCondition.ruleID, Equal <Required <EPRule.ruleID> >, And <EPRuleCondition.isActive, Equal <boolTrue> > > >
                    .Select(this, rule.RuleID)
                    .Select(_ => (EPRuleBaseCondition)_)
                    .ToList();

                if (conditions.Count == 0)
                {
                    return(null);
                }


                Type resultViewType = CreateResultView(processGraph, conditions);


                PXView itemView = new PXView(processGraph, false, BqlCommand.CreateInstance(resultViewType),
                                             (PXSelectDelegate)getItemRecord);

                Select(item, itemView, conditions.Select(_ => GraphHelper.GetType(_.Entity)).Distinct().ToList(), null);


                PXFilterRow[] filters = GenerateFilters(item, conditions).ToArray <PXFilterRow>();

                int           startRow  = 0;
                int           totalRows = 0;
                List <object> result    = itemView.Select(null, null, null, null, null, filters, ref startRow, 0, ref totalRows);

                results.Clear();

                TraceResult(rule, conditions, result.Count);

                return(result);
            }
            catch (Exception e)
            {
                isSuccessful = false;
                PXTrace.WriteInformation(e);
                return(null);
            }
        }
Esempio n. 23
0
        public IEnumerable gUICreditNote()
        {
            PXView view = new PXView(this, false, GUICreditNote.View.BqlSelect);

            if (Document.Current != null && Document.Current.RequestID != PX.Objects.CS.AutoNumberAttribute.GetNewNumberSymbol <TWNGUIInvCredit.requestID>(Document.Cache, Document.Current))
            {
                view.WhereAnd <Where <TWNGUITrans.orderNbr, Equal <Current <TWNGUIInvCredit.requestID> > > >();
            }

            int totalrow = 0;
            int startrow = PXView.StartRow;

            List <object> result = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);

            PXView.StartRow = 0;

            return(result);
        }
        public static PeriodResult GetPeriod(PXCache sender, Type searchType, DateTime fromdate, object[] currents, Boolean applyformat)
        {
            BqlCommand Select = BqlCommand.CreateInstance(searchType);

            Type   sourceType  = BqlCommand.GetItemType(((IBqlSearch)Select).GetField());
            string sourceField = ((IBqlSearch)Select).GetField().Name;

            PXView        view      = sender.Graph.TypedViews.GetView(Select, false);
            int           startRow  = 0;
            int           totalRows = 0;
            List <object> source    = view.Select(
                currents,
                new object[] { fromdate, fromdate },
                null,
                null,
                null,
                null,
                ref startRow,
                1,
                ref totalRows);

            if (source != null && source.Count > 0)
            {
                object item = source[source.Count - 1];
                if (item != null && item is PXResult)
                {
                    item = ((PXResult)item)[sourceType];
                }

                string result = (string)sender.Graph.Caches[sourceType].GetValue(item, sourceField);
                if (applyformat && result != null && result.Length == 6)
                {
                    result = FormatPeriod(result);
                }

                if (item as IPeriod != null)
                {
                    return(new PeriodResult {
                        PeriodID = result, StartDate = (item as IPeriod).StartDate, EndDate = (item as IPeriod).EndDate
                    });
                }
            }
            return(new PeriodResult());
        }
Esempio n. 25
0
        //Copied from PX.Data.Handlers.PXEntityOpener (it is private)
        public static void SelectCurrent(PXView primaryView, PX.Data.Description.PXViewDescription primaryViewInfo, params KeyValuePair <string, string>[] pars)
        {
            //selecting data
            List <object> searches = new List <object>();
            List <object> parameters = new List <object>();
            List <string> sortCols = new List <string>();
            List <bool>   descendings = new List <bool>();
            int           startRow = 0, totalRows = 0;

            foreach (KeyValuePair <string, string> pair in pars)
            {
                if (!primaryView.Cache.Keys.Contains(pair.Key))
                {
                    return;
                }

                PXFieldState state = primaryView.Cache.GetStateExt(null, pair.Key) as PXFieldState;
                object       val   = Convert.ChangeType(pair.Value, state.DataType);
                searches.Add(val);
                sortCols.Add(pair.Key);
                descendings.Add(false);

                if (primaryViewInfo.Parameters.Any(p => p.Name == pair.Key))
                {
                    parameters.Add(val);
                }
            }
            List <object> recs = primaryView.Select(null, parameters.ToArray(), searches.ToArray(), sortCols.ToArray(), descendings.ToArray(), null, ref startRow, 1, ref totalRows);

            if (recs == null || recs.Count == 0)
            {
                return;
            }

            Object current = recs[0] is PXResult ? ((PXResult)recs[0])[primaryView.Cache.GetItemType()] : recs[0];

            if (current == null)
            {
                return;
            }

            primaryView.Cache.Current = current;
        }
Esempio n. 26
0
        private IEnumerable SelectItems(PXView view)
        {
            List <PXFilterRow> list = new List <PXFilterRow>();

            foreach (CRFilterItem item in Filters.Select())
            {
                if ((item.IsUsed ?? false) && !string.IsNullOrEmpty(item.DataField))
                {
                    list.Add(new PXFilterRow(item.DataField, ParsePXCondition(item.Condition),
                                             item.Value, item.Value2));
                }
            }
            int startRow  = 0;
            int totalRows = 0;

            return(view.Select(null, null, null, null, null,
                               list.ToArray(), ref startRow,
                               0, ref totalRows));
        }
Esempio n. 27
0
        public virtual IEnumerable records()
        {
            var ret = new List <SchedulesInqResult>();

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            SchedulesFilter filter = this.Filter.Current;

            BqlCommand cmd = ComposeBQLCommandForRecords(filter);

            if (cmd == null)
            {
                return(ret);
            }

            PXView view = new PXView(this, true, cmd);

            foreach (PXResult <SchedulesInqResult, DRSchedule, DRDeferredCode, InventoryItem> record in
                     view.Select(
                         PXView.Currents,
                         null,
                         PXView.Searches,
                         PXView.SortColumns,
                         PXView.Descendings,
                         PXView.Filters,
                         ref startRow,
                         PXView.MaximumRows,
                         ref totalRows))
            {
                SchedulesInqResult schedulesInqResult = (SchedulesInqResult)record;
                InventoryItem      inventoryItem      = (InventoryItem)record;

                schedulesInqResult.ComponentCD  = inventoryItem.InventoryCD;
                schedulesInqResult.DocumentType = DRScheduleDocumentType.BuildDocumentType(schedulesInqResult.Module, schedulesInqResult.DocType);

                ret.Add(schedulesInqResult);
            }

            PXView.StartRow = 0;

            return(ret);
        }
Esempio n. 28
0
        public virtual IEnumerable messageDetails(PXAdapter a)
        {
            if (History.Current != null)
            {
                PXRedirectHelper.TryOpenPopup(History.Cache, History.Current, string.Empty);

                var activity = History.Current;

                var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(activity);
                if (!PXAccess.VerifyRights(graphType))
                {
                    MassMails.Ask(Messages.AccessDenied, Messages.FormNoAccessRightsMessage(graphType), MessageButtons.OK, MessageIcon.Error);
                }
                else
                {
                    var     graph      = PXGraph.CreateInstance(graphType);
                    PXCache cache      = graph.Caches[typeof(EPActivity)];
                    var     searchView = new PXView(
                        cache.Graph,
                        false,
                        BqlCommand.CreateInstance(typeof(Select <>), cache.GetItemType()));
                    var startRow  = 0;
                    var totalRows = 0;
                    var acts      = searchView.
                                    Select(null, null,
                                           new object[] { activity.TaskID },
                                           new string[] { typeof(EPActivity.taskID).Name },
                                           null, null, ref startRow, 1, ref totalRows);

                    if (acts != null && acts.Count > 0)
                    {
                        var act = acts[0];
                        cache.Current = act;
                        throw new PXPopupRedirectException(cache.Graph, graphType.Name, true)
                              {
                                  Mode = PXBaseRedirectException.WindowMode.NewWindow
                              };
                    }
                }
            }
            yield return(MassMails.Current);
        }
Esempio n. 29
0
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            int?organizationID = TakeBranchForSelectorFromQueryParams || TakeOrganizationForSelectorFromQueryParams
                                ? CalendarOrganizationIDProvider.GetCalendarOrganizationID(PXView.Parameters, TakeBranchForSelectorFromQueryParams, TakeOrganizationForSelectorFromQueryParams)
                                : CalendarOrganizationIDProvider.GetCalendarOrganizationID(cache.Graph, cache, extCurrentRow);

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>()
            {
                organizationID
            };

            BqlCommand cmd = BqlCommand.CreateInstance(SearchType);

            cmd = cmd.WhereAnd <Where <FinYear.organizationID, Equal <Required <FinYear.organizationID> > > >();

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                IEnumerable <object> data = view.Select(PXView.Currents,
                                                        parameters.ToArray(),
                                                        PXView.Searches,
                                                        PXView.SortColumns,
                                                        PXView.Descendings,
                                                        PXView.Filters,
                                                        ref startRow,
                                                        PXView.MaximumRows,
                                                        ref totalRows);
                return(data);
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
Esempio n. 30
0
        public virtual IEnumerable appointmentList()
        {
            PXView select = new PXView(this, true, AppointmentList.View.BqlSelect);

            int[] staffResult = StaffMemberFilter.Select()
                                .RowCast <FSAppointmentStaffMember>()
                                .Where(_ => _.Selected == true)
                                .Select(_ => _.BAccountID)
                                .Cast <int>()
                                .ToArray();

            Int32         totalrow = 0;
            Int32         startrow = PXView.StartRow;
            List <object> result   = select.Select(PXView.Currents, new object[] { staffResult }, null,
                                                   null, null, null, ref startrow, PXView.MaximumRows, ref totalrow);

            PXView.StartRow = 0;

            return(result);
        }