public static Type GetSearchType(Type origSearchType, ReportParametersFlag reportParametersMask)
        {
            //params will be passed into GetRecords context if they will be parsed from the query
            if (reportParametersMask != ReportParametersFlag.None)
            {
                BqlCommand cmd = BqlCommand.CreateInstance(origSearchType);

                if ((reportParametersMask & ReportParametersFlag.Organization) == ReportParametersFlag.Organization)
                {
                    cmd = cmd.WhereAnd <Where <FABookPeriod.organizationID, Equal <Optional2 <FAQueryParameters.organizationID> > > >();
                }
                if ((reportParametersMask & ReportParametersFlag.Branch) == ReportParametersFlag.Branch)
                {
                    cmd = cmd.WhereAnd <Where <FABookPeriod.organizationID, Equal <Optional2 <FAQueryParameters.branchID> > > >();
                }
                if ((reportParametersMask & ReportParametersFlag.BAccount) == ReportParametersFlag.BAccount)
                {
                    cmd = cmd.WhereAnd <Where <FABookPeriod.organizationID, Equal <Optional2 <FAQueryParameters.orgBAccountID> > > >();
                }
                if ((reportParametersMask & ReportParametersFlag.FixedAsset) == ReportParametersFlag.FixedAsset)
                {
                    cmd = cmd.WhereAnd <Where <FABookPeriod.organizationID, Equal <Optional2 <FAQueryParameters.assetID> > > >();
                }
                if ((reportParametersMask & ReportParametersFlag.Book) == ReportParametersFlag.Book)
                {
                    cmd = cmd.WhereAnd <Where <FABookPeriod.bookID, Equal <Optional2 <FAQueryParameters.bookID> > > >();
                }

                return(cmd.GetType());
            }

            return(origSearchType);
        }
コード例 #2
0
ファイル: Attribute.cs プロジェクト: Vialythen/AcumaticaTest
 protected virtual Type GetSearchTypeRestrictedByDate(Type selectorSearchType, Type dateType)
 {
     selectorSearchType = selectorSearchType ?? GetDefaultSelectorSearchType();
     if (dateType != null)
     {
         BqlCommand select    = BqlCommand.CreateInstance(selectorSearchType) ?? throw new ArgumentNullException("BqlCommand.CreateInstance(selectorSearchType)");
         Type       whereDate = BqlCommand.Compose(
             typeof(Where <, ,>),
             typeof(FABookPeriod.startDate),
             typeof(LessEqual <>),
             typeof(Current <>),
             dateType,
             typeof(And <,>),
             typeof(FABookPeriod.endDate),
             typeof(Greater <>),
             typeof(Current <>),
             dateType);
         select = select.WhereAnd(whereDate);
         Type[] decomposed = BqlCommand.Decompose(select.GetSelectType());
         decomposed[0]      = BqlHelper.SelectToSearch[decomposed[0]];
         decomposed[1]      = typeof(FABookPeriod.finPeriodID);
         selectorSearchType = BqlCommand.Compose(decomposed);
     }
     return(selectorSearchType);
 }
コード例 #3
0
            protected override List <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> > SelectInventoryWithAttributes()
            {
                Type sumDecimalFields = BqlCommand.Compose(BqlHelper.GetDecimalFieldsAggregate <INSiteStatus>(Base, true).ToArray());

                Type select = BqlTemplate.OfCommand <
                    Select5 <CSAnswers,
                             InnerJoin <CSAttributeGroup, On <CSAnswers.attributeID, Equal <CSAttributeGroup.attributeID> >,
                                        InnerJoin <InventoryItem, On <CSAnswers.refNoteID, Equal <InventoryItem.noteID>,
                                                                      And <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > >,
                                                   LeftJoin <INSiteStatus, On <INSiteStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                               And <INSiteStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                    And <Where <INSiteStatus.siteID, Equal <Current <EntryHeader.siteID> >, Or <Current <EntryHeader.siteID>, IsNull> > > > >,
                                                             LeftJoin <INLocationStatus, On <INLocationStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                                             And <INLocationStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                                  And <INLocationStatus.siteID, Equal <Current <EntryHeader.siteID> >,
                                                                                                       And <INLocationStatus.locationID, Equal <Current <EntryHeader.locationID> > > > > > > > > >,
                             Where <CSAttributeGroup.isActive, Equal <True>,
                                    And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                         And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                              And <InventoryItem.templateItemID, Equal <Current <EntryHeader.templateItemID> > > > > >,
                             Aggregate <GroupBy <InventoryItem.inventoryID, GroupBy <CSAnswers.refNoteID, GroupBy <CSAnswers.attributeID, BqlPlaceholder.A> > > >,
                             OrderBy <Asc <InventoryItem.inventoryID, Asc <CSAnswers.refNoteID, Asc <CSAnswers.attributeID> > > > > >
                              .Replace <BqlPlaceholder.A>(sumDecimalFields)
                              .ToType();

                var view = new PXView(Base, true, BqlCommand.CreateInstance(select));

                using (new PXFieldScope(view,
                                        typeof(InventoryItem.inventoryID), typeof(CSAnswers.attributeID), typeof(CSAnswers.value),
                                        typeof(INSiteStatus), typeof(INLocationStatus)))
                {
                    return(view.SelectMulti().Cast <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> >().ToList());
                }
            }
