コード例 #1
0
        private IEnumerable getTemplates <TTemplate>(PXSelectBase <TTemplate> select)
            where TTemplate : CRFilterTemplate, new()
        {
            Hashtable hashTable = new Hashtable();

            foreach (TTemplate item in select.Cache.Updated)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            foreach (TTemplate item in select.Cache.Inserted)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            PXView view = new PXView(this, true, select.View.BqlSelect);

            foreach (TTemplate item in view.SelectMulti(graphTypeName, PXAccess.GetUserID()))
            {
                if (!hashTable.Contains(item.FilterTemplateID))
                {
                    yield return(item);
                }
            }
            if (hashTable.Count < 1)
            {
                select.Cache.IsDirty = false;
            }
        }
コード例 #2
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;
        }
コード例 #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());
                }
            }
        protected IEnumerable <TRefItem> RefItemsForAction(TInstance leaveInstance, ICollection <TInstance> deletingInstances, bool forDeleting)
        {
            // Constraint
            if (deletingInstances.Count < 1)
            {
                yield break;
            }

            // Compose command
            BqlCommand command = GetCommand(leaveInstance, deletingInstances, forDeleting);

            if (command == null)
            {
                yield break;
            }

            // Compose parameters
            object[] deletingIDs = GetInstancesKeys(leaveInstance, deletingInstances, forDeleting);

            // Select
            PXView view = new PXView(Graph, false, command);

            foreach (object item in view.SelectMulti(deletingIDs))
            {
                PXResult record = item as PXResult;
                if (record != null)
                {
                    yield return(record[typeof(TRefItem)] as TRefItem);
                }
                else
                {
                    yield return(item as TRefItem);
                }
            }
        }
コード例 #5
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());
        }
        private bool ValidateDuplicateMap <BranchField>(PXCache sender, PXView view, object row, object oldrow)
            where BranchField : IBqlField
        {
            int?   branch   = (int?)sender.GetValue <BranchField>(row);
            string fromMask = (string)sender.GetValue <BranchAcctMap.fromAccountCD>(row);
            string toMask   = (string)sender.GetValue <BranchAcctMap.toAccountCD>(row);

            if (string.IsNullOrEmpty(fromMask) || string.IsNullOrEmpty(toMask))
            {
                return(false);
            }

            PXSetPropertyException ex = null;

            if (string.Compare(fromMask, toMask, true) > 0)
            {
                ex = new PXSetPropertyException(Messages.MapAccountError);
            }

            if (ex == null)
            {
                foreach (var item in view.SelectMulti())
                {
                    if (item == row || item == oldrow)
                    {
                        continue;
                    }
                    int?itemBranch = (int?)sender.GetValue <BranchField>(item);
                    if (branch == itemBranch)
                    { // same branch
                        string itemFromMask = (string)sender.GetValue <BranchAcctMap.fromAccountCD>(item);
                        string itemToMask   = (string)sender.GetValue <BranchAcctMap.toAccountCD>(item);
                        if (string.Compare(fromMask, itemToMask, true) < 0 &&
                            string.Compare(itemFromMask, toMask, true) < 0)
                        {
                            ex = new PXSetPropertyException(Messages.MapAccountDuplicate);
                            break;
                        }
                    }
                }
            }

            if (ex != null)
            {
                if (!sender.ObjectsEqual <BranchAcctMapFrom.toAccountCD>(row, oldrow) || (oldrow == null && sender.GetValue <BranchAcctMap.toAccountCD>(row) != null))
                {
                    sender.RaiseExceptionHandling <BranchAcctMapFrom.toAccountCD>(row,
                                                                                  sender.GetValue <BranchAcctMap.toAccountCD>(
                                                                                      row), ex);
                }
                else
                {
                    sender.RaiseExceptionHandling <BranchAcctMapFrom.fromAccountCD>(row,
                                                                                    sender.GetValue <BranchAcctMap.fromAccountCD>(
                                                                                        row), ex);
                }
            }
            return(ex == null);
        }
コード例 #7
0
        public IEnumerable GetRecords()
        {
            BqlCommand command = BqlCommand.CreateInstance(search);
            PXView     view    = new PXView(_Graph, false, command);

            foreach (object obj in view.SelectMulti())
            {
                CCProcessingCenter procCenter = PXResult.Unwrap <CCProcessingCenter>(obj);
                if (CheckPluginType(procCenter))
                {
                    yield return(obj);
                }
            }
        }
コード例 #8
0
        private void ResetQtyOnFreeItem(PXGraph graph, Detail line)
        {
            PXView  view     = new PXView(graph, false, Discounts.View.BqlSelect.WhereAnd <Where <Discount.freeItemID, Equal <Required <Discount.freeItemID> > > >());
            decimal?qtyTotal = 0;

            foreach (IDiscountDetail item in view.SelectMulti(line.InventoryID))
            {
                if (item.SkipDiscount != true && item.FreeItemID != null && item.FreeItemQty != null && item.FreeItemQty.Value > 0)
                {
                    qtyTotal += item.FreeItemQty.Value;
                }
            }

            Details.Cache.SetValueExt <Detail.quantity>(line, qtyTotal);
        }
コード例 #9
0
        protected virtual IEnumerable duplicates()
        {
            var currentSetup = Base.Caches[typeof(CRSetup)].Current as CRSetup;

            if (currentSetup == null)
            {
                yield break;
            }

            var possibleDuplicates = dbView.SelectMulti();

            foreach (PXResult rec in possibleDuplicates)
            {
                CRGrams           gram             = rec.GetItem <CRGrams>();
                CRDuplicateGrams  duplicateGram    = rec.GetItem <CRDuplicateGrams>();
                DuplicateContact  duplicateContact = rec.GetItem <DuplicateContact>();
                Standalone.CRLead duplicateLead    = rec.GetItem <Standalone.CRLead>();

                var dupRecord = new CRDuplicateRecord()
                {
                    ContactID          = gram.EntityID,
                    ValidationType     = gram.ValidationType,
                    DuplicateContactID = duplicateGram.EntityID,
                    Score = gram.Score,
                    DuplicateContactType  = duplicateContact?.ContactType,
                    DuplicateBAccountID   = duplicateContact?.BAccountID,
                    DuplicateRefContactID = duplicateLead?.RefContactID,
                };

                CRDuplicateRecord cached = (CRDuplicateRecord)Base.Caches[typeof(CRDuplicateRecord)].Locate(dupRecord);
                if (cached == null)
                {
                    Base.Caches[typeof(CRDuplicateRecord)].Hold(dupRecord);

                    dupRecord.Selected = false;
                }
                else
                {
                    dupRecord.Selected = cached.Selected;
                }

                yield return(new PXResult <CRDuplicateRecord, Contact, DuplicateContact, BAccountR>(
                                 dupRecord,
                                 rec.GetItem <Contact>(),
                                 duplicateContact,
                                 rec.GetItem <BAccountR>()));
            }
        }
コード例 #10
0
        public virtual IEnumerable ardocumentlist(PXAdapter adapter)
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(PrintInvoicesFilter),
                typeof(ARInvoice.workgroupID),
                typeof(ARInvoice.ownerID));

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


            string onlyNotPrinted = (string)ARDocumentList.GetTargetFill(null, null, null, Filter.Current.Action, "@OnlyNotPrinted");
            string onlyNotEmailed = (string)ARDocumentList.GetTargetFill(null, null, null, Filter.Current.Action, "@OnlyNotEmailed");

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

            if (onlyNotEmailed != null)
            {
                whereAnd = emailWhere;
            }

            if (onlyNotPrinted != null)
            {
                whereAnd = printWhere;
            }

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(ARInvoice),
                    typeof(InnerJoin <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> > >),
                    typeof(Where <>), whereAnd);

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

            return(view.SelectMulti());
        }
コード例 #11
0
    //Return the records
    public IEnumerable GetRecords()
    {
        var selectedField = GetSelectedTableField(GetSelection());
        var selectedTable = BqlCommand.GetItemType(selectedField.Id);

        var select = BqlCommand.Compose(
            typeof(Select <>),
            selectedTable
            );

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

        foreach (var row in view.SelectMulti())
        {
            var id          = (int?)view.Cache.GetValue(row, selectedField.Id.Name);
            var description = view.Cache.GetValue(row, selectedField.Description.Name)?.ToString();
            yield return(new TableDummy {
                Id = id, Description = description
            });
        }
    }
