コード例 #1
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)));
        }
コード例 #2
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));
        }
コード例 #3
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> >, LeftJoin <EPEmployee, On <EPEmployee.bAccountID, Equal <POPrintOrderOwned.employeeID> > > >),
                    typeof(Where <>), action);

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

            return(view.SelectMulti());
        }
コード例 #4
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);
        }
コード例 #5
0
        protected override BqlCommand AddCaseLimitations(BqlCommand command)
        {
            var res = base.AddCaseLimitations(command);

            return(res.WhereAnd(typeof(Where2 <Where <SimpleCase.closed, Equal <False>, Or <SimpleCase.closed, IsNull> >,
                                               And <Where <SimpleCase.released, Equal <False>, Or <SimpleCase.released, IsNull> > > >)));
        }
コード例 #6
0
        public static void NewChild(PXCache cache, object parentrow, Type ParentType, out object child)
        {
            foreach (PXEventSubscriberAttribute attr in cache.GetAttributes(null))
            {
                if (attr is PXParentAttribute && ((PXParentAttribute)attr).ParentType.IsAssignableFrom(ParentType))
                {
                    Type childType = cache.GetItemType();

                    PXView parentView = ((PXParentAttribute)attr).GetParentSelect(cache);
                    Type   parentType = parentView.BqlSelect.GetFirstTable();

                    PXView     childView   = ((PXParentAttribute)attr).GetChildrenSelect(cache);
                    BqlCommand selectChild = childView.BqlSelect;

                    IBqlParameter[] pars = selectChild.GetParameters();
                    Type[]          refs = selectChild.GetReferencedFields(false);

                    child = Activator.CreateInstance(childType);
                    PXCache parentcache = cache.Graph.Caches[parentType];

                    for (int i = 0; i < Math.Min(pars.Length, refs.Length); i++)
                    {
                        Type   partype = pars[i].GetReferencedType();
                        object val     = parentcache.GetValue(parentrow, partype.Name);

                        cache.SetValue(child, refs[i].Name, val);
                    }
                    return;
                }
            }
            child = null;
        }
コード例 #7
0
        public static string MakeDescription <TField>(this PXGraph graph, string originalDescription, DescriptionMaker maker)
            where TField : IBqlField
        {
            string generatedDescription = maker(originalDescription);
            int    maxDescriptionLength = 0;

            graph.Caches[BqlCommand.GetItemType <TField>()].Adjust <PXDBStringAttribute>().For <TField>(attribute => maxDescriptionLength = attribute?.Length ?? -1);

            if (maxDescriptionLength == -1)             // PXDBStringAttribute not found, cutting is not needed
            {
                return(generatedDescription);
            }

            int delta = generatedDescription.Length - maxDescriptionLength;

            if (delta > 0)             // cutting is needed
            {
                if (delta > originalDescription.Length)
                {
                    throw new PXException(Messages.DescriptionCannotBeGenerated, maxDescriptionLength, typeof(TField).FullName, originalDescription, generatedDescription);
                }

                generatedDescription = maker(originalDescription.Substring(0, originalDescription.Length - delta));
            }
            return(generatedDescription);
        }
        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;
            }
        }
        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;
                }
            }
        }
コード例 #10
0
        protected virtual IEnumerable filter()
        {
            ApproveBillsFilter filter = Filter.Current;

            if (filter != null && filter.SelectionDate != null)
            {
                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;

                yield return(Filter.Current);

                Filter.Cache.IsDirty = false;
            }
        }
 protected override Type GetSearchType(Type projectId)
 {
     return(BqlCommand.Compose(typeof(Search <,>), typeof(PMTask.taskID),
                               typeof(Where <, ,>), typeof(PMTask.projectID), typeof(Equal <>), typeof(Optional <>), projectId,
                               typeof(And <PMTask.type, NotEqual <ProjectTaskType.revenue>,
                                           And <PMTask.status, In3 <ProjectTaskStatus.active, ProjectTaskStatus.planned> > >)));
 }
コード例 #12
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());
                }
            }
コード例 #13
0
        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);
        }
 ///
 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(nameof(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));
 }
