예제 #1
0
        protected virtual void Batch_RowInserted(PXCache sender, PXRowInsertedEventArgs e, PXRowInserted bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }

            if (Base.IsWithinContext)
            {
                string vb   = Base.GetContextValue <GLVoucherBatch.voucherBatchNbr>();
                string wbID = Base.GetContextValue <GLVoucherBatch.workBookID>();
                this.VoucherBatch.Current = this.VoucherBatch.Select(wbID, vb);
                GLWorkBook wb = PXSelect <GLWorkBook,
                                          Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                if (!String.IsNullOrEmpty(vb))
                {
                    Guid?noteID = PXNoteAttribute.GetNoteID <Batch.noteID>(sender, e.Row);
                    this.Voucher.Insert(new GLVoucher());
                    this.Voucher.Cache.IsDirty        = false;
                    Base.Caches[typeof(Note)].IsDirty = false;
                }
                if (wb.DefaultDescription != null && (e.Row as Batch)?.Description == null)
                {
                    sender.SetValueExt <Batch.description>(e.Row, wb.DefaultDescription);
                }
            }
        }
예제 #2
0
        private void UpdateAcitivtyRemindInfo(object id, UpdateRemindInfo handler)
        {
            EPReminder remindInfo = RemindInfo.Select(id);

            if (remindInfo == null)
            {
                remindInfo = (EPReminder)RemindInfo.Cache.Insert();
                EPActivity activity = PXSelect <EPActivity, Where <EPActivity.taskID, Equal <Required <EPActivity.taskID> > > > .
                                      Select(this, id);

                remindInfo.NoteID = PXNoteAttribute.GetNoteID(Caches[typeof(EPActivity)], activity,
                                                              EntityHelper.GetNoteField(typeof(EPActivity)));
                remindInfo.UserID = PXAccess.GetUserID();
                remindInfo.Date   = PXTimeZoneInfo.Now;
                RemindInfo.Cache.Normalize();
            }
            handler(remindInfo);
            RemindInfo.Update(remindInfo);
            using (var ts = new PXTransactionScope())
            {
                RemindInfo.Cache.Persist(PXDBOperation.Insert);
                RemindInfo.Cache.Persist(PXDBOperation.Update);
                ts.Complete(this);
            }
            RemindInfo.Cache.Persisted(false);
            ActivityList.Cache.Clear();
            ActivityList.View.Clear();
            ActivityCount.Cache.Clear();
            ActivityCount.View.Clear();
            ReminderList.Cache.Clear();
            ReminderList.View.Clear();
            ReminderListCurrent.View.Clear();
        }
        protected virtual void INItemPlan_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INItemPlan plan = (INItemPlan)e.Row;

            if (plan != null)
            {
                PXCache parent = this.Document.Cache;
                plan.RefNoteID = PXNoteAttribute.GetNoteID <INReplenishmentOrder.noteID>(parent, parent.Current);
            }
        }
        protected override bool Process(Package package)
        {
            var account = package.Account;

            if (account.IncomingProcessing != true ||
                account.CreateLead != true)
            {
                return(false);
            }

            var message = package.Message;

            if (!string.IsNullOrEmpty(message.Exception) ||
                message.IsIncome != true ||
                message.RefNoteID != null ||
                message.ClassID == CRActivityClass.EmailRouting)
            {
                return(false);
            }

            var copy = package.Graph.Caches[typeof(CRSMEmail)].CreateCopy(message);

            try
            {
                LeadMaint graph     = PXGraph.CreateInstance <LeadMaint>();
                var       leadCache = graph.Lead.Cache;
                var       lead      = (Contact)leadCache.Insert();
                lead = PXCache <Contact> .CreateCopy(graph.Lead.Search <Contact.contactID>(lead.ContactID));

                lead.EMail    = package.Address;
                lead.LastName = package.Description;

                CREmailActivityMaint.EmailAddress address = CREmailActivityMaint.ParseNames(message.MailFrom);

                lead.FirstName = address.FirstName;
                lead.LastName  = address.LastName;
                if (account.CreateLeadClassID != null)
                {
                    lead.ClassID = account.CreateLeadClassID;
                }

                lead = (Contact)leadCache.Update(lead);

                message.RefNoteID = PXNoteAttribute.GetNoteID <Contact.noteID>(leadCache, lead);
                graph.Actions.PressSave();
                message.ContactID = message.ContactID ?? lead.ContactID;
            }
            catch (Exception e)
            {
                package.Graph.Caches[typeof(CRSMEmail)].RestoreCopy(message, copy);
                throw new PXException(Messages.CreateLeadException, e is PXOuterException ? ("\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages)) : e.Message);
            }

            return(true);
        }
예제 #5
0
        protected virtual void INItemPlan_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }
            INItemPlan plan = (INItemPlan)e.Row;

            if (plan != null)
            {
                PXCache parent = this.Document.Cache;
                plan.RefNoteID = PXNoteAttribute.GetNoteID <INReplenishmentOrder.noteID>(parent, parent.Current);
            }
        }