コード例 #12
0
ファイル: Attributes.cs プロジェクト: Vialythen/AcumaticaTest
        public IEnumerable GetRecords()
        {
            PXCache sourceCache   = _Graph.Caches[SourceEntityID.DeclaringType];
            var     currentEntity = PXView.Currents?.FirstOrDefault() ?? sourceCache.Current;

            if (currentEntity == null)
            {
                yield break;
            }

            int?currentID = (int?)sourceCache.GetValue(currentEntity, SourceEntityID.Name);

            foreach (PXResult rec in View.SelectMulti(currentID))
            {
                CRGrams          gram             = rec.GetItem <CRGrams>();
                CRDuplicateGrams duplicateGram    = rec.GetItem <CRDuplicateGrams>();
                BAccountR        duplicateAccount = rec.GetItem <BAccountR>();
                CRLead           duplicateLead    = rec.GetItem <CRLead>();

                var dupRecord = new CRDuplicateRecord()
                {
                    ContactID          = gram.EntityID,
                    ValidationType     = gram.ValidationType,
                    DuplicateContactID = duplicateGram.EntityID,
                    Score = gram.Score,
                    DuplicateContactType  = ContactTypesAttribute.BAccountProperty,
                    DuplicateBAccountID   = duplicateAccount?.BAccountID,
                    DuplicateRefContactID = duplicateLead?.RefContactID,
                };

                CRDuplicateRecord cached = (CRDuplicateRecord)_Graph.Caches[typeof(CRDuplicateRecord)].Locate(dupRecord);

                if (cached?.Selected == true || duplicateAccount.DefContactID == currentID)
                {
                    yield return(duplicateAccount);
                }
            }
        }
コード例 #13
0
        public IEnumerable <IPeriodSetup> FindFABookPeriodSetup(FABook book, bool clearQueryCache = false)
        {
            BqlCommand selectCommand;

            if (book.UpdateGL == true)
            {
                selectCommand = new Select3 <FinPeriodSetup, OrderBy <Asc <FinPeriodSetup.periodNbr> > >();
            }
            else
            {
                selectCommand = new Select <
                    FABookPeriodSetup,
                    Where <FABookPeriodSetup.bookID, Equal <Required <FABook.bookID> > >,
                    OrderBy <Asc <FABookPeriodSetup.periodNbr> > >();
            }
            PXView view = new PXView(Graph, true, selectCommand);

            if (clearQueryCache)
            {
                view.Clear();
            }
            return(view.SelectMulti(book.BookID).Cast <IPeriodSetup>());
        }
コード例 #14
0
        public static void BuildIndex(FullTextIndexRebuildProc graph, RecordType item)
        {
            Debug.Print("Start processing {0}", item.Name);
            Stopwatch sw = new Stopwatch();

            graph.Caches.Clear();
            graph.Clear(PXClearOption.ClearAll);

            PXProcessing <RecordType> .SetCurrentItem(item);

            Type entity = GraphHelper.GetType(item.Entity);

            PXSearchableAttribute searchableAttribute = null;
            var list = graph.Caches[entity].GetAttributes("NoteID");

            foreach (PXEventSubscriberAttribute att in list)
            {
                PXSearchableAttribute attribute = att as PXSearchableAttribute;
                if (attribute != null)
                {
                    searchableAttribute = attribute;
                    break;
                }
            }

            if (searchableAttribute == null)
            {
                return;
            }

            Type viewType;


            Type joinNote = typeof(LeftJoin <Note, On <Note.noteID, Equal <SearchIndex.noteID> > >);

            if (searchableAttribute.SelectForFastIndexing != null)
            {
                Type noteentity = entity;
                if (searchableAttribute.SelectForFastIndexing.IsGenericType)
                {
                    Type[] tables = searchableAttribute.SelectForFastIndexing.GetGenericArguments();
                    if (tables != null && tables.Length > 0 && typeof(IBqlTable).IsAssignableFrom(tables[0]))
                    {
                        noteentity = tables[0];
                    }
                }
                Type joinSearchIndex = BqlCommand.Compose(
                    typeof(LeftJoin <,>),
                    typeof(SearchIndex),
                    typeof(On <,>),
                    typeof(SearchIndex.noteID),
                    typeof(Equal <>),
                    noteentity.GetNestedType("noteID"));

                viewType = BqlCommand.AppendJoin(searchableAttribute.SelectForFastIndexing, joinSearchIndex);
                viewType = BqlCommand.AppendJoin(viewType, joinNote);
            }
            else
            {
                Type joinSearchIndex = BqlCommand.Compose(
                    typeof(LeftJoin <,>),
                    typeof(SearchIndex),
                    typeof(On <,>),
                    typeof(SearchIndex.noteID),
                    typeof(Equal <>),
                    entity.GetNestedType("noteID"));

                viewType = BqlCommand.Compose(typeof(Select <>), entity);
                viewType = BqlCommand.AppendJoin(viewType, joinSearchIndex);
                viewType = BqlCommand.AppendJoin(viewType, joinNote);
            }

            BqlCommand cmd = BqlCommand.CreateInstance(viewType);

            PXView        itemView = new PXView(graph, true, cmd);
            List <object> resultset;

            List <Type> fieldList       = new List <Type>(searchableAttribute.GetSearchableFields(graph.Caches[entity]));
            Type        entityForNoteId = entity;

            while (typeof(IBqlTable).IsAssignableFrom(entityForNoteId))
            {
                Type tN = entityForNoteId.GetNestedType("noteID");
                if (null != tN)
                {
                    fieldList.Add(tN);
                }
                entityForNoteId = entityForNoteId.BaseType;
            }
            fieldList.Add(typeof(SearchIndex.noteID));
            fieldList.Add(typeof(SearchIndex.category));
            fieldList.Add(typeof(SearchIndex.content));
            fieldList.Add(typeof(SearchIndex.entityType));
            fieldList.Add(typeof(Note.noteID));
            fieldList.Add(typeof(Note.noteText));

            sw.Start();
            using (new PXFieldScope(itemView, fieldList))
            {
                resultset = itemView.SelectMulti();
            }
            sw.Stop();
            Debug.Print("{0} GetResultset in {1} sec. Total records={2}", item.DisplayName, sw.Elapsed.TotalSeconds, resultset.Count);
            sw.Reset();
            sw.Start();

            int totalcount = resultset.Count;
            int cx         = 0;
            int dx         = 0;

            try
            {
                Dictionary <Guid, SearchIndex> insertDict = new Dictionary <Guid, SearchIndex>(resultset.Count);
                foreach (var res in resultset)
                {
                    cx++;

                    bool isSearchable = searchableAttribute.IsSearchable(graph.Caches[entity], ((PXResult)res)[entity]);
                    if (isSearchable)
                    {
                        dx++;

                        Note        note = (Note)((PXResult)res)[typeof(Note)];
                        SearchIndex si   = searchableAttribute.BuildSearchIndex(graph.Caches[entity], ((PXResult)res)[entity],
                                                                                (PXResult)res, ExtractNoteText(note));
                        SearchIndex searchIndex = (SearchIndex)((PXResult)res)[typeof(SearchIndex)];

                        if (searchIndex.NoteID != null && searchIndex.NoteID != si.NoteID)
                        {
                            PXSearchableAttribute.Delete(si);
                        }

                        if (searchIndex.NoteID == null)
                        {
                            if (!insertDict.ContainsKey(si.NoteID.Value))
                            {
                                insertDict.Add(si.NoteID.Value, si);
                            }
                        }
                        else if (si.Content != searchIndex.Content || si.Category != searchIndex.Category ||
                                 si.EntityType != searchIndex.EntityType)
                        {
                            PXSearchableAttribute.Update(si);
                        }
                    }
                }
                sw.Stop();
                Debug.Print("{0} Content building in {1} sec. Records processed = {2}. Searchable={3}", item.DisplayName, sw.Elapsed.TotalSeconds, totalcount, dx);
                sw.Reset();
                sw.Start();
                PXSearchableAttribute.BulkInsert(insertDict.Values);
                sw.Stop();
                Debug.Print("{0} BulkInsert in {1} sec.", item.DisplayName, sw.Elapsed.TotalSeconds);
            }
            catch (Exception ex)
            {
                string msg = string.Format("{0} out of {1} processed. {2} are searchable. Error:{3}", cx, totalcount, dx, ex.Message);
                throw new Exception(msg, ex);
            }

            PXProcessing <RecordType> .SetProcessed();
        }