コード例 #15
0
        protected virtual Type GetBQLStatement()
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(ARTwilioNotificationProcessFilter),
                typeof(ARInvoice.workgroupID),
                typeof(ARInvoice.ownerID));

            Type Where =
                typeof(Where <ARInvoice.hold, Equal <False>,
                              And <ARInvoice.released, Equal <True>,
                                   And <ARInvoice.voided, Equal <False>,
                                        And <ARInvoice.docType, Equal <ARInvoiceType.invoice>,
                                             And <ARInvoice.curyDocBal, Greater <decimal0>,
                                                  And <ARInvoice.docDate, LessEqual <Current <ARTwilioNotificationProcessFilter.endDate> >,
                                                       And <ARInvoice.docDate, GreaterEqual <Current <ARTwilioNotificationProcessFilter.beginDate> > > > > > > > >);

            Type whereAnd;

            whereAnd = Filter.Current.Action == "<SELECT>" ? typeof(Where <True, Equal <False> >) :
                       Where;

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(ARInvoice),
                    typeof(InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> > >),
                    typeof(Where2 <,>),
                    typeof(Match <Customer, Current <AccessInfo.userName> >),
                    typeof(And2 <,>), whereAnd,
                    typeof(And <>), where);

            return(select);
        }
コード例 #16
0
ファイル: Indexer.cs プロジェクト: PavelMPD/SimpleProjects
        private void ParseOperand(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, PX.Data.BqlCommand.Selection selection)
        {
            BqlCommand.EqualityList list = fields as BqlCommand.EqualityList;
            if (list != null)
            {
                list.NonStrict = true;
            }
            if (!typeof(IBqlCreator).IsAssignableFrom(typeof(Operand)))
            {
                if (graph != null && text != null)
                {
                    text.Append(" ").Append(BqlCommand.GetSingleField(typeof(Operand), graph, tables, selection));
                }

                if (fields != null)
                {
                    fields.Add(typeof(Operand));
                }
            }
            else
            {
                if (_operand == null)
                {
                    _operand = _operand.createOperand <Operand>();
                }
                _operand.Parse(graph, pars, tables, fields, sortColumns, text, selection);
            }
        }
コード例 #17
0
        public IsSchedulable()
        {
            Dictionary <string, Type> fields = typeof(TRegister)
                                               .GetNestedTypes()
                                               .ToDictionary(nestedTypes => nestedTypes.Name);

            Type releasedField          = fields[nameof(APRegister.released)];
            Type prebookedField         = fields[nameof(APRegister.prebooked)];
            Type holdField              = fields[nameof(APRegister.hold)];
            Type voidedField            = fields[nameof(APRegister.voided)];
            Type rejectedField          = fields[nameof(APRegister.rejected)];
            Type origModuleField        = fields[nameof(APRegister.origModule)];
            Type isMigratedRecordField  = fields[nameof(APRegister.isMigratedRecord)];
            Type createdByScreenIdField = fields[nameof(APRegister.createdByScreenID)];
            Type docTypeField           = fields[nameof(APRegister.docType)];
            Type refNbrField            = fields[nameof(APRegister.refNbr)];
            Type noteIdField            = fields[nameof(APRegister.noteID)];

            Type whereType = BqlCommand.Compose(
                typeof(Where <, ,>),
                releasedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), prebookedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), holdField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), voidedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), rejectedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), origModuleField, typeof(Equal <>), typeof(BatchModule.moduleAP),
                typeof(And <, ,>), isMigratedRecordField, typeof(Equal <>), typeof(False),
                typeof(And2 <,>), typeof(Not <>), typeof(IsPOLinked <,>), docTypeField, refNbrField,
                typeof(And <>), typeof(Not <>), typeof(ExistsJournalVoucher <>), noteIdField);

            where = Activator.CreateInstance(whereType) as IBqlUnary;
        }
コード例 #18
0
        private static Dictionary <string, string> GetFieldNamesAndValues(BqlCommand command)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            bool isFirstTable = true;
            PXUIFieldAttribute currentAttribute;
            string             currentValue;

            foreach (Type item in command.GetTables())
            {
                foreach (System.Reflection.PropertyInfo field in item.GetProperties())
                {
                    currentAttribute = Attribute.GetCustomAttribute(field,
                                                                    typeof(PXUIFieldAttribute), true) as PXUIFieldAttribute;
                    if (currentAttribute != null && currentAttribute.Filterable)
                    {
                        currentValue = string.Format(isFirstTable ? "{0}__{1}" : "{0}.{1}", item.Name, field.Name);
                        if (!string.IsNullOrEmpty(currentAttribute.DisplayName))
                        {
                            dic.Add(currentValue, currentAttribute.DisplayName);
                        }
                        else
                        {
                            dic.Add(currentValue, currentValue);
                        }
                    }
                }
                isFirstTable = false;
            }
            return(dic);
        }
