protected virtual void Process(List <Contact> list)
        {
            int result = PXProcessing.ProcessItems(list, item =>
            {
                if (Operations.Current.Action == CampaignOperationParam.ActionList.Update)
                {
                    CRCampaignMembers member = PXSelect <CRCampaignMembers,
                                                         Where <CRCampaignMembers.campaignID, Equal <Current <CampaignOperationParam.campaignID> >,
                                                                And <CRCampaignMembers.contactID, Equal <Required <CRCampaignMembers.contactID> > > > > .
                                               Select(this, item.ContactID);

                    if (member != null)
                    {
                        CRCampaignMembers upd = PXCache <CRCampaignMembers> .CreateCopy(member);
                        upd.Status            = Operations.Current.Status;
                        CampaignMembers.Cache.Update(upd);
                    }
                }
                else if (Operations.Current.Action == CampaignOperationParam.ActionList.Remove)
                {
                    var member = (CRCampaignMembers)PXSelect <CRCampaignMembers,
                                                              Where <CRCampaignMembers.campaignID, Equal <Current <CampaignOperationParam.campaignID> >,
                                                                     And <CRCampaignMembers.contactID, Equal <Required <CRCampaignMembers.contactID> > > > > .
                                 Select(this, item.ContactID);
                    if (member != null)
                    {
                        CampaignMembers.Cache.Delete(member);
                    }
                }
                else if (item.Selected == true)
                {
                    OrderedDictionary doc = new OrderedDictionary();
                    doc.Add("CampaignID", Operations.Current.CampaignID);
                    doc.Add("ContactID", item.ContactID);
                    doc.Add("Status", Operations.Current.Status);
                    CampaignMembers.Cache.Update(doc, doc);
                }
            });

            try
            {
                if (result > 0)
                {
                    Actions.PressSave();
                }
                Items.Cache.Clear();
                if (result != list.Count)
                {
                    throw new PXOperationCompletedException(ErrorMessages.SeveralItemsFailed);
                }
            }
            finally
            {
                CampaignMembers.Cache.Clear();
            }
        }
Exemplo n.º 2
0
 public CampaignRecipient(object entity, string format, CRCampaignMembers member, string distinationStatus)
     : base(entity, format)
 {
     _member            = member;
     _distinationStatus = distinationStatus;
 }