public void CreateSalesForceQualifiedAmbassador(Ambassador__c QualifiedAmbassador) { SforceService SfdcBinding = SalesForceSession(); try { //Campaign compaign = new Campaign(); //compaign.Name="IndiaHicks"; //sfdcLead.c = compaign; SaveResult[] saveResults = SfdcBinding.create(new sObject[] { QualifiedAmbassador }); if (saveResults[0].success) { string Id = ""; Id = saveResults[0].id; } else { string result = ""; result = saveResults[0].errors[0].message; } } catch (Exception) { throw; } }
public void UpateSalesForceQualifiedAmbassador(Ambassador__c QualifiedAmbassador) { SforceService SfdcBinding = SalesForceSession(); Ambassador__c sfdcQualifiedAmbassador = new Ambassador__c(); if (QualifiedAmbassador.Available_To_Receive_Leads__cSpecified) { sfdcQualifiedAmbassador = QualifiedAmbassador; sfdcQualifiedAmbassador.Available_To_Receive_Leads__c = true; sfdcQualifiedAmbassador.Available_To_Receive_Leads__cSpecified = true; } else { sfdcQualifiedAmbassador.Id = QualifiedAmbassador.Id; sfdcQualifiedAmbassador.Name = QualifiedAmbassador.Name; sfdcQualifiedAmbassador.Zip_Code__c = QualifiedAmbassador.Zip_Code__c; sfdcQualifiedAmbassador.Q_Ambassador_Email__c = QualifiedAmbassador.Q_Ambassador_Email__c; sfdcQualifiedAmbassador.Available_To_Receive_Leads__c = false; sfdcQualifiedAmbassador.Available_To_Receive_Leads__cSpecified = true; } try { //Campaign compaign = new Campaign(); //compaign.Name="IndiaHicks"; //sfdcLead.c = compaign; SaveResult[] saveResults = SfdcBinding.update(new sObject[] { sfdcQualifiedAmbassador }); if (saveResults[0].success) { string Id = ""; Id = saveResults[0].id; } else { string result = ""; result = saveResults[0].errors[0].message; } } catch (Exception) { throw; } }
public void SalesForceQualifiedAmbassadors() { SforceService SfdcBinding = SalesForceSession(); // GET LIST OF Qualified Ambassadors FROM DATABASE AND INSERT INTO sALESFORCE List <QualifiedAmbassadors> customers = new List <QualifiedAmbassadors>(); using (var context = Exigo.Sql()) { string sqlQuery = string.Format(@"select * from dbo.AmbassadorsList order by customerid asc "); customers = context.Query <QualifiedAmbassadors>(sqlQuery).ToList(); } if (customers.Count() == 0) { return; } List <Ambassador__c> Ambassador = new List <Ambassador__c>(); foreach (QualifiedAmbassadors Customer in customers) { Ambassador__c node = new Ambassador__c(); node.AmbassadorID__c = Customer.CustomerID.ToString(); node.Name = Customer.FirstName + " " + Customer.LastName; if (!string.IsNullOrEmpty(Customer.JoinDate)) { try { node.JoinDate__cSpecified = true; node.JoinDate__c = DateTime.Parse(Customer.JoinDate); } catch (Exception) { } } if (!string.IsNullOrEmpty(Customer.LeaveDate)) { try { node.LeaveDate__cSpecified = true; node.LeaveDate__c = DateTime.Parse(Customer.LeaveDate); } catch (Exception) { } } node.webalias__c = Customer.WebAlias; node.Q_Ambassador_Email__c = Customer.email; node.Zip_Code__c = Customer.MainZip; node.Phone__c = Customer.phone; node.Mobile_Phone__c = Customer.MobilePhone; node.SponsorID__cSpecified = true; node.SponsorID__c = double.Parse(Customer.EnrollerID.ToString()); node.Available_To_Receive_Leads__cSpecified = true; node.Available_To_Receive_Leads__c = true; node.CreatedDate = DateTime.Now; // node.CreatedById = "00536000000zbwiAAA"; Ambassador.Add(node); } if (Ambassador.Count > 0) { try { IEnumerable <List <Ambassador__c> > listambassadorlist = splitList(Ambassador.ToList()); foreach (List <Ambassador__c> list in listambassadorlist) { SaveResult[] saveResults = SfdcBinding.create(list.ToArray()); if (saveResults[0].success) { string Id = ""; Id = saveResults[0].id; } else { string result = ""; result = saveResults[0].errors[0].message; } } } catch (Exception ex) { throw; } } }