コード例 #19
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();
            }
        }
コード例 #20
0
        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);
            }
        }
コード例 #21
0
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);


            if (MasterFinPeriodIDType != null)
            {
                sender.Graph.FieldDefaulting.AddHandler(sender.GetItemType(), MasterFinPeriodIDType.Name, MasterFinPeriodIDFieldDefaulting);
            }

            if (UseMasterCalendarSourceType != null)
            {
                if (OrganizationSourceType != null)
                {
                    sender.Graph.FieldUpdated.AddHandler(
                        BqlCommand.GetItemType(OrganizationSourceType),
                        OrganizationSourceType.Name,
                        CalendarOrganizationIDSourceFieldUpdated);
                }

                if (BranchSourceType != null)
                {
                    sender.Graph.FieldUpdated.AddHandler(
                        BqlCommand.GetItemType(BranchSourceType),
                        BranchSourceType.Name,
                        CalendarOrganizationIDSourceFieldUpdated);
                }
            }
        }
        /// <summary>
        /// Returns all searchable fields including dependent fields and key fields.
        /// Ex: Since Contact.DisplayName depends on FirstName, LastName, etc. all these fields will also be returned.
        /// </summary>
        /// <returns></returns>
        public ICollection <Type> GetSearchableFields(PXCache cache)
        {
            HashSet <Type> result = new HashSet <Type>();

            foreach (Type item in titleFields.Union(fields))
            {
                result.Add(item);

                foreach (Type dependable in PXDependsOnFieldsAttribute.GetDependsRecursive(cache, item.Name).Select(cache.GetBqlField))
                {
                    result.Add(dependable);
                }

                //Note: Keys can be removed once 43383 is resolved.
                Type dacType = BqlCommand.GetItemType(item);
                foreach (Type key in cache.Graph.Caches[dacType].BqlKeys)
                {
                    result.Add(key);
                }
            }

            if (WhereConstraint != null)
            {
                foreach (Type type in BqlCommand.Decompose(WhereConstraint))
                {
                    if ((typeof(IBqlField)).IsAssignableFrom(type))
                    {
                        result.Add(type);
                    }
                }
            }

            return(result);
        }
コード例 #23
0
        public ContractAttribute(Type WhereType)
        {
            Type SearchType =
                BqlCommand.Compose(
                    typeof(Search2 <, , ,>),
                    typeof(Contract.contractID),
                    typeof(InnerJoin <ContractBillingSchedule, On <ContractBillingSchedule.contractID, Equal <Contract.contractID> > >),
                    typeof(Where <, ,>),
                    typeof(Contract.isTemplate),
                    typeof(Equal <boolFalse>),
                    typeof(And <, ,>),
                    typeof(Contract.baseType),
                    typeof(Equal <>),
                    typeof(Contract.ContractBaseType),
                    typeof(And <>),
                    WhereType,
                    typeof(OrderBy <Desc <Contract.contractCD> >));

            PXDimensionSelectorAttribute select = new PXDimensionSelectorAttribute(DimensionName, SearchType, typeof(Contract.contractCD),
                                                                                   typeof(Contract.contractCD), typeof(Contract.customerID), typeof(Contract.locationID), typeof(Contract.description), typeof(Contract.status), typeof(Contract.expireDate), typeof(ContractBillingSchedule.lastDate), typeof(ContractBillingSchedule.nextDate));

            select.DescriptionField = typeof(Contract.description);
            _Attributes.Add(select);
            _SelAttrIndex = _Attributes.Count - 1;
        }
