Esempio n. 1
0
        private void loadContactForm_SubmissionArray(string jsonData)
        {
            if (ContactForm_SubmissionArray == null)
            {
                this.ContactForm_SubmissionArray = new List<HubSpotContactForm_Submission>();
            }

            JArray records = JArray.Parse(jsonData);

            foreach (JObject record in records)
            {
                HubSpotContactForm_Submission ContactForm_Submission = new HubSpotContactForm_Submission(record);

                ContactForm_SubmissionArray.Add(ContactForm_Submission);
            }
        }
Esempio n. 2
0
        private void updLeadContactEvent(string strGuid, HubSpotContactForm_Submission contactForm_Submission)
        {
            HubSpotMap mapCONTSUPP = getMap("CONTSUPP");

            USQLServer.openConnection(SQLConnection);
            string query = "UPDATE CONTSUPP SET ";

            foreach (DictionaryEntry entry in mapCONTSUPP.Items)
            {
                HubSpotMapItem item = (HubSpotMapItem)entry.Value;
                if (item.CRMFieldName.Equals("zip", StringComparison.OrdinalIgnoreCase) ||
                    //item.CRMFieldName.Equals("ext", StringComparison.OrdinalIgnoreCase) ||
                    item.CRMFieldName.Equals("contsupref", StringComparison.OrdinalIgnoreCase) ||
                    item.CRMFieldName.Equals("ADDRESS1", StringComparison.OrdinalIgnoreCase) ||
                    item.CRMFieldName.Equals("COUNTRY", StringComparison.OrdinalIgnoreCase))
                {
                    query += item.CRMFieldName + " = @" + item.CRMFieldName + ", ";
                }
            }

            query = query.Remove(query.LastIndexOf(","));

            query += " where RECTYPE='P' and contact='HubSpot' and Address2='" + strGuid + "'";

            SqlCommand updateCmd = new SqlCommand(query, SQLConnection);

            string strValue = "";
            SqlParameter parm;
            foreach (DictionaryEntry entry in mapCONTSUPP.Items)
            {
                HubSpotMapItem item = (HubSpotMapItem)entry.Value;
                if (item.CRMFieldName.Equals("zip", StringComparison.OrdinalIgnoreCase) ||
                   //item.CRMFieldName.Equals("ext", StringComparison.OrdinalIgnoreCase) ||
                   item.CRMFieldName.Equals("contsupref", StringComparison.OrdinalIgnoreCase) ||
                   item.CRMFieldName.Equals("ADDRESS1", StringComparison.OrdinalIgnoreCase) ||
                   item.CRMFieldName.Equals("COUNTRY", StringComparison.OrdinalIgnoreCase))
                {
                    if (item.CRMFieldName.Equals("zip", StringComparison.OrdinalIgnoreCase))
                        strValue = SLX_Data.dateTimeToISODateString(contactForm_Submission.TimeStamp);
                    else if (item.CRMFieldName.Equals("ext", StringComparison.OrdinalIgnoreCase))
                        strValue = contactForm_Submission.Form_Id;
                    else if (item.CRMFieldName.Equals("contsupref", StringComparison.OrdinalIgnoreCase))
                        strValue = contactForm_Submission.Title;
                    else if (item.CRMFieldName.Equals("ADDRESS1", StringComparison.OrdinalIgnoreCase))
                        strValue = contactForm_Submission.Page_Title;
                    else if (item.CRMFieldName.Equals("COUNTRY", StringComparison.OrdinalIgnoreCase))
                        strValue = contactForm_Submission.Portal_Id;
                    else
                        strValue = "";

                    if (item.CrmDataType.Equals("NText", StringComparison.OrdinalIgnoreCase))
                        parm = new SqlParameter("@" + item.CRMFieldName, SqlDbType.NText);
                    else if (item.CrmDataType.Equals("Text", StringComparison.OrdinalIgnoreCase))
                        parm = new SqlParameter("@" + item.CRMFieldName, SqlDbType.Text);
                    else
                        parm = new SqlParameter("@" + item.CRMFieldName, SqlDbType.VarChar);
                    parm.Value = getTrimValue(strValue, item.MaxLength, item.CrmDataType);
                    updateCmd.Parameters.Add(parm);
                }
            }

            try
            {
                //USQLServer.executeCommand(updateCmd, SQLConnection);
                updateCmd.ExecuteNonQuery();
                updateCmd.Dispose();
            }

            catch (System.Web.Services.Protocols.SoapException ex)
            {
                ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "Contact to HubSpot Query: " + ex.Message);
            }

            USQLServer.closeConnection(SQLConnection);
        }