コード例 #4
0
        public override void CacheAttached(PXCache sender)
        {
            if (sender.Graph.GetType() == typeof(AttrGraph))
            {
                return;
            }

            if (sender.Graph.GetType() == typeof(PXGraph) || sender.Graph.GetType() == typeof(PX.Data.Maintenance.GI.GenericInquiryDesigner))
            {
                _IsActive = true;
            }
            base.CacheAttached(sender);

            InitializeFields(sender);

            Type selectType = _SingleSelect.GetType();
            Type itemType   = sender.GetItemType();

            while (itemType != typeof(object) && selectType == _SingleSelect.GetType())
            {
                selectType = BqlCommand.Parametrize(itemType, selectType);
                itemType   = itemType.BaseType;
            }
            _View = new PXView(sender.Graph, true, BqlCommand.CreateInstance(selectType));
        }
コード例 #5
0
ファイル: Attribute.cs プロジェクト: Vialythen/AcumaticaTest
 protected override Type GetQueryWithRestrictionByOrganization(Type bqlQueryType)
 {
     return(BqlCommand.CreateInstance(bqlQueryType)
            .WhereAnd(typeof(Where <FABookPeriod.organizationID, Equal <Required <FABookPeriod.organizationID> >,
                                    And <FABookPeriod.bookID, Equal <Required <FABookPeriod.bookID> > > >))
            .GetType());
 }
コード例 #6
0
        private void SaveAs(bool onlyUpdate)
        {
            if (Templates.Current != null)
            {
                BqlCommand command = BqlCommand.CreateInstance(typeof(Select <CRFilterTemplate,
                                                                              Where <CRFilterTemplate.name, Equal <Current <CRFilterTemplate.name> >,
                                                                                     And <CRFilterTemplate.graphType, Equal <Required <CRFilterTemplate.graphType> > > > >));
                CRFilterTemplate templateToUpdate = (new PXView(this, true, command)).SelectSingle(graphTypeName) as CRFilterTemplate;

                if (onlyUpdate && templateToUpdate == null)
                {
                    return;
                }

                if (templateToUpdate == null)
                {
                    InsertNewTemplate();
                }
                else
                {
                    UpdateExistingTemplate(templateToUpdate);
                }

                CorrectGraphType();
                CorrectDefaultValues();

                SafetyPersist(Templates.Cache, PXDBOperation.Insert, PXDBOperation.Update);
                SafetyPersist(Filters.Cache, PXDBOperation.Delete, PXDBOperation.Insert, PXDBOperation.Update);

                Filters.Cache.Clear();
                Templates.Cache.Clear();
                Templates.View.RequestRefresh();
            }
        }
コード例 #7
0
        public static void VerifyFinPeriod <fieldPeriod, fieldClosed>(PXGraph graph, PXCache cache, object row, PXSelectBase <FinPeriod> finperiod)
            where fieldPeriod : class, IBqlField
            where fieldClosed : class, IBqlField
        {
            if (finperiod.Current != null)
            {
                GLSetup glsetup = PXSetup <GLSetup> .Select(graph);

                object isClosed = finperiod.Cache.GetValue <fieldClosed>(finperiod.Current);

                if (finperiod.Current.Active != true || isClosed.Equals(true) && glsetup != null && glsetup.PostClosedPeriods != true)
                {
                    BqlCommand select = BqlCommand.CreateInstance(typeof(Select <FinPeriod,
                                                                                 Where <FinPeriod.active, Equal <True>,
                                                                                        And <FinPeriod.finPeriodID, Greater <Required <FinPeriod.finPeriodID> > > >,
                                                                                 OrderBy <Asc <FinPeriod.finPeriodID> > >))
                                        .WhereAnd(BqlCommand.Compose(typeof(Where <,>), typeof(fieldClosed), typeof(NotEqual <True>)));

                    object    docPeriod = cache.GetValue <fieldPeriod>(row);
                    FinPeriod firstopen = new PXView(graph, false, select).SelectSingle(docPeriod) as FinPeriod;

                    if (firstopen == null)
                    {
                        string userPeriod = Mask.Format("##-####", finperiod.Cache.GetValueExt <FinPeriod.finPeriodID>(finperiod.Current).ToString());
                        throw new PXSetPropertyException(GL.Messages.NoActivePeriodAfter, userPeriod);
                    }

                    cache.SetValue <fieldPeriod>(row, firstopen.FinPeriodID);
                }
            }
        }