コード例 #15
0
        private static void ProcessValidation(ValidationFilter filter, Contact record)
        {
            BusinessAccountMaint graph = PXGraph.CreateInstance <BusinessAccountMaint>();
            PXView view = graph.BAccount.View;

            int startRow = 0, totalRows = 0;

            BAccount baccount = null;
            Contact  contact  = null;

            if (record.ContactType == ContactTypesAttribute.BAccountProperty && record.BAccountID != null)
            {
                List <object> list_baccount = view.Select(null, null, new object[] { record.BAccountID }, new string[] { typeof(BAccount.bAccountID).Name }, null, null,
                                                          ref startRow, 1, ref totalRows);
                if (list_baccount != null && list_baccount.Count >= 1)
                {
                    baccount = PXResult.Unwrap <BAccount>(list_baccount[0]);
                }
            }
            if (baccount == null || baccount.DefContactID != record.ContactID)
            {
                throw new PXException(Messages.ContactNotFound);
            }

            contact = graph.DefContact.Current = graph.DefContact.SelectWindowed(0, 1);
            contact.DuplicateFound = true;

            PXView viewDuplicates = graph.Duplicates.View;

            if (viewDuplicates == null)
            {
                throw new PXException(Messages.DuplicateViewNotFound);
            }
            viewDuplicates.Clear();
            List <object> duplicates = viewDuplicates.SelectMulti();

            contact = (Contact)graph.DefContact.Cache.CreateCopy(contact);
            contact.DuplicateStatus = DuplicateStatusAttribute.Validated;
            Decimal?score = 0;

            foreach (PXResult <CRDuplicateRecord, Contact, CRLeadContactValidationProcess.Contact2> r in duplicates)
            {
                CRLeadContactValidationProcess.Contact2 duplicate = r;
                CRDuplicateRecord contactScore = r;

                int duplicateWeight = ContactMaint.GetContactWeight(duplicate);
                int currentWeight   = ContactMaint.GetContactWeight(contact);
                if (duplicateWeight > currentWeight ||
                    (duplicateWeight == currentWeight &&
                     duplicate.ContactID < contact.ContactID))
                {
                    contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated;
                    if (contactScore.Score > score)
                    {
                        score = contactScore.Score;
                    }
                }
            }
            graph.DefContact.Cache.Update(contact);
            graph.DefContact.Cache.RestoreCopy(record, contact);
            graph.Actions.PressSave();
        }
コード例 #16
0
        public decimal AllocateOverRCTLine(List <POReceiptLineAdjustment> result, POReceiptLine aLine, decimal toDistribute, Int32?branchID)
        {
            var aLCCode = new LandedCostCode();

            aLCCode.AllocationMethod = LandedCostAllocationMethod.ByQuantity;
            decimal baseTotal = GetBaseValue(aLCCode, aLine);

            decimal shareAmt      = Decimal.Zero;
            decimal allocatedAmt  = Decimal.Zero;
            decimal allocatedBase = Decimal.Zero;

            List <Type> bql = new List <Type>
            {
                typeof(Select4 <, ,>),
                typeof(POReceiptLineSplit),
                typeof(Where <POReceiptLineSplit.receiptNbr, Equal <Required <POReceiptLine.receiptNbr> >, And <POReceiptLineSplit.lineNbr, Equal <Required <POReceiptLine.lineNbr> > > >),
                typeof(Aggregate <>),
                typeof(GroupBy <,>),
                typeof(POReceiptLineSplit.locationID),
                typeof(GroupBy <,>),
                typeof(POReceiptLineSplit.subItemID),
                typeof(Sum <,>),
                typeof(POReceiptLineSplit.baseQty),
                typeof(GroupBy <>),
                typeof(POReceiptLineSplit.lotSerialNbr)
            };

            InventoryItem ii = (InventoryItem)PXSelectorAttribute.Select <POReceiptLine.inventoryID>(_graph.Caches[typeof(POReceiptLine)], aLine);
            bool          requierelotserial = ii.ValMethod == INValMethod.Specific;

            if (!requierelotserial)
            {
                bql.RemoveAt(bql.Count - 1);
                bql.RemoveAt(bql.Count - 1);
                bql[bql.Count - 2] = typeof(Sum <>);
            }

            PXView splitsView = new PXView(_graph, false, BqlCommand.CreateInstance(bql.ToArray()));

            bool hasSplits = false;

            foreach (POReceiptLineSplit split in splitsView.SelectMulti(aLine.ReceiptNbr, aLine.LineNbr))
            {
                hasSplits = true;
                decimal allocatingBase = split.BaseQty ?? 0m;
                shareAmt = CalcAllocationValue(aLCCode, split, aLine, baseTotal, toDistribute);
                shareAmt = PXDBCurrencyAttribute.BaseRound(_graph, shareAmt);

                //accu rounding
                shareAmt += PXCurrencyAttribute.BaseRound(_graph, (allocatedBase + allocatingBase) * toDistribute / baseTotal - shareAmt - allocatedAmt);

                if (shareAmt != Decimal.Zero)
                {
                    POReceiptLine newPOReceiptLine = (POReceiptLine)_graph.Caches[typeof(POReceiptLine)].CreateCopy(aLine);
                    newPOReceiptLine.LocationID   = split.LocationID;
                    newPOReceiptLine.SiteID       = split.SiteID;
                    newPOReceiptLine.SubItemID    = split.SubItemID;
                    newPOReceiptLine.LotSerialNbr = requierelotserial ? split.LotSerialNbr : null;
                    result.Add(new POReceiptLineAdjustment(newPOReceiptLine, shareAmt, branchID));
                    allocatedAmt  += shareAmt;
                    allocatedBase += allocatingBase;
                }
            }
            if (!hasSplits)
            {
                shareAmt = toDistribute;
                shareAmt = PXDBCurrencyAttribute.BaseRound(_graph, shareAmt);
                if (shareAmt != Decimal.Zero)
                {
                    result.Add(new POReceiptLineAdjustment(aLine, shareAmt, branchID));
                }

                allocatedAmt = shareAmt;
            }
            return(allocatedAmt);
        }
        public virtual IEnumerable weekCodeDateRecords()
        {
            FSRouteContractSchedule fsRouteContractScheduleRow = ContractScheduleRecords.Current;
            List <object>           returnList   = new List <object>();
            List <object>           weekCodeArgs = new List <object>();
            List <int> dayOfWeekDays             = new List <int>();

            BqlCommand commandFilter = new Select <FSWeekCodeDate>();

            Regex rgxP1 = new Regex(@"^[1-4]$");
            Regex rgxP2 = new Regex(@"^[a-bA-B]$");
            Regex rgxP3 = new Regex(@"^[c-fC-F]$");
            Regex rgxP4 = new Regex(@"^[s-zS-Z]$");

            if (fsRouteContractScheduleRow != null && string.IsNullOrEmpty(fsRouteContractScheduleRow.WeekCode) == false)
            {
                List <string> weekcodes = SharedFunctions.SplitWeekcodeByComma(fsRouteContractScheduleRow.WeekCode);

                foreach (string weekcode in weekcodes)
                {
                    List <string> charsInWeekCode = SharedFunctions.SplitWeekcodeInChars(weekcode);
                    string        p1, p2, p3, p4;
                    p1 = p2 = p3 = p4 = "%";

                    foreach (string letter in charsInWeekCode)
                    {
                        string letterAux = letter.ToUpper();

                        if (rgxP1.IsMatch(letterAux))
                        {
                            p1 = letterAux;
                        }
                        else if (rgxP2.IsMatch(letterAux))
                        {
                            p2 = letterAux;
                        }
                        else if (rgxP3.IsMatch(letterAux))
                        {
                            p3 = letterAux;
                        }
                        else if (rgxP4.IsMatch(letterAux))
                        {
                            p4 = letterAux;
                        }
                    }

                    commandFilter = commandFilter.WhereOr(typeof(
                                                              Where2 <
                                                                  Where <
                                                                      FSWeekCodeDate.weekCodeP1, Like <Required <FSWeekCodeDate.weekCodeP1> >,
                                                                      Or <FSWeekCodeDate.weekCodeP1, Like <Required <FSWeekCodeDate.weekCodeP1> >,
                                                                          Or <FSWeekCodeDate.weekCodeP1, IsNull> > >,
                                                                  And2 <
                                                                      Where <
                                                                          FSWeekCodeDate.weekCodeP2, Like <Required <FSWeekCodeDate.weekCodeP2> >,
                                                                          Or <FSWeekCodeDate.weekCodeP2, Like <Required <FSWeekCodeDate.weekCodeP2> >,
                                                                              Or <FSWeekCodeDate.weekCodeP2, IsNull> > >,
                                                                      And2 <
                                                                          Where <
                                                                              FSWeekCodeDate.weekCodeP3, Like <Required <FSWeekCodeDate.weekCodeP3> >,
                                                                              Or <FSWeekCodeDate.weekCodeP3, Like <Required <FSWeekCodeDate.weekCodeP3> >,
                                                                                  Or <FSWeekCodeDate.weekCodeP3, IsNull> > >,
                                                                          And <
                                                                              Where <
                                                                                  FSWeekCodeDate.weekCodeP4, Like <Required <FSWeekCodeDate.weekCodeP4> >,
                                                                                  Or <FSWeekCodeDate.weekCodeP4, Like <Required <FSWeekCodeDate.weekCodeP4> >,
                                                                                      Or <FSWeekCodeDate.weekCodeP4, IsNull> > > > > > >));

                    weekCodeArgs.Add(p1);
                    weekCodeArgs.Add(p1.ToLower());
                    weekCodeArgs.Add(p2);
                    weekCodeArgs.Add(p2.ToLower());
                    weekCodeArgs.Add(p3);
                    weekCodeArgs.Add(p3.ToLower());
                    weekCodeArgs.Add(p4);
                    weekCodeArgs.Add(p4.ToLower());
                }

                WeekCodeFilter filter = WeekCodeFilter.Current;

                if (filter != null)
                {
                    DateTime?dateBegin = filter.DateBegin;
                    DateTime?dateEnd   = null;

                    if (filter.DateEnd.HasValue)
                    {
                        dateEnd = filter.DateEnd;
                    }

                    if (dateBegin.HasValue == true && dateEnd.HasValue == false)
                    {
                        dateEnd = filter.DateEnd.HasValue ? filter.DateEnd : dateBegin.Value.AddYears(1);
                    }

                    if (dateBegin != null)
                    {
                        commandFilter = commandFilter.WhereAnd(typeof(Where <FSWeekCodeDate.weekCodeDate, GreaterEqual <Required <WeekCodeFilter.dateBegin> > >));
                        weekCodeArgs.Add(dateBegin);
                    }

                    if (dateEnd != null)
                    {
                        commandFilter = commandFilter.WhereAnd(typeof(Where <FSWeekCodeDate.weekCodeDate, LessEqual <Required <WeekCodeFilter.dateEnd> > >));
                        weekCodeArgs.Add(dateEnd);
                    }
                }

                if (fsRouteContractScheduleRow.FrequencyType == ID.Schedule_FrequencyType.WEEKLY)
                {
                    if (fsRouteContractScheduleRow.WeeklyOnSun == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.SUNDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnMon == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.MONDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnTue == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.TUESDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnWed == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.WEDNESDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnThu == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.THURSDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnFri == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.FRIDAY);
                    }

                    if (fsRouteContractScheduleRow.WeeklyOnSat == true)
                    {
                        dayOfWeekDays.Add(ID.WeekDaysNumber.SATURDAY);
                    }

                    if (dayOfWeekDays != null && dayOfWeekDays.Count > 0)
                    {
                        commandFilter = commandFilter.WhereAnd(InHelper <FSWeekCodeDate.dayOfWeek> .Create(dayOfWeekDays.Count));
                        foreach (int dayOfWeekDay in dayOfWeekDays)
                        {
                            weekCodeArgs.Add(dayOfWeekDay);
                        }
                    }
                }

                PXView weekCodeRecordsView = new PXView(this, true, commandFilter);
                return(weekCodeRecordsView.SelectMulti(weekCodeArgs.ToArray()));
            }

            return(returnList);
        }