예제 #6
0
        public virtual Batch ReverseBatchProc(Batch b, ReverseBatchProcDelegate baseMethod)
        {
            GLVoucher glVoucher =
                PXSelect <GLVoucher, Where <GLVoucher.refNoteID, Equal <Required <Batch.noteID> > > > .Select(Base, b.NoteID);

            if (glVoucher == null)
            {
                return(baseMethod(b));
            }

            Batch batch;

            using (PXTransactionScope transactionScope = new PXTransactionScope())
            {
                GLVoucherBatch glVoucherBatch = PXSelect <GLVoucherBatch, Where <GLVoucherBatch.voucherBatchNbr,
                                                                                 Equal <Required <GLVoucher.voucherBatchNbr> > > > .Select(Base, glVoucher.VoucherBatchNbr);

                var contextValues = new Dictionary <string, string>();
                contextValues.Add(typeof(GLVoucherBatch.workBookID).FullName, glVoucherBatch.WorkBookID);
                contextValues.Add(typeof(GLVoucherBatch.voucherBatchNbr).FullName, glVoucherBatch.VoucherBatchNbr);
                Base.contextValues = contextValues;

                batch = baseMethod(b);

                if (batch.AutoReverseCopy == true)
                {
                    VoucherBatch.Current = glVoucherBatch;

                    var copy = (GLVoucher)Voucher.Cache.CreateCopy(glVoucher);
                    copy.DocType   = batch.BatchType;
                    copy.RefNbr    = batch.BatchNbr;
                    copy.RefNoteID = batch.NoteID;
                    copy.LineNbr   = null;
                    copy           = this.Voucher.Insert(copy);
                    this.Voucher.Cache.Persist(PXDBOperation.Insert);
                    this.VoucherBatch.Cache.Persist(PXDBOperation.Update);

                    Guid?noteID = PXNoteAttribute.GetNoteID <Batch.noteID>(Base.BatchModule.Cache, batch);
                    Base.Caches[typeof(Note)].Persist(PXDBOperation.Insert);
                }

                transactionScope.Complete(Base);
            }

            return(batch);
        }
        private Guid?FindMatchingNoteIDForFolder(string screenID, string keyValues)
        {
            string graphType = PXPageIndexingService.GetGraphTypeByScreenID(screenID);

            if (string.IsNullOrEmpty(graphType))
            {
                throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, screenID);
            }

            string primaryViewName = PXPageIndexingService.GetPrimaryView(graphType);

            if (string.IsNullOrEmpty(primaryViewName))
            {
                throw new PXException(Messages.PrimaryGraphForScreenIDNotFound, graphType);
            }

            var viewDescription = new Data.Description.PXViewDescription(primaryViewName);

            KeyValuePair <string, string>[] keyValuePairs;
            var graph = PXGraph.CreateInstance(PXBuildManager.GetType(graphType, true));

            try
            {
                keyValuePairs = GetKeyValuePairsFromKeyValues(graph, primaryViewName, keyValues);
            }
            catch (FolderNameKeyValuesMismatchException)
            {
                return(null);
            }

            var view = graph.Views[primaryViewName];

            ScreenUtils.SelectCurrent(view, viewDescription, keyValuePairs);

            if (view.Cache.Current == null)
            {
                return(null);
            }
            else
            {
                return(PXNoteAttribute.GetNoteID(view.Cache, view.Cache.Current, EntityHelper.GetNoteField(view.Cache.Current.GetType())));
            }
        }
        protected virtual void APQuickCheck_RowInserted(PXCache sender, PXRowInsertedEventArgs e, PXRowInserted bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            bool isWithinContext = Base.IsWithinContext;

            if (isWithinContext)
            {
                string vb   = Base.GetContextValue <GLVoucherBatch.voucherBatchNbr>();
                string wbID = Base.GetContextValue <GLVoucherBatch.workBookID>();
                this.VoucherBatch.Current = this.VoucherBatch.Select(wbID, vb);
                GLWorkBook wb = PXSelect <GLWorkBook,
                                          Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                if (!String.IsNullOrEmpty(vb))
                {
                    Guid?noteID = PXNoteAttribute.GetNoteID <AP.Standalone.APQuickCheck.noteID>(sender, e.Row);
                    this.Voucher.Insert(new GLVoucher());
                    this.Voucher.Cache.IsDirty        = false;
                    Base.Caches[typeof(Note)].IsDirty = false;
                }

                var row = (AP.Standalone.APQuickCheck)e.Row;

                if (wb.DefaultDescription != null && row.DocDesc == null)
                {
                    sender.SetValueExt <AP.Standalone.APQuickCheck.docDesc>(e.Row, wb.DefaultDescription);
                }

                if (wb.DefaultBAccountID != null && row.VendorID == null)
                {
                    sender.SetValueExt <AP.Standalone.APQuickCheck.vendorID>(e.Row, wb.DefaultBAccountID);

                    if (wb.DefaultLocationID != null)
                    {
                        sender.SetValueExt <AP.Standalone.APQuickCheck.vendorLocationID>(e.Row, wb.DefaultLocationID);
                    }
                }
            }
        }
        protected virtual void CAAdj_RowInserted(PXCache sender, PXRowInsertedEventArgs e, PXRowInserted bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            bool isWithinContext = Base.IsWithinContext;

            if (isWithinContext)
            {
                string vb   = Base.GetContextValue <GLVoucherBatch.voucherBatchNbr>();
                string wbID = Base.GetContextValue <GLVoucherBatch.workBookID>();
                this.VoucherBatch.Current = this.VoucherBatch.Select(wbID, vb);
                GLWorkBook wb = PXSelect <GLWorkBook,
                                          Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                if (!String.IsNullOrEmpty(vb))
                {
                    Guid?noteID = PXNoteAttribute.GetNoteID <CAAdj.noteID>(sender, e.Row);
                    this.Voucher.Insert(new GLVoucher());
                    this.Voucher.Cache.IsDirty        = false;
                    Base.Caches[typeof(Note)].IsDirty = false;
                }

                var row = PXCache <CAAdj> .CreateCopy((CAAdj)e.Row);

                if (wb.DefaultDescription != null && row.TranDesc == null)
                {
                    row.TranDesc = wb.DefaultDescription;
                }
                if (wb.DefaultCashAccountID != null && row.CashAccountID == null)
                {
                    row.CashAccountID = wb.DefaultCashAccountID;
                }
                if (wb.DefaultEntryTypeID != null && row.EntryTypeID == null)
                {
                    row.EntryTypeID = wb.DefaultEntryTypeID;
                }

                sender.Update(row);
            }
        }
