Preprocess bulk data transactions using SalesForce using .Net C #

I am new to SalesForce (3 months).

So far, I have been able to create a C # application that I can use to pre-insert and update the SalesForce database. These transactions are one at a time.

No. I need a large-scale transaction preform. For example, updating thousands of records at a time. Running them one at a time would quickly lead us to our dedicated API calls over a 24-hour period.

I want to use the available bulk transaction process to reduce the number of API calls. So far I have not been very lucky, and I have not found such documentation.

If anyone could either provide some general examples or send me reliable documentation on this, I would really appreciate it.

FYI, the data I must use to perform updates and inserts comes from the IBM Unidata database located on the AIX machine. Therefore, direct communication with web services is not possible. Getting data from Unidata was my headache. I did it. Now the api array for SalesForce is my new headache.

Thanks in advance.

Jeff

+3
source share
4 answers

You do not specify which API you are currently using, but with the help of a soap partner or corporate APIs, you can record entries in salesforce 200 at a time. (calls to create / update / upsert all take an array of SObjects).

Using the API array, you can send data to pieces of thousands of rows at a time.

You can find the documentation for both sets of APIs here.

+1

( SOAP-, Salesforce "Bulk API", )

Mighy , .

/// Demonstrates how to create one or more Account records via the API  

public void CreateAccountSample()
{
    Account account1 = new Account();
    Account account2 = new Account();

    // Set some fields on the account1 object. Name field is not set  

    // so this record should fail as it is a required field.  

    account1.BillingCity = "Wichita";
    account1.BillingCountry = "US";
    account1.BillingState = "KA";
    account1.BillingStreet = "4322 Haystack Boulevard";
    account1.BillingPostalCode = "87901";

    // Set some fields on the account2 object  

    account2.Name = "Golden Straw";
    account2.BillingCity = "Oakland";
    account2.BillingCountry = "US";
    account2.BillingState = "CA";
    account2.BillingStreet = "666 Raiders Boulevard";
    account2.BillingPostalCode = "97502";

    // Create an array of SObjects to hold the accounts  

    sObject[] accounts = new sObject[2];
    // Add the accounts to the SObject array  

    accounts[0] = account1;
    accounts[1] = account2;

    // Invoke the create() call  

    try
    {
        SaveResult[] saveResults = binding.create(accounts);

        // Handle the results  

        for (int i = 0; i < saveResults.Length; i++)
        {
            // Determine whether create() succeeded or had errors  

            if (saveResults[i].success)
            {
                // No errors, so retrieve the Id created for this record  

                Console.WriteLine("An Account was created with Id: {0}",
                    saveResults[i].id);
            }
            else
            {
                Console.WriteLine("Item {0} had an error updating", i);

                // Handle the errors  

                foreach (Error error in saveResults[i].errors)
                {
                    Console.WriteLine("Error code is: {0}",
                        error.statusCode.ToString());
                    Console.WriteLine("Error message: {0}", error.message);
                }
            }
        }
    }
    catch (SoapException e)
    {
        Console.WriteLine(e.Code);
        Console.WriteLine(e.Message);
    }
}
+1

- ; , , , API? Salesforce - , "", "" API . / - / , , .

+1

, , Salesforce # WSDL API. #. spiting, .

, | ( ). , <br>, \n .. ( )

, N , HTML/ . , , - , / . . .

.

private SforceService binding;                    // declare the salesforce servive using your access credential

try
                {
                    string stroppid = "111111111111111111";
                    System.Net.HttpWebRequest fr;
                    Uri targetUri = new Uri("http://abc.xyz.com/test.html");
                    fr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(targetUri);
                    if ((fr.GetResponse().ContentLength > 0))
                    {

                        System.IO.StreamReader str = new System.IO.StreamReader(fr.GetResponse().GetResponseStream());
                        string allrow = str.ReadToEnd();
                        string  stringSeparators = "<br>";

                        string[] row1 = Regex.Split(allrow, stringSeparators);
                        CDI_Order_Data__c[] cord = new CDI_Order_Data__c[row1.Length - 1];

                        for (int i = 1; i < row1.Length-1; i++)
                        {
                            string colstr = row1[i].ToString();
                            string[] allcols = Regex.Split(colstr, "\\|");

                                cord[i] = new CDI_Order_Data__c(); // Very important to create object
                                cord[i].Opportunity_Job_Order__c = stroppid;
                                cord[i].jobid__c = stroppid;
                                cord[i].order__c = allcols[0].ToString();
                                cord[i].firstname__c = allcols[1].ToString();
                                cord[i].name__c = allcols[2].ToString();
                                DateTime dtDate = Convert.ToDateTime(allcols[3]);
                                cord[i].Date__c = new DateTime(Convert.ToInt32(dtDate.Year), Convert.ToInt32(dtDate.Month), Convert.ToInt32(dtDate.Day), 0, 0, 0); //sforcedate(allcols[3]); //XMLstringToDate(allcols[3]);
                                cord[i].clientpo__c = allcols[4].ToString();
                                cord[i].billaddr1__c = allcols[5].ToString();
                                cord[i].billaddr2__c = allcols[6].ToString(); 
                                cord[i].billcity__c = allcols[7].ToString(); 
                                cord[i].billstate__c = allcols[8].ToString(); 
                                cord[i].billzip__c = allcols[9].ToString();
                                cord[i].phone__c = allcols[10].ToString(); 
                                cord[i].fax__c = allcols[11].ToString();
                                cord[i].email__c = allcols[12].ToString(); 
                                cord[i].contact__c = allcols[13].ToString(); 
                                cord[i].lastname__c = allcols[15].ToString(); 
                                cord[i].Rep__c = allcols[16].ToString(); 
                                cord[i].sidemark__c = allcols[17].ToString(); 
                                cord[i].account__c = allcols[18].ToString(); 
                                cord[i].item__c = allcols[19].ToString(); 
                                cord[i].kmatid__c = allcols[20].ToString(); 
                                cord[i].qty__c = Convert.ToDouble(allcols[21]);
                                cord[i].Description__c = allcols[22].ToString();
                                cord[i].price__c = Convert.ToDouble(allcols[23]);
                                cord[i].installation__c = allcols[24].ToString(); 
                                cord[i].freight__c = allcols[25].ToString();
                                cord[i].discount__c = Convert.ToDouble(allcols[26]);
                                cord[i].salestax__c = Convert.ToDouble(allcols[27]);
                                cord[i].taxcode__c = allcols[28].ToString();
                        }
                        try {
                            SaveResult[] saveResults = binding.create(cord);

                      }
                      catch (Exception ce)
                      {
                            Response.Write("Buld order update errror" +ce.Message.ToString());
                            Response.End();
                      }

                       if (str != null) str.Close();
                   }
+1
source

All Articles