コード例 #18
0
            public virtual IEnumerable GetRecords()
            {
                PXView view = _Graph.TypedViews.GetView(_select, true);

                return(view.SelectMulti());
            }
コード例 #19
0
        public void ProcessImpl(IEnumerable <IBqlTable> entities, bool topLayer, Guid?topParentNoteID)
        {
            var processingGraph = PXGraph.CreateInstance <GDPRPersonalDataProcessBase>();

            foreach (IBqlTable entity in entities)
            {
                var mapping = PXPersonalDataTableAttribute.GetEntitiesMapping(entity.GetType());

                AddCachesIntoGraph(processingGraph, mapping.Keys);

                var entityCache = processingGraph.Caches[entity.GetType()];

                entityCache.Current = entity;

                if (topLayer)
                {
                    topParentNoteID = entityCache.GetValue(entity, nameof(INotable.NoteID)) as Guid?;

                    var info = GenerateSearchInfo(processingGraph, entity);

                    // as no wway to search -> restore
                    if (info == null)
                    {
                        continue;
                    }

                    var combinedKey = String.Join <string>(PXAuditHelper.SEPARATOR.ToString(), entityCache.Keys.Select(_ => entityCache.GetValue(entity, _).ToString()));

                    TopLevelProcessor(combinedKey, topParentNoteID, info);

                    LogOperation(entity.GetType(), combinedKey);
                }

                foreach (KeyValuePair <Type, List <BqlCommand> > tableLink in mapping)
                {
                    var childTable = tableLink.Key;
                    var selects    = tableLink.Value;

                    foreach (BqlCommand select in selects)
                    {
                        var currentSelect = select;

                        var bqlPseudonymizationStatus = processingGraph.Caches[childTable].GetBqlField(nameof(IPseudonymizable.PseudonymizationStatus));

                        if (bqlPseudonymizationStatus != null)
                        {
                            if (GetPseudonymizationStatus == typeof(PXPseudonymizationStatusListAttribute.notPseudonymized))
                            {
                                currentSelect = currentSelect.WhereAnd(BqlCommand.Compose(typeof(Where <, ,>), bqlPseudonymizationStatus, typeof(Equal <>), GetPseudonymizationStatus,
                                                                                          typeof(Or <,>), bqlPseudonymizationStatus, typeof(IsNull))); // for just added columns in cst
                            }
                            else
                            {
                                currentSelect = currentSelect.WhereAnd(BqlCommand.Compose(typeof(Where <,>), bqlPseudonymizationStatus, typeof(Equal <>), GetPseudonymizationStatus));
                            }
                        }

                        var view = new PXView(processingGraph, false, currentSelect);

                        var result = view.SelectMulti();
                        if (result.Count == 0)
                        {
                            continue;
                        }

                        var childs = result.Select(_ => _ is PXResult ? (_ as PXResult)[0] : _);

                        List <PXPersonalDataFieldAttribute> fields = null;
                        var isKeyValueTable = PXPersonalDataFieldAttribute.GetPersonalDataFields(childTable, out fields);
                        fields = fields.Where(_ => !(_ is PXPersonalDataTableAnchorAttribute)).ToList();



                        if (fields.Count > 0)
                        {
                            if (!processingGraph.Caches[childTable].Fields.Contains(nameof(INotable.NoteID)) ||
                                !processingGraph.Caches[childTable].Fields.Contains(nameof(IPseudonymizable.PseudonymizationStatus)))
                            {
                                continue;
                            }

                            if (!isKeyValueTable)
                            {
                                ChildLevelProcessor(processingGraph, childTable, fields, childs, topParentNoteID);
                            }
                            else
                            {
                                ChildLevelProcessor(processingGraph, childTable, fields.Where(_ => _ is PXPersonalDataFieldAttribute.Value), childs, topParentNoteID);
                            }
                        }



                        ProcessImpl(childs.Cast <IBqlTable>(), false, topParentNoteID);
                    }
                }
            }
        }
        protected virtual void ValidateDimensionForKeyDuplication(Dimension dimension)
        {
            if (string.IsNullOrEmpty(dimension.ParentDimensionID))
            {
                Dictionary <string, KeyValuePair <Type, string> > dictTables = PXDimensionAttribute.GetTables(dimension.DimensionID);
                if (dictTables != null)
                {
                    foreach (string table in dictTables.Keys)
                    {
                        KeyValuePair <Type, string> pair = dictTables[table];
                        Type        typeTable            = pair.Key;
                        PXCache     cach      = Caches[typeTable];
                        Type        typeField = cach.GetBqlField(pair.Value);
                        List <Type> keys      = cach.BqlKeys;

                        if (!keys.Contains(typeField))
                        {
                            continue;
                        }

                        int    line  = 0;
                        int    count = (keys.Count - 1) * 2 + 1;
                        Type[] group = new Type[count];

                        foreach (Type key in keys)
                        {
                            if (key != typeField)
                            {
                                group[line]     = typeof(GroupBy <,>);
                                group[line + 1] = key;
                                line           += 2;
                            }
                        }

                        group[count - 1] = typeof(Count);
                        Type groupby = BqlCommand.Compose(group);

                        BqlCommand select = BqlCommand.CreateInstance
                                                (typeof(Select4 <,>),
                                                typeTable,
                                                typeof(Aggregate <>),
                                                typeof(GroupBy <,>),
                                                typeof(Left <,>),
                                                typeField,
                                                typeof(CurrentValue <>),
                                                typeof(Dimension.length),
                                                groupby
                                                );

                        PXView        view = new PXView(this, false, select);
                        List <object> rows = view.SelectMulti(null);

                        foreach (PXResult row in rows)
                        {
                            if (row.RowCount > 1)
                            {
                                throw new PXRowPersistingException
                                          (typeof(Dimension.length).Name,
                                          dimension.Length,
                                          PXMessages.LocalizeFormatNoPrefixNLA(Messages.DimensionDuplicate, BqlCommand.GetTableName(typeTable))
                                          );
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
        public virtual decimal AllocateOverRCTLine(
            PXGraph graph,
            List <POReceiptLineAdjustment> result,
            AllocationItem allocationItem,
            decimal toDistribute,
            Int32?branchID)
        {
            // the artificial object is used for allocating the landed cost amount between splits (by quantity)
            var nAllocationItem = new AllocationItem()
            {
                LandedCostCode = new LandedCostCode()
                {
                    AllocationMethod = LandedCostAllocationMethod.ByQuantity
                },
                ReceiptLine = allocationItem.ReceiptLine,
            };

            InventoryItem ii = InventoryItem.PK.Find(graph, allocationItem.ReceiptLine.InventoryID.Value);
            bool          requireLotSerial = (ii.ValMethod == INValMethod.Specific);

            List <Type> bql = new List <Type>(16)
            {
                typeof(Select4 <, ,>),
                typeof(POReceiptLineSplit),
                typeof(Where <POReceiptLineSplit.receiptType, Equal <Required <POReceiptLine.receiptType> >, And <POReceiptLineSplit.receiptNbr, Equal <Required <POReceiptLine.receiptNbr> >, And <POReceiptLineSplit.lineNbr, Equal <Required <POReceiptLine.lineNbr> > > > >),
                typeof(Aggregate <>),
                typeof(GroupBy <,>),
                typeof(POReceiptLineSplit.locationID),
                typeof(GroupBy <,>),
                typeof(POReceiptLineSplit.subItemID),
                typeof(Sum <>),
                typeof(POReceiptLineSplit.baseQty),
            };

            if (requireLotSerial)
            {
                bql.Insert(bql.Count - 2, typeof(GroupBy <,>));
                bql.Insert(bql.Count - 2, typeof(POReceiptLineSplit.lotSerialNbr));
            }

            PXView splitsView = new PXView(graph, false, BqlCommand.CreateInstance(bql.ToArray()));
            var    splits     = splitsView.SelectMulti(allocationItem.ReceiptLine.ReceiptType, allocationItem.ReceiptLine.ReceiptNbr,
                                                       allocationItem.ReceiptLine.LineNbr);

            bool               hasSplits      = false;
            decimal            baseTotal      = GetBaseValue(nAllocationItem);
            decimal            allocatedBase  = 0m;
            decimal            allocatingBase = 0m;
            decimal            allocatedAmt   = 0m;
            POReceiptLineSplit maxSplit       = null;

            foreach (POReceiptLineSplit split in splits)
            {
                hasSplits       = true;
                allocatingBase += split.BaseQty ?? 0m;
                decimal handledSplitsAmt = (baseTotal == 0m) ? 0m : (allocatedBase + allocatingBase) * toDistribute / baseTotal;
                handledSplitsAmt = PXDBCurrencyAttribute.BaseRound(graph, handledSplitsAmt);
                decimal shareAmt = handledSplitsAmt - allocatedAmt;

                if (maxSplit == null || maxSplit.BaseQty < split.BaseQty)
                {
                    maxSplit = split;
                }

                if (shareAmt != 0m)
                {
                    POReceiptLine newPOReceiptLine = PXCache <POReceiptLine> .CreateCopy(allocationItem.ReceiptLine);

                    newPOReceiptLine.LocationID   = maxSplit.LocationID;
                    newPOReceiptLine.SiteID       = maxSplit.SiteID;
                    newPOReceiptLine.SubItemID    = maxSplit.SubItemID;
                    newPOReceiptLine.LotSerialNbr = requireLotSerial ? maxSplit.LotSerialNbr : null;

                    var adj = CreateReceiptLineAdjustment(allocationItem, newPOReceiptLine, shareAmt, branchID);

                    result.Add(adj);
                    allocatedAmt  += shareAmt;
                    allocatedBase += allocatingBase;
                    allocatingBase = 0m;
                    maxSplit       = null;
                }
            }
            if (!hasSplits)
            {
                decimal shareAmt = toDistribute;
                shareAmt = PXDBCurrencyAttribute.BaseRound(graph, shareAmt);
                if (shareAmt != 0m)
                {
                    var adj = CreateReceiptLineAdjustment(allocationItem, null, shareAmt, branchID);

                    result.Add(adj);
                }

                allocatedAmt = shareAmt;
            }
            return(allocatedAmt);
        }
コード例 #22
0
        public static void PrintStatements(PrintParameters filter, List <DetailsResult> list, bool markOnly)
        {
            PXGraph graph   = new PXGraph();
            PXView  docview =
                filter.CuryStatements == true ?
                new PXView(graph, false, BqlCommand.CreateInstance(typeof(Select <ARStatement,
                                                                                  Where <ARStatement.statementCycleId, Equal <Required <ARStatement.statementCycleId> >,
                                                                                         And <ARStatement.statementDate, Equal <Required <ARStatement.statementDate> >,
                                                                                              And <ARStatement.statementCustomerID, Equal <Required <ARStatement.customerID> >,
                                                                                                   And <ARStatement.curyID, Equal <Required <ARStatement.curyID> > > > > > >)))
                          :
                new PXView(graph, false, BqlCommand.CreateInstance(typeof(Select <ARStatement,
                                                                                  Where <ARStatement.statementCycleId, Equal <Required <ARStatement.statementCycleId> >,
                                                                                         And <ARStatement.statementDate, Equal <Required <ARStatement.statementDate> >,
                                                                                              And <ARStatement.statementCustomerID, Equal <Required <ARStatement.customerID> > > > > >)));

            graph.Views["_ARStatement_"] = docview;
            graph.Views.Caches.Add(typeof(ARStatement));
            PXReportRequiredException ex = null;
            string reportID = (filter.CuryStatements ?? false) ?
                              ARStatementReportParams.CS_CuryStatementReportID :
                              ARStatementReportParams.CS_StatementReportID;

            foreach (DetailsResult t in list)
            {
                if (markOnly)
                {
                    if (filter.ShowAll != true)
                    {
                        foreach (ARStatement doc in docview.SelectMulti(filter.StatementCycleId, filter.StatementDate, t.CustomerID, t.CuryID))
                        {
                            doc.DontPrint = true;
                            docview.Cache.Update(doc);
                        }
                    }
                }
                else
                {
                    Dictionary <string, string> d = new Dictionary <string, string>();

                    d[ARStatementReportParams.Parameters.BranchID]     = filter.BranchCD;
                    d[ARStatementReportParams.Fields.StatementCycleID] = filter.StatementCycleId;
                    d[ARStatementReportParams.Fields.StatementDate]    = filter.StatementDate.Value.ToString("d", CultureInfo.InvariantCulture);
                    d[ARStatementReportParams.Fields.CustomerID]       = t.CustomerID.ToString();

                    if (filter.ShowAll == true)
                    {
                        d[ARStatementReportParams.Parameters.IgnorePrintFlags] = ARStatementReportParams.BoolValues.True;
                    }
                    else
                    {
                        d[ARStatementReportParams.Fields.PrintStatements] = ARStatementReportParams.BoolValues.True;
                    }
                    if (filter.CuryStatements ?? false)
                    {
                        d[ARStatementReportParams.Fields.CuryID] = t.CuryID;
                    }

                    foreach (ARStatement doc in docview.SelectMulti(filter.StatementCycleId, filter.StatementDate, t.CustomerID, t.CuryID))
                    {
                        if (doc.Printed != true)
                        {
                            doc.Printed = true;
                            docview.Cache.Update(doc);
                        }
                    }

                    ex = PXReportRequiredException.CombineReport(ex, GetCustomerReportID(graph, reportID, t), d);
                }
            }

            graph.Actions.PressSave();
            if (ex != null)
            {
                throw ex;
            }
        }
コード例 #23
0
        public virtual void OptimizeRoutes(RoutesOptimizationProcess graph, FSAppointmentFilter filter, List <FSAppointmentFSServiceOrder> list, PXResultset <FSAppointmentStaffMember, CSCalendar> staffSelected)
        {
            RouteOptimizerClient client = new RouteOptimizerClient();

            SingleDayOptimizationInput requestBody = new SingleDayOptimizationInput();

            List <FSAppointment> processList = new List <FSAppointment>();

            FSSetup fsSetupRow = graph.SetupRecord.Current;

            requestBody.balanced = true;

            requestBody.vehicles  = new List <Vehicle>();
            requestBody.waypoints = new List <Waypoint>();

            string address = string.Empty;

            if (staffSelected != null && staffSelected.Count == 0)
            {
                throw new PXException(PXMessages.LocalizeFormatNoPrefix(TX.Error.SELECT_AT_LEAST_ONE_STAFF_MEMBER));
            }

            //Origin end Route location
            FSAddress fsAddressRow = PXSelectJoin <FSAddress,
                                                   InnerJoin <FSBranchLocation,
                                                              On <FSBranchLocation.branchLocationAddressID, Equal <FSAddress.addressID> > >,
                                                   Where <
                                                       FSBranchLocation.branchLocationID, Equal <Required <FSBranchLocation.branchLocationID> > > >
                                     .Select(graph, list[0].BranchLocationID);

            address = SharedFunctions.GetAddressForGeolocation(fsAddressRow.PostalCode,
                                                               fsAddressRow.AddressLine1,
                                                               fsAddressRow.AddressLine2,
                                                               fsAddressRow.City,
                                                               fsAddressRow.State,
                                                               fsAddressRow.CountryID);

            GLocation[] results = Geocoder.Geocode(address, fsSetupRow.MapApiKey);

            if (results.Length == 0)
            {
                throw new PXException(PXMessages.LocalizeFormatNoPrefix(TX.Error.MAPS_FAILED_REVERSE_ADRESS, TX.TableName.BRANCH_LOCATION));
            }

            CSCalendar csVendorCalendarRow = PXSelect <CSCalendar,
                                                       Where <CSCalendar.calendarID, Equal <Required <CSCalendar.calendarID> > > >
                                             .Select(graph, fsSetupRow.CalendarID);

            //Driver Logic
            foreach (PXResult <FSAppointmentStaffMember, CSCalendar> result in staffSelected)
            {
                FSAppointmentStaffMember staffRow = (FSAppointmentStaffMember)result;
                CSCalendar csCalendarRow          = (CSCalendar)result;

                Vehicle vehicleRow = new Vehicle()
                {
                    name   = staffRow.BAccountID.ToString(),
                    origin = new RouteLocation()
                    {
                        latitude = results[0].LatLng.Latitude, longitude = results[0].LatLng.Longitude
                    },
                    destination = new RouteLocation()
                    {
                        latitude = results[0].LatLng.Latitude, longitude = results[0].LatLng.Longitude
                    },
                    tags = new List <string>()
                    {
                        staffRow.BAccountID.ToString()
                    }
                };

                TimeWindow working    = graph.GetWorkingTimeWindow(staffRow.EmployeeSDEnabled == true ? csCalendarRow : csVendorCalendarRow, filter.StartDate);
                Break      lunchBreak = graph.GetBreakWindow(fsSetupRow);

                if (lunchBreak != null)
                {
                    vehicleRow.breaks = new List <Break>()
                    {
                        lunchBreak
                    };
                }

                if (working != null)
                {
                    vehicleRow.timeWindow = working;
                    requestBody.vehicles.Add(vehicleRow);
                }
            }

            if (requestBody.vehicles.Count == 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    FSAppointment fsAppointmentRow = list[i];
                    UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.NOT_ABLE);
                    graph.Appointments.Update(fsAppointmentRow);
                    PXProcessing <FSAppointmentFSServiceOrder> .SetError(i, PXMessages.LocalizeFormatNoPrefix(TX.Error.APPOINTMENT_COULD_NOT_BE_REACH_SERVICED_NO_DRIVER_AVAILABLE));
                }

                if (graph.Appointments.Cache.IsDirty == true)
                {
                    graph.Appointments.Cache.Persist(PXDBOperation.Update);
                }

                return;
            }

            //Existing Appointment Logic
            if (filter.Type == ID.Type_ROOptimization.UNASSIGNED_APP && staffSelected.Count() > 0)
            {
                List <object> args = new List <object>();

                BqlCommand fsAppointmentList = new Select2 <FSAppointment,
                                                            InnerJoin <FSServiceOrder,
                                                                       On <FSServiceOrder.sOID, Equal <FSAppointment.sOID> >,
                                                                       InnerJoin <FSAddress,
                                                                                  On <FSAddress.addressID, Equal <FSServiceOrder.serviceOrderAddressID> > > > >();

                if (filter.BranchID != null)
                {
                    fsAppointmentList = fsAppointmentList.WhereAnd(typeof(Where <FSServiceOrder.branchID, Equal <Required <FSServiceOrder.branchID> > >));
                    args.Add(filter.BranchID);
                }

                if (filter.BranchLocationID != null)
                {
                    fsAppointmentList = fsAppointmentList.WhereAnd(typeof(Where <FSServiceOrder.branchLocationID, Equal <Required <FSServiceOrder.branchLocationID> > >));
                    args.Add(filter.BranchLocationID);
                }

                if (filter.StartDate != null)
                {
                    fsAppointmentList = fsAppointmentList.WhereAnd(typeof(Where <FSAppointment.scheduledDateTimeBegin, GreaterEqual <Required <FSAppointment.scheduledDateTimeBegin> > >));
                    args.Add(filter.StartDateWithTime);
                }

                if (filter.EndDateWithTime != null)
                {
                    fsAppointmentList = fsAppointmentList.WhereAnd(typeof(Where <FSAppointment.scheduledDateTimeEnd, LessEqual <Required <FSAppointment.scheduledDateTimeEnd> > >));
                    args.Add(filter.EndDateWithTime);
                }

                if (staffSelected != null && staffSelected.Count() > 0)
                {
                    fsAppointmentList = fsAppointmentList.WhereAnd(typeof(Where <FSAppointment.primaryDriver, In <Required <FSAppointment.primaryDriver> > >));

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

                    args.Add(staffResult);
                }

                PXView appointmentView = new PXView(graph, true, fsAppointmentList);

                var fsAppointmentSet = appointmentView.SelectMulti(args.ToArray());

                foreach (PXResult <FSAppointment, FSServiceOrder, FSAddress> row in fsAppointmentSet)
                {
                    FSAppointment fsAppointmentRow = (FSAppointment)row;
                    fsAddressRow = (FSAddress)row;

                    address = SharedFunctions.GetAddressForGeolocation(
                        fsAddressRow.PostalCode,
                        fsAddressRow.AddressLine1,
                        fsAddressRow.AddressLine2,
                        fsAddressRow.City,
                        fsAddressRow.State,
                        fsAddressRow.CountryID);


                    Waypoint wp = GetWaypointFromAppointment(fsSetupRow, fsAppointmentRow, address);

                    if (wp != null)
                    {
                        requestBody.waypoints.Add(wp);

                        processList.Add(fsAppointmentRow);
                    }
                    else
                    {
                        UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.ADDRESS_ERROR);
                        graph.Appointments.Update(fsAppointmentRow);
                    }
                }
            }

            //Appointment Logic
            for (int i = list.Count - 1; i >= 0; i--)
            {
                bool addressError = false;

                try
                {
                    address = SharedFunctions.GetAddressForGeolocation(
                        list[i].PostalCode,
                        list[i].AddressLine1,
                        list[i].AddressLine2,
                        list[i].City,
                        list[i].State,
                        list[i].CountryID);

                    Waypoint wp = GetWaypointFromAppointment(fsSetupRow, list[i], address);

                    if (wp != null)
                    {
                        requestBody.waypoints.Add(wp);
                        processList.Add(list[i]);
                    }
                    else
                    {
                        addressError = true;
                    }
                }
                catch
                {
                    addressError = true;
                }

                if (addressError == true)
                {
                    addressError = false;

                    FSAppointment fsAppointmentRow = list[i];
                    UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.ADDRESS_ERROR);
                    graph.Appointments.Update(fsAppointmentRow);
                    list.RemoveAt(i);

                    PXProcessing <FSAppointmentFSServiceOrder> .SetError(i, PXMessages.LocalizeFormatNoPrefix(TX.Error.MAPS_FAILED_REVERSE_ADRESS, TX.TableName.APPOINTMENT));
                }
            }

            if (graph.Appointments.Cache.IsDirty == true)
            {
                graph.Appointments.Cache.Persist(PXDBOperation.Update);
            }

            try
            {
                SingleDayOptimizationOutput responseObject = client.getSingleDayOptimization(fsSetupRow.ROWWApiEndPoint, fsSetupRow.ROWWLicensekey, requestBody);

                AppointmentEntry graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>();

                for (int i = 0; i < responseObject.routes.Count; i++)
                {
                    int assignedstaffID;
                    int.TryParse(responseObject.routes[i].vehicle.name, out assignedstaffID);
                    bool changeFlag = false;

                    for (int j = 1; j < responseObject.routes[i].steps.Count - 1; j++)
                    {
                        RouteOtimizer.RouteStep currentAppointment = responseObject.routes[i].steps[j];
                        int appointmentID;
                        int.TryParse(currentAppointment.waypoint.name, out appointmentID);

                        FSAppointment fsAppointmentListRow = processList.Find(x => x.AppointmentID == appointmentID);

                        var newBegin = convertSecToTime(currentAppointment.serviceStartTimeSec, fsAppointmentListRow.ScheduledDateTimeBegin);
                        var newEnd   = newBegin.AddSeconds(currentAppointment.departureTimeSec - currentAppointment.arrivalTimeSec);

                        UpdateAppointmentHeader(fsAppointmentListRow, ID.Status_ROOptimization.OPTIMIZED, j, null, newBegin, newEnd);

                        if (fsAppointmentListRow.PrimaryDriver != null)
                        {
                            graph.Appointments.Update(fsAppointmentListRow);
                            changeFlag = true;
                        }
                        else
                        {
                            fsAppointmentListRow.PrimaryDriver = assignedstaffID;

                            FSAppointment fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.refNbr>(
                                fsAppointmentListRow.RefNbr, fsAppointmentListRow.SrvOrdType);

                            UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.OPTIMIZED, j, assignedstaffID, newBegin, newEnd);

                            graphAppointmentEntry.AppointmentRecords.Update(fsAppointmentRow);

                            FSAppointmentEmployee fsAppointmentEmployeeRow_New = new FSAppointmentEmployee()
                            {
                                AppointmentID = fsAppointmentRow.AppointmentID,
                                EmployeeID    = assignedstaffID
                            };

                            fsAppointmentEmployeeRow_New = graphAppointmentEntry.AppointmentServiceEmployees.Insert(fsAppointmentEmployeeRow_New);

                            graphAppointmentEntry.Save.Press();
                        }
                    }

                    if (changeFlag == true)
                    {
                        graph.Appointments.Cache.Persist(PXDBOperation.Update);
                    }
                }

                foreach (OutputWaypoint wp in responseObject.unreachableWaypoints.Concat(responseObject.unreachedWaypoints).GroupBy(p => p.name).Select(g => g.First()).ToList())
                {
                    int appointmentID;
                    int.TryParse(wp.name, out appointmentID);

                    FSAppointment fsAppointmentRow = list.Find(x => x.AppointmentID == appointmentID);
                    if (fsAppointmentRow != null)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (fsAppointmentRow.AppointmentID == list[i].AppointmentID)
                            {
                                UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.NOT_ABLE);
                                graph.Appointments.Update(fsAppointmentRow);

                                PXProcessing <FSAppointmentFSServiceOrder> .SetError(i, PXMessages.LocalizeFormatNoPrefix(TX.Error.APPOINTMENT_COULD_NOT_BE_REACH_SERVICED));
                            }
                        }
                    }
                }

                graph.Appointments.Cache.Persist(PXDBOperation.Update);
            }
            catch (PXException e)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    FSAppointment fsAppointmentRow = list[i];
                    UpdateAppointmentHeader(fsAppointmentRow, ID.Status_ROOptimization.NOT_ABLE);
                    graph.Appointments.Update(fsAppointmentRow);

                    PXProcessing <FSAppointmentFSServiceOrder> .SetError(i, PXMessages.LocalizeFormatNoPrefix(e.Message));
                }

                graph.Appointments.Cache.Persist(PXDBOperation.Update);
            }
        }