예제 #10
0
        private static Guid?GetEntityNoteID(PXGraph graph, object row)
        {
            var  helper    = new EntityHelper(graph);
            Guid?refNoteId = null;

            if (row != null)
            {
                var cacheType = row.GetType();
                var graphType = helper.GetPrimaryGraphType(cacheType, row, false);
                if (graphType != null)
                {
                    var primaryGraph = graph.GetType() != graphType
                        ? (PXGraph)PXGraph.CreateInstance(graphType)
                        : graph;

                    var primaryCache = primaryGraph.Caches[cacheType];
                    refNoteId = PXNoteAttribute.GetNoteID(primaryCache,
                                                          row, EntityHelper.GetNoteField(cacheType));
                }
            }
            return(refNoteId);
        }
        protected override bool Process(Package package)
        {
            var account = package.Account;

            if (account.IncomingProcessing != true ||
                account.CreateCase != true)
            {
                return(false);
            }

            var message = package.Message;

            if (!string.IsNullOrEmpty(message.Exception) || message.IsIncome != true || message.RefNoteID != null)
            {
                return(false);
            }


            var graph = PXGraph.CreateInstance <CRCaseMaint>();

            SetCRSetup(graph);
            SetAccessInfo(graph);
            var copy = package.Graph.Caches[typeof(CRSMEmail)].CreateCopy(message);

            try
            {
                var caseCache = graph.Caches[typeof(CRCase)];
                var @case     = (CRCase)caseCache.Insert();
                @case = graph.Case.Search <CRCase.caseCD>(@case.CaseCD);
                @case = PXCache <CRCase> .CreateCopy(@case);

                //@case.EMail = package.Address;
                @case.Subject = message.Subject;
                if (@case.Subject == null || @case.Subject.Trim().Length == 0)
                {
                    @case.Subject = GetFromString(package.Address, package.Description);
                }
                @case.Description = message.Body;

                if (account.CreateCaseClassID != null)
                {
                    @case.CaseClassID = account.CreateCaseClassID;
                }

                @case = PXCache <CRCase> .CreateCopy((CRCase)caseCache.Update(@case));

                var contact = FindContact(graph, package.Address);
                if (contact != null)
                {
                    @case.ContactID   = contact.ContactID;
                    message.ContactID = contact.ContactID;
                }
                else
                {
                    CRCaseClass caseClass = PXSelect <CRCaseClass, Where <CRCaseClass.caseClassID, Equal <Required <CRCaseClass.caseClassID> > > > .SelectSingleBound(graph, null, @case.CaseClassID);

                    if (caseClass == null || caseClass.RequireContact == true)
                    {
                        return(false);
                    }
                }

                var bAccount = FindAccount(graph, contact);
                if (bAccount != null)
                {
                    PXCache cache = graph.Caches[typeof(BAccount)];
                    graph.EnsureCachePersistence(cache.GetItemType());
                    message.BAccountID = bAccount.BAccountID;
                    @case.CustomerID   = bAccount.BAccountID;
                }

                message.RefNoteID = PXNoteAttribute.GetNoteID <CRCase.noteID>(graph.Caches[typeof(CRCase)], @case);
                caseCache.Update(@case);
                graph.Activities.Cache.Current = message;
                graph.Save.PressImpl(false);
            }
            catch (Exception e)
            {
                package.Graph.Caches[typeof(CRSMEmail)].RestoreCopy(message, copy);
                throw new PXException(Messages.CreateCaseException, e is PXOuterException ? ("\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages)) : e.Message);
            }
            return(true);
        }
        public static void ConvertToAccount(Contact contact, AccountsFilter param)
        {
            BusinessAccountMaint accountMaint = CreateInstance <BusinessAccountMaint>();
            object cd = param.BAccountID;

            accountMaint.BAccount.Cache.RaiseFieldUpdating <BAccount.acctCD>(null, ref cd);
            BAccount account = new BAccount
            {
                AcctCD           = (string)cd,
                AcctName         = param.AccountName,
                Type             = BAccountType.ProspectType,
                ClassID          = param.AccountClass,
                ParentBAccountID = contact.ParentBAccountID
            };

            #region Set Contact and Address fields
            CRContactClass cls = PXSelect <CRContactClass, Where <CRContactClass.classID, Equal <Current <Contact.classID> > > > .SelectSingleBound(accountMaint, new object[] { contact });

            if (cls != null && cls.OwnerToBAccount == true)
            {
                account.WorkgroupID = contact.WorkgroupID;
                account.OwnerID     = contact.OwnerID;
            }

            try
            {
                object newValue = account.OwnerID;
                accountMaint.BAccount.Cache.RaiseFieldVerifying <BAccount.ownerID>(account, ref newValue);
            }
            catch (PXSetPropertyException)
            {
                account.OwnerID = null;
            }

            account = accountMaint.BAccount.Insert(account);

            accountMaint.Answers.CopyAllAttributes(account, contact);

            Contact defContact = PXCache <Contact> .CreateCopy(PXSelect <Contact, Where <Contact.contactID, Equal <Current <BAccount.defContactID> > > > .SelectSingleBound(accountMaint, new object[] { account }));

            var defContactNoteID = defContact.NoteID;
            PXCache <Contact> .RestoreCopy(defContact, contact);

            defContact.ContactType     = ContactTypesAttribute.BAccountProperty;
            defContact.FullName        = account.AcctName;
            defContact.ContactID       = account.DefContactID;
            defContact.BAccountID      = account.BAccountID;
            defContact.DuplicateStatus = DuplicateStatusAttribute.NotValidated;
            defContact.DuplicateFound  = false;
            defContact.WorkgroupID     = null;
            defContact.OwnerID         = null;
            defContact.NoteID          = defContactNoteID;
            defContact = accountMaint.DefContact.Update(defContact);

            Address contactAddress = PXSelect <Address, Where <Address.addressID, Equal <Required <Contact.defAddressID> > > > .Select(accountMaint, contact.DefAddressID);

            if (contactAddress == null)
            {
                throw new PXException(Messages.DefAddressNotExists, contact.DisplayName);
            }
            contactAddress.BAccountID = account.BAccountID;
            accountMaint.AddressCurrent.Cache.Clear();

            defContact.DefAddressID = contactAddress.AddressID;
            defContact = accountMaint.DefContact.Update(defContact);

            contactAddress = accountMaint.AddressCurrent.Update(contactAddress);

            account.DefAddressID = contactAddress.AddressID;
            accountMaint.BAccount.Update(account);

            contact.BAccountID      = account.BAccountID;
            contact.DuplicateStatus = DuplicateStatusAttribute.NotValidated;
            contact.DuplicateFound  = false;
            if (contact.QualificationDate == null)
            {
                contact.QualificationDate = PXTimeZoneInfo.Now;
            }
            accountMaint.Contacts.Cache.SetStatus(contact, PXEntryStatus.Updated);
            CR.Location location = accountMaint.DefLocation.Select();
            location.DefAddressID = contactAddress.AddressID;
            accountMaint.DefLocation.Update(location);

            account.NoteID = PXNoteAttribute.GetNoteID <CRActivity.noteID>(accountMaint.CurrentBAccount.Cache, account);
            foreach (CRPMTimeActivity a in PXSelect <CRPMTimeActivity, Where <CRPMTimeActivity.refNoteID, Equal <Required <Contact.noteID> > > > .Select(accountMaint, contact.NoteID))
            {
                a.BAccountID = account.BAccountID;
                accountMaint.Activities.Cache.Update(a);
            }
            #endregion

            // Copy Note text and Files references
            CRSetup setup = PXSetupOptional <CRSetup> .Select(accountMaint);

            PXNoteAttribute.CopyNoteAndFiles(accountMaint.Contacts.Cache, contact, accountMaint.CurrentBAccount.Cache, account, setup);

            throw new PXRedirectRequiredException(accountMaint, "Business Account");
        }
예제 #13
0
 protected virtual void INReplenishmentOrder_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
 {
     PXNoteAttribute.GetNoteID <INReplenishmentOrder.noteID>(sender, e.Row);
 }
예제 #14
0
 public virtual void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
 {
     PXNoteAttribute.GetNoteID(sender, e.Row, _NoteID.Name);
 }
예제 #15
0
 public virtual void RowInserted(PXCache sender, PXRowInsertedEventArgs e)
 {
     PXNoteAttribute.GetNoteID(sender, e.Row, _NoteID.Name);
     sender.Graph.Caches[typeof(Note)].IsDirty = false;
 }
예제 #16
0
        protected override bool Process(Package package)
        {
            var account = package.Account;

            if (account.IncomingProcessing != true ||
                account.CreateLead != true)
            {
                return(false);
            }

            var message = package.Message;

            if (!string.IsNullOrEmpty(message.Exception) ||
                message.IsIncome != true ||
                message.RefNoteID != null ||
                message.ClassID == CRActivityClass.EmailRouting)
            {
                return(false);
            }

            var copy = package.Graph.Caches[typeof(CRSMEmail)].CreateCopy(message);

            try
            {
                LeadMaint graph     = PXGraph.CreateInstance <LeadMaint>();
                var       leadCache = graph.Lead.Cache;
                var       lead      = (CRLead)leadCache.Insert();
                lead = PXCache <CRLead> .CreateCopy(graph.Lead.Search <CRLead.contactID>(lead.ContactID));

                lead.EMail        = package.Address;
                lead.LastName     = package.Description;
                lead.RefContactID = message.ContactID;

                lead.OverrideRefContact = true;

                CREmailActivityMaint.EmailAddress address = CREmailActivityMaint.ParseNames(message.MailFrom);

                lead.FirstName = address.FirstName;
                lead.LastName  = string.IsNullOrEmpty(address.LastName) ? address.Email : address.LastName;
                if (account.CreateLeadClassID != null)
                {
                    lead.ClassID = account.CreateLeadClassID;
                }

                lead = (CRLead)leadCache.Update(lead);

                if (lead.ClassID != null)
                {
                    CRLeadClass cls = PXSelect <
                        CRLeadClass,
                        Where <
                            CRLeadClass.classID, Equal <Required <CRLeadClass.classID> > > >
                                      .SelectSingleBound(graph, null, lead.ClassID);

                    if (cls?.DefaultOwner == CRDefaultOwnerAttribute.Source)
                    {
                        lead.WorkgroupID = message.WorkgroupID;
                        lead.OwnerID     = message.OwnerID;
                    }
                }

                message.RefNoteID = PXNoteAttribute.GetNoteID <CRLead.noteID>(leadCache, lead);
                graph.Actions.PressSave();
            }
            catch (Exception e)
            {
                package.Graph.Caches[typeof(CRSMEmail)].RestoreCopy(message, copy);
                throw new PXException(Messages.CreateLeadException, e is PXOuterException ? ("\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages)) : e.Message);
            }

            return(true);
        }