コード例 #8
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);
                    }
                }
            }
        }
コード例 #9
0
        private static PXView CreateRestictedIntView(PXGraph graph)
        {
            Type inventoryID = GetTypeField <Status>(typeof(INSiteStatus.inventoryID).Name);
            Type subItemID   = GetTypeField <Status>(typeof(INSiteStatus.subItemID).Name);
            Type siteID      = GetTypeField <Status>(typeof(INSiteStatus.siteID).Name);

            Type join =
                BqlCommand.Compose(
                    typeof(InnerJoin <,>),
                    typeof(RQRequestClassItem),
                    typeof(On <, ,>),
                    typeof(RQRequestClassItem.inventoryID), typeof(Equal <>), inventoryID,
                    typeof(And <RQRequestClassItem.reqClassID, Equal <Current <RQRequestClass.reqClassID> > >));

            Type where = CreateWhere(graph);

            Type selectType =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>),
                    typeof(Status),
                    join,
                    where);

            return(new LookupView(graph, BqlCommand.CreateInstance(selectType)));
        }
        public void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            EPEmployee employee = null;

            if (employeeSearch != null)
            {
                BqlCommand cmd  = BqlCommand.CreateInstance(employeeSearch);
                PXView     view = new PXView(sender.Graph, false, cmd);

                employee = view.SelectSingle() as EPEmployee;
            }

            if (employee != null && !string.IsNullOrEmpty(employee.UnionID))
            {
                HashSet <string> validUnions = new HashSet <string>();
                if (projectField != null)
                {
                    int?projectID = (int?)sender.GetValue(e.Row, projectField.Name);

                    if (ProjectDefaultAttribute.IsProject(sender.Graph, projectID))
                    {
                        var select = new PXSelect <PMProjectUnion, Where <PMProjectUnion.projectID, Equal <Required <PMProjectUnion.projectID> > > >(sender.Graph);
                        foreach (PMProjectUnion union in select.Select(projectID))
                        {
                            validUnions.Add(union.UnionID);
                        }
                    }
                }

                if (validUnions.Count == 0 || validUnions.Contains(employee.UnionID))
                {
                    e.NewValue = employee.UnionID;
                }
            }
        }
 ///
 public PXDBAttributeAttribute(Type valueSearch, Type attributeID)
 {
     if (valueSearch == null)
     {
         throw new PXArgumentException("type", ErrorMessages.ArgumentNullException);
     }
     if (attributeID == null)
     {
         throw new PXArgumentException("field", ErrorMessages.ArgumentNullException);
     }
     _Field = attributeID;
     if (typeof(IBqlSearch).IsAssignableFrom(valueSearch))
     {
         _SingleSelect = BqlCommand.CreateInstance(valueSearch);
     }
     else if (valueSearch.IsNested && typeof(IBqlField).IsAssignableFrom(valueSearch))
     {
         _SingleSelect = BqlCommand.CreateInstance(typeof(Search <>), valueSearch);
     }
     else
     {
         throw new PXArgumentException("valueSearch", ErrorMessages.CantCreateForeignKeyReference, valueSearch);
     }
     _PureWhere    = (_SingleSelect as IHasBqlWhere).GetWhere();
     _SubSelect    = _SingleSelect.WhereAnd(typeof(Where <,>).MakeGenericType(_Field, typeof(Equal <AttributeIDPlaceholder>)));
     _SingleSelect = _SingleSelect.WhereAnd(BqlCommand.Compose(typeof(Where <,>), _Field, typeof(Equal <>), typeof(Required <>), _Field));
 }
コード例 #12
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);
        }
