Ejemplo n.º 1
0
        protected void FindOwner(PXGraph graph, Guid?ownerId, out Contact employee, out Users user)
        {
            employee = null;
            user     = null;
            if (ownerId == null)
            {
                return;
            }

            PXSelectJoin <Users,
                          LeftJoin <EPEmployee,
                                    On <EPEmployee.userID, Equal <Users.pKID> >,
                                    LeftJoin <Contact,
                                              On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                          Where <Users.pKID, Equal <Required <Users.pKID> > > >
            .Clear(graph);

            var row = (PXResult <Users, EPEmployee, Contact>) PXSelectJoin <Users,
                                                                            LeftJoin <EPEmployee,
                                                                                      On <EPEmployee.userID, Equal <Users.pKID> >,
                                                                                      LeftJoin <Contact,
                                                                                                On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                                                                            Where <Users.pKID, Equal <Required <Users.pKID> > > >
                      .Select(graph, ownerId);

            employee = (Contact)row;
            user     = (Users)row;
        }
        private List <MailAddress> GetOwnerAddress(PXGraph graph, int?bAccID)
        {
            PXSelectJoin <Users,
                          LeftJoin <EPEmployee,
                                    On <EPEmployee.userID, Equal <Users.pKID> >,
                                    LeftJoin <Contact,
                                              On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                          Where <Contact.bAccountID, Equal <Required <Contact.bAccountID> > > >
            .Clear(graph);

            var row = (PXResult <Users, EPEmployee, Contact>) PXSelectJoin <Users,
                                                                            LeftJoin <EPEmployee,
                                                                                      On <EPEmployee.userID, Equal <Users.pKID> >,
                                                                                      LeftJoin <Contact,
                                                                                                On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                                                                            Where <Contact.bAccountID, Equal <Required <Contact.bAccountID> > > >
                      .Select(graph, bAccID);

            if (row == null)
            {
                return(null);
            }
            var owner    = row.GetItem <Contact>();
            var user     = row.GetItem <Users>();
            var employee = row.GetItem <EPEmployee>();

            if (PreventEmailRoutingFor(user, employee))
            {
                return(null);
            }

            return(GenerateAddress(owner, user));
        }
Ejemplo n.º 3
0
        //TODO: need optimizae DB requests
        internal static bool IsFromInternalUser(PXGraph graph, CRSMEmail message)
        {
            var @from = Mailbox.Parse(message.MailFrom).With(_ => _.Address).With(_ => _.Trim());

            PXSelect <Users,
                      Where2 <Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                              And <Users.email, Equal <Required <Users.email> > > > > .
            Clear(graph);

            var usersEmail = (Users)PXSelect <Users,
                                              Where2 <Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                                                      And <Users.email, Equal <Required <Users.email> > > > > .
                             Select(graph, @from) != null;

            if (usersEmail)
            {
                return(true);
            }

            PXSelectJoin <EPEmployee,
                          LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                          Where <EPEmployee.userID, IsNotNull, And <Contact.eMail, Equal <Required <Contact.eMail> > > > > .
            Clear(graph);

            return((EPEmployee)PXSelectJoin <EPEmployee,
                                             LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                                             Where <EPEmployee.userID, IsNotNull, And <Contact.eMail, Equal <Required <Contact.eMail> > > > > .
                   Select(graph, @from) != null);
        }
Ejemplo n.º 4
0
        //TODO: need optimizae DB requests
        internal static bool?IsFromInternalUser(PXGraph graph, CRSMEmail message)
        {
            var @from = EmailParser.ParseAddresses(message.MailFrom).FirstOrDefault().With(_ => _?.Address).With(_ => _?.Trim());

            PXSelect <Users,
                      Where2 <
                          Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                          And <Users.email, Equal <Required <Users.email> > > > >
            .Clear(graph);

            var users = PXSelect <Users,
                                  Where2 <
                                      Where <Users.guest, Equal <False>, Or <Users.guest, IsNull> >,
                                      And <Users.email, Equal <Required <Users.email> > > > >
                        .Select(graph, @from);

            bool disabledUser = users.Count > 0 && users.RowCast <Users>().All(_ => _.State == Users.state.Disabled);

            if (disabledUser)
            {
                return(null);
            }

            if (users.Count > 0)
            {
                return(true);
            }

            PXSelectJoin <EPEmployee,
                          LeftJoin <Contact,
                                    On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                          Where <
                              EPEmployee.userID, IsNotNull,
                              And <Contact.eMail, Equal <Required <Contact.eMail> > > > >
            .Clear(graph);

            var employees = PXSelectJoin <EPEmployee,
                                          LeftJoin <Contact,
                                                    On <Contact.contactID, Equal <EPEmployee.defContactID> > >,
                                          Where <
                                              EPEmployee.userID, IsNotNull,
                                              And <Contact.eMail, Equal <Required <Contact.eMail> > > > >
                            .Select(graph, @from);

            bool disabledEmployee = employees.Count > 0 && employees.RowCast <EPEmployee>().All(_ => _.Status == EPEmployee.status.Inactive);

            if (disabledEmployee)
            {
                return(null);
            }

            if (employees.Count > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        private Mailbox GetOwnerAddress(PXGraph graph, int?bAccID)
        {
            PXSelectJoin <Users,
                          LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <Users.pKID> >,
                                    LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                          Where <Contact.bAccountID, Equal <Required <Contact.bAccountID> > > > .
            Clear(graph);

            var row = (PXResult <Users, EPEmployee, Contact>) PXSelectJoin <Users,
                                                                            LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <Users.pKID> >,
                                                                                      LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                                                                            Where <Contact.bAccountID, Equal <Required <Contact.bAccountID> > > > .
                      Select(graph, bAccID);

            var owner = (Contact)row;
            var user  = (Users)row;

            return(GenerateAddress(owner, user));
        }
        private Guid?GetKnownSender(PXGraph graph, CRSMEmail message)
        {
            var @from = Mailbox.Parse(message.MailFrom).With(_ => _.Address).With(_ => _.Trim());

            PXSelectJoin <EPEmployee,
                          InnerJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> >,
                                     InnerJoin <Users, On <Users.pKID, Equal <EPEmployee.userID> > > >,
                          Where <Contact.eMail, Equal <Required <Contact.eMail> > > > .
            Clear(graph);

            var employeeEmail = (EPEmployee)PXSelectJoin <EPEmployee,
                                                          InnerJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> >,
                                                                     InnerJoin <Users, On <Users.pKID, Equal <EPEmployee.userID> > > >,
                                                          Where <Contact.eMail, Equal <Required <Contact.eMail> > > > .
                                Select(graph, @from);

            if (employeeEmail != null)
            {
                return(employeeEmail.UserID);
            }

            return(null);
        }
Ejemplo n.º 7
0
        private void FindOwner(PXGraph graph, IAssign source, out Contact employee, out Users user)
        {
            employee = null;
            user     = null;
            if (source == null || source.OwnerID == null)
            {
                return;
            }

            PXSelectJoin <Users,
                          LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <Users.pKID> >,
                                    LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                          Where <Users.pKID, Equal <Required <Users.pKID> > > > .
            Clear(graph);

            var row = (PXResult <Users, EPEmployee, Contact>) PXSelectJoin <Users,
                                                                            LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <Users.pKID> >,
                                                                                      LeftJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID> > > >,
                                                                            Where <Users.pKID, Equal <Required <Users.pKID> > > > .
                      Select(graph, source.OwnerID);

            employee = (Contact)row;
            user     = (Users)row;
        }