private static CRPMTimeActivity CreateActivity(ProcessTranscript graph, ContactMaint contMaint,
                                                       TransScriptDetail transScriptDetail, CRPMTimeActivity activityData, string meetingText = null)
        {
            int minsConsumed = 0;

            if (string.IsNullOrEmpty(meetingText))
            {
                activityData.Body = GetTranscriptInfo(transScriptDetail, graph, out minsConsumed);
            }
            else
            {
                activityData.Body = meetingText;
            }

            activityData.TrackTime  = true;
            activityData.IsBillable = false;
            activityData.Summary    = transScriptDetail.Title;
            activityData.Subject    = transScriptDetail.Title;
            activityData.TimeSpent  = minsConsumed == 0 ? 1 : minsConsumed;
            activityData            = contMaint.Activities.Update(activityData);
            activityData.ProjectID  = 0;
            activityData            = contMaint.Activities.Update(activityData);

            contMaint.Persist();
            return(activityData);
        }
 protected virtual void TransferActivities(ContactMaint graph, Contact contact)
 {
     foreach (CRPMTimeActivity activity in Activities.Select())
     {
         activity.ContactID = contact.ContactID;
         graph.Activities.Update(activity);
     }
 }
        private static string CreateMTActivity(ProcessTranscript graph, ContactMaint contMaint, string emailContact,
                                               TransScriptDetail transScriptDetail)
        {
            contMaint.Clear();

            contMaint.Contact.Current = PXSelect <Contact,
                                                  Where <Contact.eMail, Equal <Required <Contact.eMail> > > > .Select(contMaint, emailContact);

            var activityData = contMaint.Activities.Insert();

            activityData.Type = "MT";

            activityData = CreateActivity(graph, contMaint, transScriptDetail, activityData);

            return(activityData.Body);
        }
        protected override void ReverseDocumentUpdate(ContactMaint graph, Contact entity)
        {
            // need for right update Documents
            //Base.Caches<Contact>().SetStatus(entity, PXEntryStatus.Inserted);

            var doc = Documents.Current;

            Documents.Cache.SetValue <Document.refContactID>(doc, entity.ContactID);
            graph.Caches <TMain>().Update(GetMain(doc));

            var contact = Contacts.Current ?? Contacts.SelectSingle();

            Contacts.Cache.SetValue <DocumentContact.firstName>(contact, entity.FirstName);
            Contacts.Cache.SetValue <DocumentContact.lastName>(contact, entity.LastName);
            Contacts.Cache.SetValue <DocumentContact.salutation>(contact, entity.Salutation);
            Contacts.Cache.SetValue <DocumentContact.phone1>(contact, entity.Phone1);
            Contacts.Cache.SetValue <DocumentContact.phone1Type>(contact, entity.Phone1Type);
            Contacts.Cache.SetValue <DocumentContact.email>(contact, entity.EMail);
            var contactMain = Contacts.Cache.GetMain(contact);

            graph.Caches[contactMain.GetType()].Update(contactMain);
        }