コード例 #24
0
ファイル: SOCreate.cs プロジェクト: PavelMPD/SimpleProjects
 public SOCreateProjectionAttribute()
     : base(typeof(SOCreateFilter),
            BqlCommand.Compose(
                typeof(Select2 <, ,>),
                typeof(INItemPlan),
                typeof(InnerJoin <INPlanType,
                                  On <INPlanType.planType, Equal <INItemPlan.planType> >,
                                  InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <INItemPlan.inventoryID> >,
                                             InnerJoin <INUnit,
                                                        On <INUnit.inventoryID, Equal <InventoryItem.inventoryID>,
                                                            And <INUnit.fromUnit, Equal <InventoryItem.purchaseUnit>,
                                                                 And <INUnit.toUnit, Equal <InventoryItem.baseUnit> > > >,
                                                        LeftJoin <IN.S.INItemSite, On <IN.S.INItemSite.inventoryID, Equal <INItemPlan.inventoryID>, And <IN.S.INItemSite.siteID, Equal <INItemPlan.siteID> > > > > > >),
                typeof(Where2 <,>),
                typeof(Where <INItemPlan.hold, Equal <boolFalse>,
                              And <INItemPlan.fixedSource, Equal <INReplenishmentSource.transfer>,
                                   And <Where <INItemPlan.supplyPlanID, IsNull,
                                               Or <INItemPlan.planType, Equal <INPlanConstants.plan6B>,
                                                   Or <INItemPlan.planType, Equal <INPlanConstants.plan6E> > > > > > >),
                typeof(And <>),
                TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                    typeof(SOCreateFilter),
                    typeof(InventoryItem.productWorkgroupID),
                    typeof(InventoryItem.productManagerID))))
 {
 }
コード例 #25
0
        protected virtual void BatchSelection_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            BatchSelection batch = e.Row as BatchSelection;

            if (batch != null &&
                !string.IsNullOrWhiteSpace(batch.Module) &&
                !string.IsNullOrWhiteSpace(batch.BatchNbr))
            {
                batch = PXSelectReadonly <
                    BatchSelection,
                    Where <
                        BatchSelection.module, Equal <Required <BatchSelection.module> >,
                        And <BatchSelection.batchNbr, Equal <Required <BatchSelection.batchNbr> > > > >
                        .Select(this, batch.Module, batch.BatchNbr);

                PXSelectorAttribute selectorAttr = (PXSelectorAttribute)sender.GetAttributesReadonly <BatchSelection.batchNbr>(batch).FirstOrDefault(
                    (PXEventSubscriberAttribute attr) => { return(attr is PXSelectorAttribute); });

                BqlCommand selectorSearch = selectorAttr.GetSelect();

                if (batch != null && selectorSearch.Meet(sender, batch))
                {
                    Batch_Detail.Delete(batch);
                    Batch_Detail.Update(batch);
                }
                else
                {
                    batch = (BatchSelection)e.Row;
                    sender.RaiseExceptionHandling <BatchSelection.batchNbr>(batch, batch.BatchNbr, new PXSetPropertyException(Messages.BatchNbrNotValid));
                    Batch_Detail.Delete(batch);
                }
            }
        }
コード例 #26
0
        private static Type getAPDocumentSelect(bool groupBy = false)
        {
            Type selType = typeof(Select2 <, ,>);

            if (groupBy)
            {
                selType = typeof(Select5 <, , ,>);
            }

            Type table = typeof(APInvoice);

            Type join = typeof(InnerJoin <Vendor, On <Vendor.bAccountID, Equal <APInvoice.vendorID> >,
                                          InnerJoin <CurrencyInfo,
                                                     On <CurrencyInfo.curyInfoID, Equal <APInvoice.curyInfoID> >,
                                                     LeftJoin <APAdjust, On <APAdjust.adjdDocType, Equal <APInvoice.docType>,
                                                                             And <APAdjust.adjdRefNbr, Equal <APInvoice.refNbr>,
                                                                                  And <APAdjust.released, Equal <False> > > >,
                                                               LeftJoin <APPayment, On <APPayment.docType, Equal <APInvoice.docType>,
                                                                                        And <APPayment.refNbr, Equal <APInvoice.refNbr>,
                                                                                             And <Where <APPayment.docType, Equal <APDocType.prepayment>, Or <APPayment.docType, Equal <APDocType.debitAdj> > > > > > > > > >);

            Type where = typeof(Where <APInvoice.openDoc, Equal <True>,
                                       And2 <Where <APInvoice.released, Equal <True>, Or <APInvoice.prebooked, Equal <True> > >,
                                             And <APAdjust.adjgRefNbr, IsNull,
                                                  And <APPayment.refNbr, IsNull,
                                                       And2 <Match <Vendor, Current <AccessInfo.userName> >,
                                                             And2 <Where <APInvoice.curyID, Equal <Current <ApproveBillsFilter.curyID> >,
                                                                          Or <Current <ApproveBillsFilter.curyID>, IsNull> >,
                                                                   And2 <Where2 <Where <Current <ApproveBillsFilter.showApprovedForPayment>, Equal <True>,
                                                                                        And <APInvoice.paySel, Equal <True> > >,
                                                                                 Or <Where <Current <ApproveBillsFilter.showNotApprovedForPayment>, Equal <True>,
                                                                                            And <APInvoice.paySel, Equal <False> > > > >,
                                                                         And2 <Where <Vendor.bAccountID, Equal <Current <ApproveBillsFilter.vendorID> >,
                                                                                      Or <Current <ApproveBillsFilter.vendorID>, IsNull> >,
                                                                               And2 <Where <Vendor.vendorClassID, Equal <Current <ApproveBillsFilter.vendorClassID> >,
                                                                                            Or <Current <ApproveBillsFilter.vendorClassID>, IsNull> >,
                                                                                     And <Where2 <Where2 <Where <Current <ApproveBillsFilter.showPayInLessThan>, Equal <True>, And <APInvoice.payDate, LessEqual <Required <APInvoice.payDate> > > >,
                                                                                                          Or2 <Where <Current <ApproveBillsFilter.showDueInLessThan>, Equal <True>,
                                                                                                                      And <APInvoice.dueDate, LessEqual <Required <APInvoice.dueDate> > > >,
                                                                                                               Or <Where <Current <ApproveBillsFilter.showDiscountExpiresInLessThan>, Equal <True>,
                                                                                                                          And <APInvoice.discDate, LessEqual <Required <APInvoice.discDate> > > > > > >,
                                                                                                  Or <Where <Current <ApproveBillsFilter.showPayInLessThan>, Equal <False>,
                                                                                                             And <Current <ApproveBillsFilter.showDueInLessThan>, Equal <False>,
                                                                                                                  And <Current <ApproveBillsFilter.showDiscountExpiresInLessThan>, Equal <False> > > > > > > > > > > > > > > >);

            Type aggr = typeof(Aggregate <
                                   GroupBy <APInvoice.paySel,
                                            Sum <APInvoice.docBal,
                                                 Sum <APInvoice.curyDocBal> > > >);

            if (groupBy)
            {
                return(BqlCommand.Compose(selType, table, join, where, aggr));
            }
            else
            {
                return(BqlCommand.Compose(selType, table, join, where));
            }
        }
