public override void Process() { String username = CurrentSite.Configuration.Salesforce.Username; String password = CurrentSite.Configuration.Salesforce.Password; String token = CurrentSite.Configuration.Salesforce.Token; String apiPassword = password + token; SalesforcePartnerClient client = new SalesforcePartnerClient(); try { client.Login(username, apiPassword); client.AddLead(base.FormFields, CurrentSite.Configuration.Salesforce.CustomFieldMappings); client.Logout(); } catch (Exception e) { } }
private static void AddSalesforceLead(Registration registration, CmsSubscription subscription) { try { if (GooeyConfigManager.Salesforce.IsEnabled) { Dictionary<String, String> fields = new Dictionary<string, string>(); fields.Add("FirstName", registration.Firstname); fields.Add("LastName", registration.Lastname); fields.Add("Company", registration.Company); fields.Add("Email", registration.Email); fields.Add("Gooey_CMS_Site__c", registration.Sitename + ".gooeycms.net"); fields.Add("subscription_type__c", subscription.SubscriptionPlanSku); fields.Add("PayPal_Profile__c", subscription.PaypalProfileId); fields.Add("Subscription_ID__c", subscription.Guid); SalesforcePartnerClient salesforce = new SalesforcePartnerClient(); try { salesforce.Login(GooeyConfigManager.Salesforce.SalesforceUsername, GooeyConfigManager.Salesforce.ApiPassword); salesforce.AddLead(fields, null); } finally { salesforce.Logout(); } } else { Logging.Database.Write("salesforce-client", "Salesforce has not been setup for tracking registration leads"); } } catch (Exception e) { Logging.Database.Write("salesforce-client", "Failed to create the salesforce lead:" + e.Message); } }
private void InsertSalesforceLead() { Boolean enabled = false; String temp = base.GetSiteConfigurationValue("salesforce-enabled"); Boolean.TryParse(temp, out enabled); if (CurrentSite.Configuration.Salesforce.IsEnabled) { String username = CurrentSite.Configuration.Salesforce.Username; String password = CurrentSite.Configuration.Salesforce.Password; String token = CurrentSite.Configuration.Salesforce.Token; String apiPassword = password + token; SalesforcePartnerClient client = new SalesforcePartnerClient(); String firstname = base.CallName; String lastname = ""; String[] arr = base.CallName.Split(' '); if (arr.Length >= 2) { firstname = arr[1]; lastname = arr[0]; } Dictionary<String, String> fields = new Dictionary<string, string>(); fields.Add("Phone", base.CallFromNumber); fields.Add("FirstName", firstname); fields.Add("LastName", lastname); fields.Add("PostalCode", base.CallFromZip); fields.Add("City", base.CallFromCity); fields.Add("State", base.CallFromState); fields.Add("Description", UtcDateTime.Now + Environment.NewLine + "Customer call received from " + CurrentSite.ProductionDomain + Environment.NewLine + "Campaign: " + base.GetAssociatedCampaign().Name + " (" + base.GetAssociatedCampaign().TrackingCode + ")"); try { client.Login(username,apiPassword); client.AddLead(fields, CurrentSite.Configuration.Salesforce.CustomFieldMappings); client.Logout(); } catch (Exception) { } } }