protected override bool Process(Package package)
        {
            var account = package.Account;

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

            var message = package.Message;

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


            var graph = package.Graph;

            PXSelect <CRCase,
                      Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
            Clear(graph);

            var @case = (CRCase)PXSelect <CRCase,
                                          Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
                        Select(graph, message.RefNoteID);

            if (@case == null || @case.CaseID == null)
            {
                return(false);
            }

            if (!RouterEmailProcessor.IsFromInternalUser(graph, message) &&
                (@case.MajorStatus == CRCaseMajorStatusesAttribute._PENDING_CUSTOMER ||
                 @case.Resolution == CRCaseResolutionsAttribute._CUSTOMER_PRECLOSED))
            {
                var caseCache = graph.Caches[typeof(CRCase)];
                var newCase   = (CRCase)caseCache.CreateCopy(@case);
                newCase.MajorStatus = CRCaseMajorStatusesAttribute._OPEN;
                newCase.Status      = CRCaseStatusesAttribute._OPEN;
                newCase.Resolution  = CRCaseResolutionsAttribute._CUSTOMER_REPLIED;
                newCase             = (CRCase)caseCache.Update(newCase);
                PersistRecord(package, newCase);
            }

            return(true);
        }
        protected override bool Process(Package package)
        {
            var account = package.Account;

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

            var message = package.Message;

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


            var graph = package.Graph;

            PXSelect <CRCase,
                      Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
            Clear(graph);

            var @case = (CRCase)PXSelect <CRCase,
                                          Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
                        Select(graph, message.RefNoteID);

            if (@case == null || @case.CaseID == null)
            {
                return(false);
            }
            if (@case != null && message.OwnerID == null && account.EmailAccountType == PX.SM.EmailAccountTypesAttribute.Standard)
            {
                try
                {
                    message.WorkgroupID = @case.WorkgroupID;
                    graph.Caches[typeof(CRSMEmail)].SetValueExt <CRSMEmail.ownerID>(message, @case.OwnerID);
                }
                catch (PXSetPropertyException)
                {
                    message.OwnerID = null;
                }
            }

            if (!RouterEmailProcessor.IsOwnerEqualUser(graph, message, @case.OwnerID) &&
                (@case.MajorStatus != CRCaseMajorStatusesAttribute._CLOSED &&
                 @case.MajorStatus != CRCaseMajorStatusesAttribute._RELEASED &&
                 @case.Released != true && (@case.Status == CRCaseStatusesAttribute._PENDING_CUSTOMER || @case.Status == CRCaseStatusesAttribute._OPEN)))
            {
                var caseCache = graph.Caches[typeof(CRCase)];
                var newCase   = (CRCase)caseCache.CreateCopy(@case);
                newCase.MajorStatus = CRCaseMajorStatusesAttribute._OPEN;
                newCase.Status      = CRCaseStatusesAttribute._OPEN;
                newCase.Resolution  = CRCaseResolutionsAttribute._CUSTOMER_REPLIED;
                newCase             = (CRCase)caseCache.Update(newCase);
                PersistRecord(package, newCase);
            }

            return(true);
        }
Example #3
0
        protected override bool Process(Package package)
        {
            var account = package.Account;

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

            var message = package.Message;

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


            var graph = package.Graph;

            PXSelect <CRCase,
                      Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
            Clear(graph);

            var @case = (CRCase)PXSelect <CRCase,
                                          Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > .
                        Select(graph, message.RefNoteID);

            if (@case == null || @case.CaseCD == null)
            {
                return(false);
            }
            if (@case != null && message.OwnerID == null && account.EmailAccountType == PX.SM.EmailAccountTypesAttribute.Standard)
            {
                try
                {
                    message.WorkgroupID = @case.WorkgroupID;
                    graph.Caches[typeof(CRSMEmail)].SetValueExt <CRSMEmail.ownerID>(message, @case.OwnerID);
                }
                catch (PXSetPropertyException)
                {
                    message.OwnerID = null;
                }
            }

            CRCaseClass caseClass = new PXSelect <CRCaseClass, Where <CRCaseClass.caseClassID, Equal <Required <CRCaseClass.caseClassID> > > >(graph)
                                    .SelectWindowed(0, 1, @case.CaseClassID);


            if (!RouterEmailProcessor.IsOwnerEqualUser(graph, message, @case.OwnerID) &&
                @case.Released != true &&
                (@case.IsActive == true || CaseShouldBeReopenedByDate()))
            {
                var caseMaint = PXGraph.CreateInstance <CRCaseMaint>();
                caseMaint.Case.Current = caseMaint.Case.Cache.CreateCopy(@case) as CRCase;
                caseMaint.GetExtension <Workflows.CaseWorkflow>().openCaseFromProcessing.Press();
            }

            return(true);

            bool CaseShouldBeReopenedByDate()
            {
                return(@case.ResolutionDate is DateTime resolutionDate &&
                       caseClass?.ReopenCaseTimeInDays is int reopenDays && reopenDays > 0
                                        ? PX.Common.PXTimeZoneInfo.Now - resolutionDate < TimeSpan.FromDays(reopenDays)
                                        : false);
            }
        }