コード例 #27
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;
            }
        }
コード例 #28
0
        public virtual bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
        {
            bool status = true;

            if (info.Fields is BqlCommand.EqualityList list)
            {
                list.NonStrict = true;
            }

            SQLExpression opUser = null;

            if (!typeof(IBqlCreator).IsAssignableFrom(typeof(OperandUser)))
            {
                if (info.BuildExpression)
                {
                    opUser = BqlCommand.GetSingleExpression(typeof(OperandUser), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition);
                }
                info.Fields?.Add(typeof(OperandUser));
            }
            else
            {
                if (_operandUser == null)
                {
                    _operandUser = _operandUser.createOperand <OperandUser>();
                }
                status &= _operandUser.AppendExpression(ref opUser, graph, info, selection);
            }

            Query qin = new Query();

            qin[typeof(EPCompanyTreeH.workGroupID)].From(typeof(EPCompanyTreeH))
            .Join(typeof(EPCompanyTreeMember))
            .On(SQLExpression.EQ(typeof(EPCompanyTreeH.parentWGID), typeof(EPCompanyTreeMember.workGroupID))
                //.And(Column.SQLColumn(typeof(EPCompanyTreeH.parentWGID)).NotEqual(Column.SQLColumn(typeof(EPCompanyTreeH.workGroupID)))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.active)).EQ(1))
                .And(Column.SQLColumn(typeof(EPCompanyTreeMember.userID)).EQ(opUser)))
            //)
            .Where(new SQLConst(1).EQ(1));

            Query qout = new Query();

            //Append Tail removes main object, so we fieldNote will not be mapped. Skipping conditions for AppendTail
            if (info.Tables == null || info.Tables.Count <= 0 || info.Tables.Contains(BqlCommand.GetItemType <FieldNote>()))
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin)
                       .And(SQLExpression.EQ(typeof(EntityWorkgroup.refNoteID), typeof(FieldNote))));
            }
            else
            {
                qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup))
                .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin));
            }

            qout.Limit(-1);             // prevent limiting of IN subqueries
            exp = exp.In(qout);

            return(status);
        }
コード例 #29
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));
        }
コード例 #30
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)));
        }
コード例 #31
0
			internal DummyView(PXGraph graph, BqlCommand command, List<object> records)
				: base(graph, true, command)
			{
				_Records = records;
			}
コード例 #32
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>>>>));
			}