Beispiel #5
0
        /// <summary>
        /// If external logistic email doesn't exist in Acumatica contact, then create it.
        /// </summary>
        public static int?CreateSOContact(int?sOCustomeID, MyArray myArray)
        {
            ContactMaint contactGraph = PXGraph.CreateInstance <ContactMaint>();

            Contact origContact = SelectFrom <Contact> .Where <Contact.eMail.IsEqual <@P.AsString>
                                                               .And <Contact.bAccountID.IsEqual <@P.AsInt> > > .View.Select(contactGraph, myArray.BillingEmail, sOCustomeID);

            if (origContact == null)
            {
                Contact contact = contactGraph.ContactCurrent.Cache.CreateInstance() as Contact;

                contact.ContactType = ContactTypesAttribute.Person;
                contact.BAccountID  = sOCustomeID;
                contact.FirstName   = myArray.BillingFirstName;
                contact.LastName    = myArray.BillingLastName;
                contact.EMail       = myArray.BillingEmail;
                contact.Phone1      = myArray.BillingPhoneNumber;

                contactGraph.ContactCurrent.Insert(contact);

                Address address = contactGraph.AddressCurrent.Select();

                address.AddressLine1 = myArray.BillingAddress;
                address.AddressLine2 = myArray.BillingAddress2;
                address.City         = myArray.BillingCity;
                address.CountryID    = myArray.BillingCountry;
                address.PostalCode   = myArray.BillingZipCode;
                address.State        = myArray.BillingState;

                contactGraph.AddressCurrent.Update(address);

                contactGraph.Save.Press();
            }

            return(contactGraph.ContactCurrent.Current?.ContactID ?? origContact.ContactID);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ContactMaint         graph          = PXGraph.CreateInstance <ContactMaint>();
        var                  search_phone   = Request.QueryString["phone"];
        var                  default_callID = Request.QueryString["cid"];
        BusinessAccountMaint baccount_graph = PXGraph.CreateInstance <BusinessAccountMaint>();

        Int32?contactId   = null;
        Guid? contactGuid = null;

        var contacts = PXSelect <Contact,
                                 Where <Contact.phone1,
                                        Equal <Required <Contact.phone1> >,
                                        Or <Contact.phone2,
                                            Equal <Required <Contact.phone2> >,
                                            Or <Contact.phone3,
                                                Equal <Required <Contact.phone3> > > > > > .Select(graph, search_phone, search_phone, search_phone);

        // For now, just grab the first result
        if (contacts.Count() > 0)
        {
            var contact = ((Contact)contacts.First());
            contactName = contact.DisplayName;
            var customers = PXSelect <BAccount,
                                      Where <BAccount.bAccountID,
                                             Equal <Required <Contact.bAccountID> > > > .Select(graph, contact.BAccountID);

            // There should only be one bAccount that matches
            if (customers.Count() > 0)
            {
                accountCD = ((BAccount)customers.First()).AcctCD;
            }

            contactId   = contact.ContactID;
            contactGuid = contact.NoteID;
        }
        else
        {
            var contact = new Contact();
            contact.LastName = default_callID;
            contact.Phone1   = search_phone;
            contact          = graph.Contact.Insert(contact);
            //graph.Contact.Cache.Persist(PXDBOperation.Insert);
            graph.Save.Press();
            contactName = default_callID;

            contactId   = graph.Contact.Current.ContactID;
            contactGuid = graph.Contact.Current.NoteID;
        }

        // Save an audit record of the phone call
        var audit_graph = PXGraph.CreateInstance <PhoneAudit>();
        var audit       = new PhoneCallerAudit();

        audit.PhoneNubmer = search_phone;
        audit.CallerID    = contactName;
        audit.ContactID   = contactId;
        audit_graph.Audit.Insert(audit);
        audit_graph.Save.Press();

        CRActivityMaint activity_graph = PXGraph.CreateInstance <CRActivityMaint>();
        CRActivity      activity       = new CRActivity();

        activity           = activity_graph.Activities.Insert(activity);
        activity.Type      = "P";
        activity.Subject   = "Inbound Call";
        activity.OwnerID   = new Guid("B5344897-037E-4D58-B5C3-1BDFD0F47BF9");
        activity.ContactID = contactId;
        activity.RefNoteID = contactGuid;
        activity_graph.Activities.Update(activity);
        activity_graph.Save.Press();

        var json = string.Format("{{\"baccount\": \"{0}\", \"contact\": \"{1}\"}}", accountCD, contactName);

        Response.Clear();
        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(json);
        Response.End();
    }
        protected override Contact CreateMaster(ContactMaint graph, ContactConversionOptions _)
        {
            var entity           = Documents.Current;
            var param            = ContactInfo.Current;
            var docContact       = Contacts.Current ?? Contacts.SelectSingle();
            var docContactMethod = ContactMethod.Current ?? ContactMethod.SelectSingle();
            var docAddress       = Addresses.Current ?? Addresses.SelectSingle();

            Contact contact = new Contact
            {
                ContactType      = ContactTypesAttribute.Person,
                ParentBAccountID = entity.ParentBAccountID
            };

            MapContact(docContact, contact);
            MapConsentable(docContact, contact);

            contact.FirstName        = param.FirstName;
            contact.LastName         = param.LastName;
            contact.Salutation       = param.Salutation;
            contact.Phone1           = param.Phone1;
            contact.Phone1Type       = param.Phone1Type;
            contact.EMail            = param.Email;
            contact.ContactType      = ContactTypesAttribute.Person;
            contact.ParentBAccountID = entity.ParentBAccountID;
            contact.BAccountID       = entity.BAccountID;
            contact.Source           = entity.Source;

            MapContactMethod(docContactMethod, contact);

            var address = (Address)graph.AddressCurrent.Cache.CreateInstance();

            address = graph.AddressCurrent.Insert(address);

            contact = graph.Contact.Insert(contact);

            contact.ClassID = param.ContactClass;

            CRContactClass cls = PXSelect <
                CRContactClass,
                Where <
                    CRContactClass.classID, Equal <Required <CRContactClass.classID> > > >
                                 .SelectSingleBound(graph, null, contact.ClassID);

            if (cls?.DefaultOwner == CRDefaultOwnerAttribute.Source)
            {
                contact.WorkgroupID = entity.WorkgroupID;
                contact.OwnerID     = entity.OwnerID;
            }

            MapAddress(docAddress, address);

            address = (Address)graph.AddressCurrent.Cache.Update(address);

            contact.DefAddressID = address.AddressID;

            contact = graph.Contact.Update(contact);

            ReverseDocumentUpdate(graph, contact);

            FillRelations(graph.Relations, contact);

            FillAttributes(graph.Answers, contact);

            TransferActivities(graph, contact);

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

            PXNoteAttribute.CopyNoteAndFiles(graph.Caches <TMain>(), Documents.Cache.GetMain(entity), graph.Contact.Cache, contact, setup);

            return(graph.Contact.Update(contact));
        }
