Exemplo n.º 1
0
        protected void forward()
        {
            CRSMEmail item = Emails.Current;

            if (item == null)
            {
                return;
            }

            CREmailActivityMaint graph = CreateInstance <CREmailActivityMaint>();

            graph.Message.Current = graph.Message.Search <CRSMEmail.noteID>(item.NoteID);
            graph.Forward.Press();
        }
Exemplo n.º 2
0
        public virtual void replyAll()
        {
            CRSMEmail item = Emails.Current;

            if (item == null)
            {
                return;
            }

            CREmailActivityMaint graph = CreateInstance <CREmailActivityMaint>();

            graph.Message.Current = graph.Message.Search <CRSMEmail.noteID>(item.NoteID);
            graph.ReplyAll.Press();
        }
Exemplo n.º 3
0
        public virtual void editRecord()
        {
            CRSMEmail item = Emails.Current;

            if (item == null)
            {
                return;
            }

            CREmailActivityMaint graph = CreateInstance <CREmailActivityMaint>();

            graph.Message.Current = graph.Message.Search <CRSMEmail.noteID>(item.NoteID);
            PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.InlineWindow);
        }
Exemplo n.º 4
0
        private PXResult <CRSMEmail, EMailAccount, EPView> GetActivityResult(CRSMEmail a)
        {
            EMailAccount acc = PXSelectReadonly <EMailAccount,
                                                 Where <EMailAccount.emailAccountID, Equal <Required <CRSMEmail.mailAccountID> > > > .Select(this, a.MailAccountID);

            EPView v = PXSelectReadonly <EPView,
                                         Where <Required <CRSMEmail.noteID>, Equal <EPView.noteID>,
                                                And <Required <CRSMEmail.ownerID>, Equal <EPView.userID> > > > .Select(this, a.NoteID, a.OwnerID);

            return(new PXResult <CRSMEmail, EMailAccount, EPView>(a, acc ?? new EMailAccount {
                EmailAccountID = a.MailAccountID
            }, v ?? new EPView {
                NoteID = a.NoteID, UserID = a.OwnerID
            }));
        }
        public virtual IEnumerable relate(PXAdapter adapter)
        {
            bool lint = entityFilter.AskExt() == WebDialogResult.OK && entityFilter.VerifyRequired();

            if (lint)
            {
                PXCache       cache            = this.Caches <CRSMEmail>();
                RelatedEntity relatedEntity    = entityFilter.Current;
                EntityHelper  helper           = new EntityHelper(this);
                Type          entityType       = PXBuildManager.GetType(relatedEntity.Type, false);
                object        row              = helper.GetEntityRow(entityType, relatedEntity.RefNoteID);
                Type          graphType        = helper.GetPrimaryGraphType(row, false);
                Type          actualEntityType = PXSubstManager.Substitute(entityType, graphType);
                object        actualRow        = helper.GetEntityRow(actualEntityType, relatedEntity.RefNoteID);
                PXGraph       graph            = PXGraph.CreateInstance(graphType);
                graph.Caches[actualEntityType].Current = actualRow;
                foreach (PXResult <CRSMEmail, EMailAccount, EPView> email in SelectedList())
                {
                    ((CRSMEmail)email).Selected = false;
                    CRSMEmail copy = PXCache <CRSMEmail> .CreateCopy(email);

                    CRActivity newActivity = (CRActivity)graph.Caches[typeof(CRActivity)].Insert();

                    copy.BAccountID = newActivity.BAccountID;
                    copy.ContactID  = newActivity.ContactID;
                    copy.RefNoteID  = newActivity.RefNoteID;
                    copy.MPStatus   = MailStatusListAttribute.Processed;
                    copy.Exception  = null;
                    PXRefNoteSelectorAttribute.EnsureNotePersistence(this, entityFilter.Current.Type, entityFilter.Current.RefNoteID);
                    copy = (CRSMEmail)cache.Update(copy);
                }
                Save.Press();
            }
            else
            {
                entityFilter.Ask(Messages.Warning, Messages.SelectRecord, MessageButtons.OK);
            }

            Emails.Cache.IsDirty = false;
            Emails.Cache.Clear();
            Emails.Cache.ClearQueryCacheObsolete();
            Emails.View.RequestRefresh();
            return(adapter.Get());
        }
        protected virtual IEnumerable MarkAs(PXAdapter adapter, int status, IEnumerable <PXResult <CRSMEmail, EMailAccount, EPView> > messages)
        {
            foreach (PXResult <CRSMEmail, EMailAccount, EPView> r in messages)
            {
                CRSMEmail email   = r;
                EPView    vstatus = r;

                email.Selected = false;
                object owner = Emails.Cache.GetValueExt <CRSMEmail.ownerID>(email);
                if (owner is PXFieldState)
                {
                    owner = ((PXFieldState)owner).Value;
                }

                if ((owner == null || email.OwnerID != Accessinfo.UserID) && vstatus.Status != status)
                {
                    Emails.Cache.RaiseExceptionHandling <CRSMEmail.selected>(email, null, new PXSetPropertyException(Messages.OnlyOwnerSetReadStatus, PXErrorLevel.RowWarning, new EPViewStatusAttribute().ValueLabelDic[status]));
                }
                else if (status == EPViewStatusAttribute.VIEWED
                                                        ? vstatus.Status != EPViewStatusAttribute.VIEWED
                                                        : vstatus.Status == EPViewStatusAttribute.VIEWED)
                {
                    vstatus = PXCache <EPView> .CreateCopy(vstatus);

                    vstatus.UserID = email.OwnerID;
                    vstatus.NoteID = email.NoteID;
                    vstatus.Status = status;
                    viewStatus.Update(vstatus);
                }
            }

            viewStatus.Cache.Persist(PXDBOperation.Insert);
            viewStatus.Cache.Persist(PXDBOperation.Update);

            Emails.Cache.IsDirty = false;
            return(adapter.Get());
        }