protected IEnumerable items()
        {
            string actionName = CRMassProcessingAttribute.GetSelectedAction(Items.View);

            if (CRMergeAttribute.IsMergeAction(actionName))
            {
                return(new PXSelectJoin <CRContactBatch,
                                         LeftJoin <CRLeadBatch, On <CRLeadBatch.contactID, Equal <CRContactBatch.contactID> >,
                                                   LeftJoin <BAccount, On <CRContactBatch.bAccountID, Equal <BAccount.bAccountID> >,
                                                             LeftJoin <Address, On <Address.addressID, Equal <CRContactBatch.defAddressID> > > > >,
                                         Where <CRContactBatch.contactType, Equal <ContactTypes.person>,
                                                And <Where <CRContactBatch.bAccountID, NotEqual <Current <Company.bAccountID> >,
                                                            Or <CRContactBatch.bAccountID, IsNull> > > > >(this).Select());
            }
            if (CRUpdateAttribute.IsUpdateAction(actionName))
            {
                return(new PXSelectJoin <CRContactBatch,
                                         InnerJoin <CRLeadBatch, On <CRLeadBatch.contactID, Equal <CRContactBatch.contactID> >,
                                                    LeftJoin <Address, On <Address.addressID, Equal <CRLeadBatch.defAddressID> > > >,
                                         Where <CRLeadBatch.bAccountID, IsNull> >(this).Select());
            }
            if (actionName == ASSIGNLEADS_ACTIONNAME)
            {
                return(new PXSelectJoin <CRContactBatch,
                                         InnerJoin <CRLeadBatch, On <CRLeadBatch.contactID, Equal <CRContactBatch.contactID> >,
                                                    LeftJoin <Address, On <Address.addressID, Equal <CRLeadBatch.defAddressID> > > >,
                                         Where <CRLeadBatch.workgroupID, IsNull> >(this).Select());
            }
            return(new PXResultset <CRContactBatch, CRLeadBatch, BAccount, Address>());
        }
        protected IEnumerable leadItems()
        {
            string actionName = CRMassProcessingAttribute.GetSelectedAction(Items.View);

            if (CRMergeAttribute.IsMergeAction(actionName) || CRUpdateAttribute.IsUpdateAction(actionName))
            {
                return(new PXSelect <CRLeadBatch, Where <CRLeadBatch.bAccountID, IsNull> >(this).Select());
            }
            if (actionName == ASSIGNLEADS_ACTIONNAME)
            {
                return(new PXSelect <CRLeadBatch, Where <CRLeadBatch.workgroupID, IsNull> >(this).Select());
            }
            return(new PXResultset <CRLeadBatch>());
        }
        public IEnumerable AssignLeads(PXAdapter adapter)
        {
            PXCache cache        = this.Caches[typeof(CRLeadBatch)];
            bool    onlySelected = CRMassProcessingAttribute.GetOnlySelectedParameter(adapter.Parameters);

            if ((!onlySelected || CRMassProcessingAttribute.ExistSelectedItems(cache)) &&
                AssignmentMap.View.Ask(null, MessageButtons.Panel) == WebDialogResult.OK)
            {
                CRAssignmentProcessHelper <Lead> helper = new CRAssignmentProcessHelper <Lead>();
                int assignmentMapID = AssignmentMap.Current.CRAssignmentMapID.Value;
                foreach (CRLeadBatch item in onlySelected ?
                         CRMassProcessingAttribute.GetSelectedItems(cache) :
                         CRMassProcessingAttribute.GetAllItems(cache))
                {
                    helper.Assign(item, assignmentMapID);
                }
                CRHelper.SafetyPersist(cache, PXDBOperation.Update);
                this.SelectTimeStamp();
            }

            return(adapter.Get());
        }
        private void CacheAttached(PXGraph graph, Type itemType)
        {
            PXCache valuesCache;

            if ((valuesCache = graph.Caches[itemType]) != null)
            {
                Dictionary <string, List <object> > values =
                    GetPropertyValuesPairs(valuesCache,
                                           OnlySelected
                                                                                        ? CRMassProcessingAttribute.GetSelectedItems(valuesCache)
                                                                                        : CRMassProcessingAttribute.GetAllItems(valuesCache));
                FillArrayDic <object>(values, _valuesDic);
                FillArrayDic <string>(GetPropertyLabelsPairs(valuesCache, values, itemType), _labelsDic);
            }
        }
 public void SetAction(string actionName)
 {
     CRMassProcessingAttribute.SetSelectedAction(Items.View, Items.GetItemType().Name + actionName);
 }