コード例 #13
0
        private BqlCommand GetBqlCommand(PXCache cache)
        {
            var fieldType = cache.GetBqlField(_FieldName);

            return(BqlCommand.CreateInstance(typeof(Select <,>), BqlTable,
                                             typeof(Where <,>), fieldType, typeof(Equal <>), typeof(Required <>), fieldType));
        }
コード例 #14
0
        public virtual IEnumerable records(PXAdapter adapter)
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(POPrintOrderFilter),
                typeof(POPrintOrderOwned.workgroupID),
                typeof(POPrintOrderOwned.ownerID));

            Type printWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontPrint, Equal <False>,
                                   And <POPrintOrderOwned.printed, NotEqual <True> > > >);
            Type emailWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontEmail, Equal <False>,
                                   And <POPrintOrderOwned.emailed, NotEqual <True> > > >);

            Type action =
                Filter.Current.Action == "<SELECT>"
                                ? typeof(Where <CS.boolTrue, Equal <CS.boolFalse> >)
                                : Filter.Current.Action.Contains("Email")
                                ? emailWhere :
                printWhere;

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(POPrintOrderOwned),
                    typeof(InnerJoin <Vendor, On <Vendor.bAccountID, Equal <POPrintOrderOwned.vendorID> > >),
                    typeof(Where <>), action);

            PXView view = new PXView(this, false, BqlCommand.CreateInstance(select));

            return(view.SelectMulti());
        }
コード例 #15
0
        protected virtual IEnumerable filter()
        {
            ApproveBillsFilter filter = Filter.Current;

            if (filter != null && filter.SelectionDate != null && filter.PendingRefresh == true)
            {
                DateTime PayInLessThan             = ((DateTime)filter.SelectionDate).AddDays(filter.PayInLessThan.GetValueOrDefault());
                DateTime DueInLessThan             = ((DateTime)filter.SelectionDate).AddDays(filter.DueInLessThan.GetValueOrDefault());
                DateTime DiscountExpiresInLessThan = ((DateTime)filter.SelectionDate).AddDays(filter.DiscountExpiresInLessThan.GetValueOrDefault());

                decimal approvedTotal = 0m;
                decimal docsTotal     = 0m;

                PXView view = new PXView(this, true, BqlCommand.CreateInstance(getAPDocumentSelect(true)));

                foreach (PXResult <APInvoice> temp in view.SelectMulti(PayInLessThan, DueInLessThan, DiscountExpiresInLessThan))
                {
                    APInvoice res = temp;
                    approvedTotal += res.PaySel == true ? (Accessinfo.CuryViewState ? (res.DocBal ?? 0m) : (res.CuryDocBal ?? 0m)) : 0m;
                    docsTotal     += Accessinfo.CuryViewState ? (res.DocBal ?? 0m) : (res.CuryDocBal ?? 0m);
                }

                Filter.Current.CuryApprovedTotal = approvedTotal;
                Filter.Current.CuryDocsTotal     = docsTotal;
                Filter.Current.PendingRefresh    = false;
            }

            yield return(Filter.Current);

            Filter.Cache.IsDirty = false;
        }
コード例 #16
0
        protected virtual void MarkAs(PXCache cache, CRActivity row, Guid UserID, int status)
        {
            if (IsImport || row.NoteID == null)
            {
                return;
            }

            var noteidType = typeof(TMaster).GetNestedType(typeof(CRActivity.noteID).Name);
            var ownerType  = typeof(TMaster).GetNestedType(typeof(CRActivity.ownerID).Name);

            var select = BqlCommand.Compose(
                typeof(Select <,>), typeof(EPView), typeof(Where <, ,>),
                typeof(EPView.noteID), typeof(Equal <>), typeof(Required <>), noteidType,
                typeof(And <,>), typeof(EPView.userID), typeof(Equal <>), typeof(Required <>), ownerType
                );

            EPView epview = (EPView) new PXView(this, false,
                                                BqlCommand.CreateInstance(select)).SelectSingle(row.NoteID, UserID);

            if (epview == null)
            {
                epview = new EPView
                {
                    NoteID = row.NoteID,
                    UserID = UserID,
                };
            }
            else
            {
                epview = PXCache <EPView> .CreateCopy(epview);
            }

            if (status == EPViewStatusAttribute.VIEWED
                                        ? epview.Status != EPViewStatusAttribute.VIEWED
                                        : epview.Status == EPViewStatusAttribute.VIEWED)
            {
                epview.Status = status;
                EPViews.Update(epview);

                bool isDirty = false;
                foreach (PXCache c in Views.Caches.Where(t => t != typeof(EPView)).Select(t => Caches[t]))
                {
                    isDirty = c.Inserted.ToArray <object>().Any() || c.Updated.ToArray <object>().Any() || c.Deleted.ToArray <object>().Any();
                    if (isDirty)
                    {
                        break;
                    }
                }
                if (!isDirty)
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        Persist();
                        ts.Complete();
                    }
                }
                EPViews.Cache.IsDirty = false;
            }
        }
