//***** MHM Contacts *************// private void loadLeadConversionEventsArray(string jsonData) { if (leadConversionEventsArray == null) { this.leadConversionEventsArray = new List<HubSpotLeadConversionEvent>(); } JArray records = JArray.Parse(Record["leadConversionEvents"].ToString().Trim()); foreach (JObject record in records) { HubSpotLeadConversionEvent leadConversionEvent = new HubSpotLeadConversionEvent(record); leadConversionEventsArray.Add(leadConversionEvent); } }
private void updLeadEvent(string strGuid, HubSpotLeadConversionEvent leadConversionEvent) { HubSpotMap mapCONTSUPP = getMap("CONTSUPP"); USQLServer.openConnection(SQLConnection); string query = "UPDATE CONTSUPP SET "; foreach (DictionaryEntry entry in mapCONTSUPP.Items) { HubSpotMapItem item = (HubSpotMapItem)entry.Value; if (!String.IsNullOrEmpty(item.HubSpotFieldName)) { query += item.CRMFieldName + " = @" + item.CRMFieldName + ", "; if (item.HubSpotFieldName.Equals("convertDate", StringComparison.OrdinalIgnoreCase)) query += "CITY = SUBSTRING(CITY, 1, 8) + '" + SLX_Data.dateTimeToISODateString(leadConversionEvent.getDateTimeValueInLocalTime(item.HubSpotFieldName)).Substring(0, 10).Replace("-", "") + "', "; } } 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 (!String.IsNullOrEmpty(item.HubSpotFieldName)) { if (item.HubSpotFieldName.Equals("convertDate", StringComparison.OrdinalIgnoreCase)) strValue = SLX_Data.dateTimeToISODateString(leadConversionEvent.getDateTimeValueInLocalTime(item.HubSpotFieldName)); else strValue = leadConversionEvent.getStringValue(item.HubSpotFieldName); 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(), "Leads to HubSpot Query: " + ex.Message); } USQLServer.closeConnection(SQLConnection); }