static void PopulateCustomersList(int CustomerCount, int BatchSize) { Console.WriteLine(); Console.WriteLine("Adding sample Customers list..."); Console.WriteLine(); int customerCounter = 0; int batchCounter = 0; int batchStart = 1; var customers = RandomCustomerGenerator.GetCustomerList(CustomerCount); foreach (var customer in customers) { // increment counters customerCounter += 1; batchCounter += 1; // add new customer item ListItem newCustomer = listCustomers.AddItem(new ListItemCreationInformation()); newCustomer["Title"] = customer.LastName; newCustomer["FirstName"] = customer.FirstName; newCustomer["Company"] = customer.Company; newCustomer["HomePhone"] = customer.HomePhone; newCustomer["WorkPhone"] = customer.WorkPhone; newCustomer["EMail"] = customer.EmailAddress; newCustomer["WorkAddress"] = customer.Address; newCustomer["WorkCity"] = customer.City; newCustomer["WorkState"] = customer.State; newCustomer["WorkZip"] = customer.ZipCode; newCustomer.Update(); if (batchCounter >= BatchSize) { Console.WriteLine("Adding customers " + batchStart.ToString() + " to " + customerCounter + "..."); clientContext.ExecuteQuery(); batchCounter = 0; batchStart = customerCounter + 1; } } clientContext.ExecuteQuery(); Console.WriteLine(); Console.WriteLine(" Loading of customer data has completed"); Console.WriteLine(); }
public static async Task AddAccounts(int AccountCount) { IEnumerable <CustomerData> customers = RandomCustomerGenerator.GetCustomerList(AccountCount, false); foreach (CustomerData customer in customers) { Account newAccount = new Account { name = customer.Company, telephone1 = customer.WorkPhone, address1_primarycontactname = customer.FirstName + " " + customer.LastName, address1_line1 = customer.Address, address1_city = customer.City, address1_stateorprovince = customer.State, address1_postalcode = customer.ZipCode }; await CdsaManager.AddAccount(newAccount); } }
public static async Task AddContacts(int CustomerCount) { IEnumerable <CustomerData> customers = RandomCustomerGenerator.GetCustomerList(CustomerCount, false); foreach (CustomerData customer in customers) { Contact newContact = new Contact { firstname = customer.FirstName, lastname = customer.LastName, emailaddress1 = customer.EmailAddress, company = customer.Company, telephone1 = customer.WorkPhone, mobilephone = customer.HomePhone, address1_line1 = customer.Address, address1_city = customer.City, address1_stateorprovince = customer.State, address1_postalcode = customer.ZipCode }; await CdsaManager.AddContact(newContact); } }