コード例 #17
0
        public static BqlCommand CreateSelectCommand(Type entityType, Type fieldType)
        {
            Type required = BqlCommand.Compose(typeof(Required <>), fieldType);
            Type equal    = BqlCommand.Compose(typeof(Equal <>), required);

            Type where = BqlCommand.Compose(typeof(Where <,>), fieldType, equal);
            return(BqlCommand.CreateInstance(typeof(Select <,>), entityType, where));
        }
コード例 #18
0
            public override void CacheAttached(PXCache sender)
            {
                base.CacheAttached(sender);

                _select = BqlCommand.CreateInstance(typeof(Select2 <FABook,
                                                                    InnerJoin <FABookSettings, On <FABookSettings.bookID, Equal <FABook.bookID> > >,
                                                                    Where <FABookSettings.assetID, Equal <Current <FABookBalance.classID> > > >));
            }
コード例 #19
0
        private PXView GetChildView(PXCache cache)
        {
            var command = BqlCommand.CreateInstance(
                typeof(Select <,>), childReferenceType,
                typeof(Where <,>), childReferenceKeyType, typeof(Equal <>), typeof(Required <>), childReferenceKeyType);

            return(new PXView(cache.Graph, false, command));
        }
コード例 #20
0
        private static int?GetAssignmentMapId(PXGraph graph)
        {
            BqlCommand search = (BqlCommand)Activator.CreateInstance(BqlCommand.Compose(typeof(Search <>), typeof(TAssignmentMapField)));
            PXView     view   = new PXView(graph, true, BqlCommand.CreateInstance(search.GetSelectType()));
            object     row    = view.SelectSingle();

            return(row.With(_ => (int?)view.Cache.GetValue(_, ((IBqlSearch)search).GetField().Name)));
        }
コード例 #21
0
 public TaxReportLineSelector(Type search, params Type[] fields) : base(search, fields)
 {
     this.DescriptionField = typeof(TaxReportLine.descr);
     _UnconditionalSelect  =
         BqlCommand.CreateInstance(typeof(Search <TaxReportLine.lineNbr,
                                                  Where <TaxReportLine.vendorID, Equal <Current <TaxReportLine.vendorID> >,
                                                         And <TaxReportLine.lineNbr, Equal <Required <TaxReportLine.lineNbr> > > > >));
     _CacheGlobal = false;
 }
コード例 #22
0
        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);
        }
コード例 #23
0
        protected virtual bool CheckCondition(PXCache sender, object row)
        {
            object[]   selectParams = GetParams(sender, row);
            BqlCommand cmd          = BqlCommand.CreateInstance(_ConditionSelect);
            PXView     view         = sender.Graph.TypedViews.GetView(cmd, true);
            object     result       = view.SelectSingleBound(new object[] { row }, selectParams);

            return(result != null);
        }
コード例 #24
0
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            BqlCommand search = (BqlCommand)Activator.CreateInstance(BqlCommand.Compose(typeof(Search <>), MigrationModeSetupField));
            PXView     view   = new PXView(sender.Graph, true, BqlCommand.CreateInstance(search.GetSelectType()));
            object     setup  = view.SelectSingle();

            IsMigrationModeEnabled = (view.Cache.GetValue(setup, MigrationModeSetupField.Name) as bool?) == true;
        }
コード例 #25
0
        public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
        {
            Type    table      = BqlCommand.GetItemType(typeof(Field));
            PXCache cacheSetup = cache.Graph.Caches[table];
            string  fieldName  = cacheSetup.GetField(typeof(Field));

            object setup = new PXView(cache.Graph, true, BqlCommand.CreateInstance(typeof(Select <>), table)).SelectSingle();

            return(cacheSetup.GetValue(setup, fieldName));
        }