コード例 #24
0
        private static void ProcessValidation(ValidationFilter Filter, Contact record)
        {
            PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(new PXGraph());
            PXGraph graph = primaryGraph[record];

            if (graph == null)
            {
                throw new PXException(Messages.UnableToFindGraph);
            }

            PXView        view = graph.Views[graph.PrimaryView];
            int           startRow = 0, totalRows = 0;
            List <object> list_contact = view.Select(null, null, new object[] { record.ContactID }, new string[] { typeof(Contact.contactID).Name }, null, null,
                                                     ref startRow, 1, ref totalRows);

            if (list_contact == null || list_contact.Count < 1)
            {
                throw new PXException(Messages.ContactNotFound);
            }
            Contact contact = PXResult.Unwrap <Contact>(list_contact[0]);

            contact.DuplicateFound = true;
            //Find duplicates view
            PXView viewDuplicates = graph.Views.ToArray().First(v => v.Value.Cache.GetItemType() == typeof(CRDuplicateRecord)).Value;

            if (viewDuplicates == null)
            {
                throw new PXException(Messages.DuplicateViewNotFound);
            }
            viewDuplicates.Clear();
            List <object> duplicates = viewDuplicates.SelectMulti();

            contact = (Contact)view.Cache.CreateCopy(contact);
            string prevStatus = contact.DuplicateStatus;

            contact.DuplicateStatus = DuplicateStatusAttribute.Validated;
            Decimal?score = 0;

            contact.DuplicateFound = duplicates.Count > 0;
            foreach (PXResult <CRDuplicateRecord, Contact, Contact2> r in duplicates)
            {
                Contact2          duplicate    = r;
                CRDuplicateRecord contactScore = r;
                int duplicateWeight            = ContactMaint.GetContactWeight(duplicate);
                int currentWeight = ContactMaint.GetContactWeight(contact);

                if (duplicateWeight > currentWeight ||
                    (duplicateWeight == currentWeight &&
                     duplicate.ContactID < contact.ContactID))
                {
                    contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated;
                    if (contactScore.Score > score)
                    {
                        score = contactScore.Score;
                    }
                }
            }
            view.Cache.Update(contact);

            if (contact.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated &&
                contact.ContactType == ContactTypesAttribute.Lead &&
                contact.Status == LeadStatusesAttribute.New &&
                Filter.CloseNoActivityLeads == true &&
                score > Filter.CloseThreshold)
            {
                CRActivity activity = PXSelect <CRActivity,
                                                Where <CRActivity.contactID, Equal <Required <Contact.contactID> > > > .SelectWindowed(graph, 0, 1, contact.ContactID);

                if (activity == null)
                {
                    PXAction  action  = graph.Actions["Action"];
                    PXAdapter adapter = new PXAdapter(view);
                    adapter.StartRow    = 0;
                    adapter.MaximumRows = 1;
                    adapter.Searches    = new object[] { contact.ContactID };
                    adapter.Menu        = Messages.CloseAsDuplicate;
                    adapter.SortColumns = new[] { typeof(Contact.contactID).Name };
                    foreach (Contact c in action.Press(adapter))
                    {
                        ;
                    }
                    prevStatus = null;
                }
            }
            view.Cache.RestoreCopy(record, view.Cache.Current);
            if (prevStatus != contact.DuplicateStatus)
            {
                graph.Actions.PressSave();
            }
        }
        private IEnumerable <ApproveInfo> ProcessLevel(Table item, int?assignmentMap, PXResultset <EPRule> rules)
        {
            foreach (EPRule rule in rules)
            {
                if (rule.RuleID == null)
                {
                    continue;
                }

                path.Add(rule.RuleID.Value);

                bool isSuccessful  = true;
                var  filteredItems = ExecuteRule(item, rule, ref isSuccessful);


                Guid?OwnerID     = null;
                int? WorkgroupID = rule.WorkgroupID;

                switch (rule.RuleType)
                {
                case EPRuleType.Direct:

                    if (!isSuccessful || (filteredItems != null && filteredItems.Count == 0))
                    {
                        continue;
                    }

                    OwnerID = rule.OwnerID;

                    FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID);

                    if (OwnerID == null && WorkgroupID == null)
                    {
                        continue;
                    }

                    yield return(new ApproveInfo()
                    {
                        OwnerID = OwnerID,
                        WorkgroupID = WorkgroupID,
                        RuleID = rule.RuleID,
                        StepID = rule.StepID,
                        WaitTime = rule.WaitTime
                    });

                    break;

                case EPRuleType.Document:

                    if (rule.OwnerSource == null || (filteredItems != null && filteredItems.Count == 0))
                    {
                        continue;
                    }

                    PXView lineView    = null;
                    PXView primaryView = null;
                    Type   viewType    = null;
                    try
                    {
                        var s        = rule.OwnerSource;
                        var viewName = s.Substring(s.LastIndexOf("(") + 1, s.IndexOf(".") - (s.LastIndexOf("(") + 1));

                        if (String.Equals(viewName, processGraph.PrimaryView, StringComparison.InvariantCultureIgnoreCase))
                        {
                            primaryView = processGraph.Views[viewName];
                            viewType    = primaryView.GetItemType();
                        }
                        else
                        {
                            lineView = processGraph.Views[viewName];
                            viewType = lineView.GetItemType();
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }


                    bool queryContainsDetails = filteredItems != null && filteredItems.Count > 0 && ((PXResult)filteredItems[0])[viewType] != null;

                    var arrayToIterate = queryContainsDetails
                                                        ? filteredItems
                                                        : lineView?.SelectMulti() ?? primaryView.Cache.Current.SingleToList() ?? filteredItems;

                    foreach (object filteredItem in arrayToIterate)
                    {
                        if (filteredItem is PXResult)
                        {
                            var line = ((PXResult)filteredItem)[viewType];
                            processGraph.Caches[viewType].Current = line;
                        }
                        else
                        {
                            processGraph.Caches[viewType].Current = filteredItem;
                        }

                        string code = PXTemplateContentParser.Instance.Process(rule.OwnerSource, processGraph, viewType, null);

                        EPEmployee emp =
                            PXSelect <
                                EPEmployee,
                                Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > >
                            .SelectWindowed(this, 0, 1, code);

                        OwnerID = emp != null ? emp.UserID : GUID.CreateGuid(code);

                        FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID);

                        if (OwnerID == null && WorkgroupID == null)
                        {
                            continue;
                        }

                        yield return(new ApproveInfo()
                        {
                            OwnerID = OwnerID,
                            WorkgroupID = WorkgroupID,
                            RuleID = rule.RuleID,
                            StepID = rule.StepID,
                            WaitTime = rule.WaitTime
                        });
                    }

                    break;

                case EPRuleType.Filter:

                    if (filteredItems == null || filteredItems.Count == 0)
                    {
                        continue;
                    }

                    List <EPRuleBaseCondition> conditions =
                        PXSelectReadonly <EPRuleEmployeeCondition,
                                          Where <EPRuleEmployeeCondition.ruleID, Equal <Required <EPRule.ruleID> > > >
                        .Select(this, rule.RuleID)
                        .Select(_ => (EPRuleBaseCondition)_)
                        .ToList();

                    if (conditions.Count == 0)
                    {
                        break;
                    }

                    foreach (var approveInfo in GetEmployeesByFilter(item, rule, conditions))
                    {
                        yield return(approveInfo);
                    }

                    break;
                }

                if (rule.RuleID != null)
                {
                    if (path.Contains(rule.RuleID.Value))
                    {
                        continue;
                    }

                    foreach (var approveInfo in ProcessLevel(item, assignmentMap, PXSelectReadonly <EPRule> .Search <EPRule.ruleID>(this, rule.RuleID)))
                    {
                        yield return(approveInfo);
                    }
                }

                PXResultset <EPRule> result = PXSelectReadonly <
                    EPRule,
                    Where <
                        EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > >,
                    OrderBy <
                        Asc <EPRule.sequence> > > .Select(this, assignmentMap);

                foreach (var approveInfo in ProcessLevel(item, assignmentMap, result))
                {
                    yield return(approveInfo);
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Gets the employees contact info separated by a coma.
        /// </summary>
        /// <param name="graph">Graph to use.</param>
        /// <param name="concatenateNames">Boolean that if true, returns the Staff name(s).</param>
        /// <param name="concatenateCells">Boolean that if true, returns the Staff cell phone(s).</param>
        /// <param name="appointmentID">Appointment ID.</param>
        private static StringBuilder GetsEmployeesContactInfo(PXGraph graph, bool concatenateNames, bool concatenateCells, int?appointmentID)
        {
            StringBuilder names = new StringBuilder();

            int i = 0;

            // TODO SD-7612 this BQL is not currently retrieving contact info for vendors
            BqlCommand fsAppointmentEmployeeContactInfoBql =
                new Select5 <FSAppointmentEmployee,
                             InnerJoin <BAccount,
                                        On <
                                            BAccount.bAccountID, Equal <FSAppointmentEmployee.employeeID> >,
                                        InnerJoin <Contact,
                                                   On <
                                                       BAccount.defContactID, Equal <Contact.contactID> > > >,
                             Where <
                                 FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> > >,
                             Aggregate <
                                 GroupBy <FSAppointmentEmployee.employeeID> >,
                             OrderBy <
                                 Asc <FSAppointmentEmployee.employeeID> > >();

            PXView fsAppointmentEmployeeContactInfoView = new PXView(graph, true, fsAppointmentEmployeeContactInfoBql);
            var    fsAppointmentEmployeeSet             = fsAppointmentEmployeeContactInfoView.SelectMulti(appointmentID);

            if (fsAppointmentEmployeeSet.Count > 0)
            {
                foreach (PXResult <FSAppointmentEmployee, BAccount, Contact> bqlResult in fsAppointmentEmployeeSet)
                {
                    FSAppointmentEmployee fsAppointmentEmployeeRow = (FSAppointmentEmployee)bqlResult;
                    BAccount bAccountRow = (BAccount)bqlResult;
                    Contact  contactRow  = (Contact)bqlResult;

                    i++;

                    if (fsAppointmentEmployeeSet.Count > 1 && i == fsAppointmentEmployeeSet.Count)
                    {
                        names.Append(PXMessages.LocalizeFormatNoPrefix(TX.Messages.LIST_LAST_ITEM_PREFIX));
                    }
                    else
                    {
                        if (names.Length != 0)
                        {
                            names.Append(", ");
                        }
                    }

                    if (fsAppointmentEmployeeRow.Type == BAccountType.EmployeeType)
                    {
                        if (string.IsNullOrEmpty(contactRow.FirstName) == false && concatenateNames == true)
                        {
                            names.Append(contactRow.FirstName.Trim());
                        }

                        if (string.IsNullOrEmpty(contactRow.LastName) == false && concatenateNames == true)
                        {
                            names.Append(' ');
                            names.Append(contactRow.LastName.Trim());
                        }
                    }
                    else if (fsAppointmentEmployeeRow.Type == BAccountType.VendorType)
                    {
                        if (string.IsNullOrEmpty(contactRow.FullName) == false && concatenateNames == true)
                        {
                            names.Append(contactRow.FullName.Trim());
                        }
                    }

                    if (string.IsNullOrEmpty(contactRow.Phone1) == false && concatenateCells == true)
                    {
                        names.Append(contactRow.Phone1.Trim());
                    }
                    else if (concatenateCells == true)
                    {
                        names.Append(TX.Messages.NO_CONTACT_CELL_FOR_THE_STAFF);
                    }
                }
            }
            else
            {
                names.Append(TX.Messages.NO_STAFF_ASSIGNED_FOR_THE_APPOINTMENT);
            }

            return(names);
        }
コード例 #27
0
        private IEnumerable <PMCommitment> GetCommitments()
        {
            var view = new PXView(Base, true, Base.Items.View.BqlSelect);

            return(view.SelectMulti().RowCast <PMCommitment>());
        }