Пример #1
0
        private void insertHubspotLeadConversionEventRecord(int leadId, HubSpotLead leadRecord)
        {
            Dictionary<string, int> trimMap = getTrimMap(getMap("LeadConversionEvent"));
            ArrayList guids = new ArrayList();
            string sqlQuery = "conv_leadid = " + leadId + ""; //Didn't include criteria to check for records that haven't been deleted on purpose. We want all guids added to the list regardless of whether they have been deleted.
            queryresult entityResult = binding.query(sqlQuery, "LeadConversionEvent");
            ewarebase[] leadConversionEventBase = entityResult.records;

            if (leadConversionEventBase != null)
            {
                //ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "leadConversionEventBase.Length: " + leadId + " - " + leadConversionEventBase.Length);

                for(int i = 0; i < leadConversionEventBase.Length; i++)
                {
                    leadconversionevent leadConversionEvent = (leadconversionevent)leadConversionEventBase[i];

                    if(guids.Contains(leadConversionEvent.guid) == false)
                    {
                        guids.Add(leadConversionEvent.guid);
                    }
                }
            }

            int counter = 0;
            List<ewarebase> CRMBase = new List<ewarebase>();
            ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "leadRecord.LeadConversionEvents.Count: " + leadId + " - " + leadRecord.LeadConversionEvents.Count);
            foreach (HubSpotLeadConversionEvent leadConversionEvent in leadRecord.LeadConversionEvents)
            {
                if (guids.Contains(leadConversionEvent.getStringValue("guid")) == false)
                {
                    leadconversionevent CRMLeadConversionEvent = new leadconversionevent();

                    CRMLeadConversionEvent.leadid = leadId;
                    CRMLeadConversionEvent.leadidSpecified = true;
                    CRMLeadConversionEvent.conversiondate = leadConversionEvent.getDateTimeValueInLocalTime("convertDate");
                    CRMLeadConversionEvent.conversiondateSpecified = true;
                    CRMLeadConversionEvent.formid = getTrimmedValue(trimMap, "FORMID", leadConversionEvent.getStringValue("formId"));
                    CRMLeadConversionEvent.formguid = getTrimmedValue(trimMap, "FORMGUID", leadConversionEvent.getStringValue("formGuid"));
                    CRMLeadConversionEvent.formname = getTrimmedValue(trimMap, "FORMNAME", leadConversionEvent.getStringValue("formName"));
                    CRMLeadConversionEvent.formvalues = leadConversionEvent.FormValuesString.Replace("/n/r", Environment.NewLine).Replace("/n", Environment.NewLine);
                    CRMLeadConversionEvent.guid = getTrimmedValue(trimMap, "GUID", leadConversionEvent.getStringValue("guid"));
                    CRMLeadConversionEvent.leadguid = getTrimmedValue(trimMap, "LEADGUID", leadConversionEvent.getStringValue("leadGuid"));
                    CRMLeadConversionEvent.pagename = getTrimmedValue(trimMap, "PAGENAME", leadConversionEvent.getStringValue("pageName"));
                    CRMLeadConversionEvent.pagetype = getTrimmedValue(trimMap, "PAGETYPE", leadConversionEvent.getStringValue("pageType"));
                    CRMLeadConversionEvent.pageurl = getTrimmedValue(trimMap, "PAGEURL", leadConversionEvent.getStringValue("pageUrl"));
                    CRMLeadConversionEvent.portalid = getTrimmedValue(trimMap, "PORTALID", leadConversionEvent.getStringValue("portalId"));

                    CRMBase.Add(CRMLeadConversionEvent);

                    counter++;
                }
            }

            if (CRMBase.Count > 0)
            {
                try
                {
                    addresult CRMAddResult = binding.add("LeadConversionEvent", CRMBase.ToArray());
                }
                catch (Exception e)
                {
                    ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "EXCEPTION IN insertHubspotLeadConversionEventRecord", e);
                }
            }
        }