Beispiel #8
0
        public static void ProcessSurvey(List <SurveyContactInfo> contacts)
        {
            bool erroroccurred = false;

            ContactMaint graphNotification = PXGraph.CreateInstance <ContactMaint>();

            List <SurveyContactInfo> contactsToProceed = new List <SurveyContactInfo>(contacts);

            CaseSurveyHistoryMaint graph = PXGraph.CreateInstance <CaseSurveyHistoryMaint>();

            foreach (var rec in contactsToProceed)
            {
                try
                {
                    //Notification rowNotification = PXSelect<Notification, Where<Notification.notificationID, Equal<Required<Notification.notificationID>>>>.Select(graphNotification, rec.NotificationMapID);

                    //if (rowNotification == null)
                    //{
                    //    throw new PXException("Notification Template for Case Survey is not specified.");
                    //}

                    //Get From Address from Notification Template if not specified then use default
                    string sFromEmail = PX.Data.EP.MailAccountManager.GetDefaultEmailAccount().Address;
                    if (rec.NotificationNFrom.HasValue)
                    {
                        PX.SM.EMailAccount EMA = PXSelect <PX.SM.EMailAccount,
                                                           Where <PX.SM.EMailAccount.emailAccountID, Equal <Required <PX.SM.EMailAccount.emailAccountID> > > > .Select(graphNotification, rec.NotificationNFrom);

                        if (EMA != null)
                        {
                            sFromEmail = EMA.Address;
                        }
                    }

                    if (String.IsNullOrEmpty(sFromEmail))
                    {
                        throw new PXException("E-mail account is not setup to send Surveys.");
                    }

                    if (!String.IsNullOrEmpty(rec.EMail))
                    {
                        AddEmailActivity(rec);

                        //Update Case Survey History
                        CaseSurveyHistory newCaseHistory = new CaseSurveyHistory();
                        newCaseHistory.ContactID = rec.ContactID;
                        newCaseHistory.OwnerID   = rec.CaseOwnerID;

                        graph.CaseSurveyHistoryRecord.Insert(newCaseHistory);
                        graph.Actions.PressSave();

                        PXProcessing <SurveyContactInfo> .SetInfo(contacts.IndexOf(rec),
                                                                  String.Format("Survey has been sent to {0}", rec.EMail));
                    }
                    else
                    {
                        erroroccurred = true;
                        PXProcessing <SurveyContactInfo> .SetError(contacts.IndexOf(rec),
                                                                   String.Format("E-mail address is not specified."));
                    }
                }
                catch (Exception e)
                {
                    erroroccurred = true;
                    PXProcessing <SurveyContactInfo> .SetError(contacts.IndexOf(rec), e);
                }
            }
            if (erroroccurred)
            {
                throw new PXException("At least one Survey hasn't been processed.");
            }
        }