コード例 #26
0
        protected virtual void TMasterFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            TMaster row = (TMaster)e.Row;

            if (row == null || row.ClassID == null)
            {
                return;
            }

            RelatedEntity pars = this.Caches <RelatedEntity>().Current as RelatedEntity;

            if (pars == null || pars.Type == null || pars.RefNoteID == null)
            {
                return;
            }

            EntityHelper helper     = new EntityHelper(this);
            Type         entityType = PXBuildManager.GetType(pars.Type, false);
            var          related    = new EntityHelper(this).GetEntityRow(entityType, pars.RefNoteID);

            if (related == null)
            {
                return;
            }

            Type graphType = helper.GetPrimaryGraphType(entityType, related, true);

            if (graphType == null)
            {
                return;
            }

            TMaster copy = PXCache <TMaster> .CreateCopy(row);

            PXGraph graph = CreateInstance(graphType);

            Type   noteType = EntityHelper.GetNoteType(entityType);
            PXView view     = new PXView(this, false, BqlCommand.CreateInstance(BqlCommand.Compose(typeof(Select <,>), entityType, typeof(Where <,>), noteType, typeof(Equal <>), typeof(Required <>), noteType)));

            graph.Caches[entityType].Current = view.SelectSingle(pars.RefNoteID);

            PXCache <TMaster> cache = graph.Caches <TMaster>();

            cache.SetDefaultExt(copy, typeof(CRActivity.bAccountID).Name);
            cache.SetDefaultExt(copy, typeof(CRActivity.contactID).Name);
            if (copy.BAccountID != null)
            {
                row.BAccountID = copy.BAccountID;
            }
            if (copy.ContactID != null)
            {
                row.ContactID = copy.ContactID;
            }
        }
コード例 #27
0
        protected virtual PXView CreateIntView(PXGraph graph)
        {
            Type type = BqlCommand.Compose((new List <Type>()
            {
                typeof(Select <,>),
                typeof(RowToSelect),
                CreateWhere(graph)
            }).ToArray());

            return(new PXView(graph, true, BqlCommand.CreateInstance(new Type[] { type })));
        }
コード例 #28
0
        protected virtual BqlCommand GetCommand(PXCache cache, object extRow, List <object> parameters, FABookPeriod.Key periodKey)
        {
            BqlCommand cmd = BqlCommand.CreateInstance(OrigSearchType);

            cmd = cmd.WhereAnd <Where <FABookPeriod.organizationID, Equal <Required <FABookPeriod.organizationID> >,
                                       And <FABookPeriod.bookID, Equal <Required <FABookPeriod.bookID> > > > >();

            parameters.Add(periodKey.OrganizationID);
            parameters.Add(periodKey.BookID);

            return(cmd);
        }
コード例 #29
0
        protected virtual string GetBasicNumberingID()
        {
            GLWorkBook currentWB = this.WorkBooks.Current;

            if (currentWB == null || currentWB.Module == null || currentWB.DocType == null)
            {
                return(null);
            }
            Type numberingField;

            switch (currentWB.Module)
            {
            case BatchModule.CA:
                numberingField = typeof(CASetup.registerNumberingID);
                break;

            case BatchModule.GL:
                numberingField = BatchModule.NumberingAttribute.GetNumberingIDField(BatchModule.GL);
                break;

            case BatchModule.AP:
                numberingField = AP.APInvoiceType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                if (numberingField == null)
                {
                    numberingField = AP.APPaymentType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                }
                break;

            case BatchModule.AR:
                numberingField = AR.ARInvoiceType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                if (numberingField == null)
                {
                    numberingField = AR.ARPaymentType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                }
                break;

            default: return(null);
            }
            if (numberingField == null)
            {
                return(null);
            }
            Type select =
                BqlCommand.Compose(
                    typeof(Select <,>), typeof(CS.Numbering),
                    typeof(Where <,>), typeof(CS.Numbering.numberingID),
                    typeof(Equal <>), typeof(Current <>), numberingField);
            PXView view = new PXView(this, false, BqlCommand.CreateInstance(select));
            var    item = view.SelectSingle();

            return(((CS.Numbering)item).NumberingID);
        }
コード例 #30
0
        protected virtual void EnsureSearchView(PXCache sender)
        {
            if (searchView == null)
            {
                List <Type> list = new List <Type>();
                list.Add(typeof(Select <,>));
                list.Add(sender.GetItemType());
                list.AddRange(BqlCommand.Decompose(WhereConstraint));

                BqlCommand cmd = BqlCommand.CreateInstance(list.ToArray());
                searchView = new PXView(sender.Graph, true, cmd);
            }
        }