Пример #2
0
        private void insertContactHubspotForm_SubmissionRecord(int leadId, HubSpotLead aContactRecord)
        {
            HubSpotMap LeadConversionEvent = getMap("LeadConversionEvent");

            ArrayList guids = new ArrayList();
            string sqlQuery = "conv_leadid = " + leadId + ""; //Didn't include criteria to check for records that haven't been deleted on purpose. We want all guids added to the list regardless of whether they have been deleted.
            queryresult entityResult = binding.query(sqlQuery, "LeadConversionEvent");
            ewarebase[] leadConversionEventBase = entityResult.records;

            if (leadConversionEventBase != null)
            {
                //ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "leadConversionEventBase.Length: " + leadId + " - " + leadConversionEventBase.Length);

                for (int i = 0; i < leadConversionEventBase.Length; i++)
                {
                    leadconversionevent leadConversionEvent = (leadconversionevent)leadConversionEventBase[i];

                    if (guids.Contains(leadConversionEvent.guid) == false)
                    {
                        guids.Add(leadConversionEvent.guid);
                    }
                }
            }

            int counter = 0;
            List<ewarebase> CRMBase = new List<ewarebase>();

            ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "contactRecord.ContactForm_Submission.Count: " + leadId + " - " + aContactRecord.ContactForm_Submissions.Count);
            foreach (HubSpotContactForm_Submission contactForm_Submission in aContactRecord.ContactForm_Submissions)
            {
                if (guids.Contains(contactForm_Submission.Conversion_Id) == false)
                {
                    leadconversionevent CRMLeadConversionEvent = new leadconversionevent();

                    CRMLeadConversionEvent.leadid = leadId;
                    CRMLeadConversionEvent.leadidSpecified = true;
                    CRMLeadConversionEvent.conversiondate = contactForm_Submission.TimeStamp;
                    CRMLeadConversionEvent.conversiondateSpecified = true;
                    CRMLeadConversionEvent.formid = getTrimValue(LeadConversionEvent.getItem("formid"), contactForm_Submission.Form_Id);
                    CRMLeadConversionEvent.formguid = getTrimValue(LeadConversionEvent.getItem("formguid"), contactForm_Submission.Form_Id);
                    CRMLeadConversionEvent.formname = getTrimValue(LeadConversionEvent.getItem("formname"), contactForm_Submission.Page_Title);
                    CRMLeadConversionEvent.formvalues = buildFormValues(contactForm_Submission.Conversion_Id, aContactRecord); //leadConversionEvent.FormValuesString.Replace("/n/r", Environment.NewLine).Replace("/n", Environment.NewLine);
                    CRMLeadConversionEvent.guid = getTrimValue(LeadConversionEvent.getItem("guid"), contactForm_Submission.Conversion_Id);
                    CRMLeadConversionEvent.leadguid = getTrimValue(LeadConversionEvent.getItem("LEADGUID"), aContactRecord.ContactDetailRecord.getStringValue("vid"));
                    CRMLeadConversionEvent.pagename = getTrimValue(LeadConversionEvent.getItem("pagename"), contactForm_Submission.Page_Title);
                    CRMLeadConversionEvent.pagetype = getTrimValue(LeadConversionEvent.getItem("pagetype"), contactForm_Submission.Page_Id);
                    CRMLeadConversionEvent.pageurl = getTrimValue(LeadConversionEvent.getItem("pageurl"), contactForm_Submission.Page_Url);
                    CRMLeadConversionEvent.portalid = getTrimValue(LeadConversionEvent.getItem("portalid"), contactForm_Submission.Portal_Id);

                    CRMBase.Add(CRMLeadConversionEvent);

                    counter++;
                }
            }

            if (CRMBase.Count > 0)
            {
                try
                {
                    addresult CRMAddResult = binding.add("LeadConversionEvent", CRMBase.ToArray());
                }
                catch (Exception e)
                {
                    ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "EXCEPTION IN insertHubspotContactForm_SubmissionRecord", e);
                }
            }
        }