public void SingleResource_Verify_CanCreate() { var request = new SDataSingleResourceRequest(_service) {ResourceKind = "employees"}; var payload = new SDataPayload(); payload.Values["Title"] = "create 1"; payload.Values["NationalIdNumber"] = "44444"; payload.Values["LoginId"] = "create 4"; payload.Values["ContactId"] = "9999"; payload.Values["BirthDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(new DateTime(1970, 8, 2)); payload.Values["HireDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now); payload.Values["ModifiedDate"] = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now); payload.Values["MaritalStatus"] = "Single"; payload.Values["SalariedFlag"] = XmlConvert.ToString(true); payload.Values["CurrentFlag"] = XmlConvert.ToString(true); payload.Values["Gender"] = "Male"; payload.Values["RowGuid"] = Guid.NewGuid().ToString(); var entry = new AtomEntry { UpdatedOn = DateTime.Now, PublishedOn = DateTime.Now }; entry.SetSDataPayload(payload); request.Entry = entry; _mock.Setup(s => s.CreateEntry(request, request.Entry)).Returns(TestData.Entry); entry = request.Create(); Expect(entry, Is.Not.Null); }
internal ResourceLocator CreateResource(SDataService ws, String resourceName, IDictionary<String, object> values, string resourceKind = null) { var sru = new SDataSingleResourceRequest(ws); sru.ResourceKind = resourceKind == null ? resourceName.ToLower() + "s" : resourceKind; SDataPayload payload = new SDataPayload(); payload.ResourceName = resourceName; payload.Namespace = SDATA_NS; sru.Entry = new AtomEntry(); foreach (KeyValuePair<String, object> kvp in values) { payload.Values[kvp.Key] = kvp.Value; } sru.Entry.SetSDataPayload(payload); AtomEntry entry = sru.Create(); payload = entry.GetSDataPayload(); return new ResourceLocator { Id = payload.Key, ETag = entry.GetSDataHttpETag() }; }
private void cmdSave_Click(object sender, EventArgs e) { try { ISDataService service; service = SDataDataService.mydataService(); string contactId = contactPayload.Key; ; string contactName = contactPayload.Values["FirstName"].ToString().Trim() + " " + contactPayload.Values["LastName"].ToString().Trim(); SDataPayload accountPayload = (SDataPayload)contactPayload.Values["Account"]; string accountId = accountPayload.Key; string accountName = contactPayload.Values["AccountName"].ToString().Trim(); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "Activity", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"AccountId", accountId}, //{"AccountName", accountName}, {"ContactId", contactId}, {"Description", txtRegarding.Text} } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Activities" }; AtomEntry result = request.Create(); if (result != null) { //MessageBox.Show("Acctivity created"); } this.Close(); } catch (SDataClientException ex) { MessageBox.Show(ex.Message); } }
private void cmdSave_Click(object sender, EventArgs e) { try { ISDataService service; service = SDataDataService.mydataService(); string ownerId = UserNameToOwnerId.GetId(service.UserName); string userId = UserNameToId.GetId(service.UserName); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "Opportunity", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"Description", txtDescription.Text}, {"Account", (SDataPayload)contactPayload.Values["Account"]}, {"Owner", new SDataPayload{ Key = ownerId, ResourceName="Owner"}}, {"AccountManager", new SDataPayload{ Key = userId, ResourceName="AccountManager"}}, {"Contacts", new SDataPayloadCollection { new SDataPayload { ResourceName = "OpportunityContact", Values = {{"Contact",new SDataPayload{ Key = contactPayload.Key}}, {"IsPrimary","true"}} } } } } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Opportunities" }; AtomEntry result = request.Create(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cmdSave_Click(object sender, EventArgs e) { try { ISDataService service; service = SDataDataService.mydataService(); string ownerId = UserNameToOwnerId.GetId(service.UserName); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "Ticket", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"Account", (SDataPayload)contactPayload.Values["Account"]}, {"Contact", contactPayload},//, {"AssignedTo", new SDataPayload{ Key = ownerId, ResourceName="Owner"}}, //{"Issue",txtSubject.Text}, {"TicketProblem", new SDataPayload{ ResourceName="TicketProblem", Values = { {"Notes",txtSubject.Text} } } } } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Tickets" }; AtomEntry result = request.Create(); this.Close(); } catch (SDataClientException ex) { //MessageBox.Show(ex.Message); //Getting object reference error and have no idea why //Everything is created just fine and is working though still get error this.Close(); } }
public static string Create(string oppoId, string contactId) { try { ISDataService service; service = SDataDataService.mydataService(); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "OpportunityContact", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"Contact", new SDataPayload{ Key = contactId, ResourceName="Contact"}}, {"Opportunity", new SDataPayload{ Key = oppoId, ResourceName="Opportunity"}} } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "OpportunityContacts" }; AtomEntry result = request.Create(); if (result != null) { return result.Id.ToString(); } else { return null; } } catch (Exception ex) { return null; } }
// Needs help! public void contact() { SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic); contactTemplate.ResourceKind = "contacts"; Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; string firstName = GetFakeFirstName(); string lastName = GetFakeLastName(); if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); if (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName) { do { firstName = GetFakeFirstName(); lastName = GetFakeLastName(); } while (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName); } } payload.Values["FirstName"] = firstName; payload.Values["LastName"] = lastName; payload.Values["LastNameUpper"] = lastName.ToUpper(); payload.Values["NameLF"] = lastName + ", " + firstName; payload.Values["Name"] = firstName + " " + lastName; payload.Values["FullName"] = lastName + " , " + firstName; payload.Values["NamePFL"] = " " + firstName + " " + lastName; } } string emailProvider = "gmail"; int temp = rand.Next(0, 4); switch (temp) { case 0: emailProvider = "yahoo"; break; case 1: emailProvider = "gmail"; break; case 2: emailProvider = "mail"; break; case 3: emailProvider = "me"; break; default: emailProvider = "hotmail"; break; } payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["Account"] = accountPayload; payload.Values["CreateDate"] = DateTime.Now; payload.Values["CreateUser"] = UserID; payload.Values["Email"] = firstName + lastName + "@" + emailProvider + ".com"; string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString(); payload.Values["WorkPhone"] = phone; payload.Values["Mobile"] = phone; payload.Values["DoNotEmail"] = false; payload.Values["DoNotFax"] = false; payload.Values["DoNotMail"] = false; payload.Values["DoNotPhone"] = false; payload.Values["DoNotSolicit"] = false; payload.Values["IsServiceAuthorized"] = false; payload.Values["IsPrimary"] = false; payload.Values["Status"] = "Active"; payload.Values["Owner"] = "Everyone"; payload.Values["PreferredContact"] = "Unknown"; tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "contacts", Entry = tempEntry }; request.Create(); Log("Created contact: " + payload.Values["Name"], fileName); }
private void cmdSave_Click(object sender, EventArgs e) { try { ISDataService service; service = SDataDataService.mydataService(); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "Account", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"AccountName", txtAccount.Text}, {"Contacts", new SDataPayloadCollection { new SDataPayload { ResourceName = "Contact", Values = { {"AccountName", txtAccount.Text}, {"LastName", txtLName.Text}, {"FirstName", txtFName.Text}, {"Email",txtEmail.Text} } } } } } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "accounts" }; AtomEntry result = request.Create(); if(result != null) { this.DialogResult = System.Windows.Forms.DialogResult.Yes; } this.Close(); } catch (SDataClientException ex) { MessageBox.Show(ex.Message); } }
private void cmdSave_Click(object sender, EventArgs e) { try { ISDataService service; service = SDataDataService.mydataService(); var entry = new AtomEntry(); var payload = new SDataPayload { ResourceName = "Lead", Namespace = "http://schemas.sage.com/dynamic/2007", Values = { {"Company", txtCompany.Text.Trim()}, {"FirstName",txtFName.Text.Trim()}, {"LastName",txtLName.Text.Trim()}, {"Email",txtEmail.Text.Trim()}, {"Address", new SDataPayload { ResourceName = "LeadAddress", Values = { {"Address1", txtAddress.Text.Trim()}, {"City", txtCity.Text.Trim()}, {"State", txtState.Text.Trim()}, {"PostalCode",txtPostalCode.Text.Trim()} } } } } }; entry.SetSDataPayload(payload); var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "leads" }; AtomEntry result = request.Create(); if (result != null) { this.DialogResult = System.Windows.Forms.DialogResult.Yes; } this.Close(); } catch (SDataClientException ex) { MessageBox.Show(ex.Message); } }
// Functional public void lead() { SDataTemplateResourceRequest leadsTemplate = new SDataTemplateResourceRequest(dynamic); leadsTemplate.ResourceKind = "leads"; bool checker = true; string firstName = ""; string lastName = ""; Sage.SData.Client.Atom.AtomEntry tempEntry = leadsTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); // Checks to see if there is a lead with that name already created do { firstName = GetFakeFirstName(); lastName = GetFakeLastName(); SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "LastName eq '" + lastName + "'" } } }; var feed = check.Read(); foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { SDataPayload tempPayload = entry.GetSDataPayload(); if ((string)tempPayload.Values["FirstName"] == firstName) { checker = true; break; } else checker = false; } } while (checker); string emailProvider = "gmail"; int temp = rand.Next(0, 4); switch (temp) { case 0: emailProvider = "yahoo"; break; case 1: emailProvider = "gmail"; break; case 2: emailProvider = "mail"; break; case 3: emailProvider = "me"; break; default: emailProvider = "hotmail"; break; } string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString(); payload.Values["CreateUser"] = UserID; payload.Values["CreateDate"] = DateTime.Now.ToUniversalTime(); payload.Values["Company"] = GetFakeCompanyName(); payload.Values["Email"] = firstName.ToLower() + lastName.ToLower() + "@" + emailProvider + ".com"; payload.Values["FirstName"] = firstName; payload.Values["LastName"] = lastName; payload.Values["LastNameUpper"] = lastName.ToUpper(); payload.Values["Mobile"] = phone; payload.Values["LeadNameFirstLast"] = firstName + " " + lastName; payload.Values["LeadNameLastFirst"] = lastName + ", " + firstName; SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "leads", Entry = tempEntry }; /*SDataServiceOperationRequest request = new SDataServiceOperationRequest(service) { ResourceKind = "leads", //OperationName = "Save", Entry = tempEntry }; */ request.Create(); Debug.WriteLine(payload.Values["Company"] + ", " + payload.Values["LeadNameFirstLast"]); leadsCount++; // In this case the notes created label becomes the leads generated label SetLeadsCreated(leadsCount.ToString()); }
// Functional public void activityFor(SDataPayload opportunityPayload) { try { // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions. string temp = randomTypeGenerator(); string category = randomCategoryGenerator(temp); string description = randomDescriptionGenerator(temp); //if (temp == "ToDo" && (description != "Send proposal" || description != "Send quote")) //{ temp = todoDecoder(description); } string type = "at" + temp; string location = randomLocationGenerator(temp); DateTime startTime = randomDateGenerator(); string priority = randomPriorityGenerator(); SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"]; SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic) { ResourceKind = "accounts", ResourceSelector = "'" + key.Key + "'" }; var rawr = getAccount.Read(); SDataPayload accountPayload = rawr.GetSDataPayload(); string notes = randomNoteGenerator(temp, accountPayload, description); DateTime alarm = startTime.AddMinutes(-15); DateTime duration; SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service); activityTemplate.ResourceKind = "activities"; Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); payload.Values["OpportunityName"] = opportunityPayload.Values["Description"]; payload.Values["OpportunityId"] = opportunityPayload.Key; payload.Values["Type"] = type; payload.Values["Category"] = category; // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each. payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["AccountId"] = accountPayload.Key; payload.Values["Description"] = description; //payload.Values["Duration"] = "15 minutes"; payload.Values["StartDate"] = startTime; payload.Values["Location"] = location; payload.Values["Priority"] = priority; payload.Values["LongNotes"] = notes; payload.Values["Notes"] = notes; payload.Values["AlarmTime"] = alarm; tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(service) { ResourceKind = "activities", Entry = tempEntry }; //Creating the entry... request.Create(); activitiesCount++; //SetActivitiesCreated(activitiesCount.ToString()); } catch (Exception e) { Log(e.ToString(),fileName);; } }
// Functional public void opportunity() { SDataTemplateResourceRequest opportunityTemplate = new SDataTemplateResourceRequest(dynamic); opportunityTemplate.ResourceKind = "opportunities"; Sage.SData.Client.Atom.AtomEntry tempEntry = opportunityTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null & i < 50); if (i == 50) return; int oppValue = 500 * rand.Next(1, 1000); DateTime closeDate = DateTime.Now; closeDate = closeDate.AddMonths(3); int month = rand.Next(0, 12); int day = rand.Next(0, 30); closeDate = closeDate.AddMonths(month); closeDate = closeDate.AddDays(day); payload.Values["ActualAmount"] = oppValue; payload.Values["CreateDate"] = DateTime.Now; payload.Values["CreateUser"] = UserID; payload.Values["Description"] = accountPayload.Values["AccountName"] + " - Phase " + rand.Next(0, 10); payload.Values["Account"] = accountPayload; payload.Values["Owner"] = UserID; payload.Values["SalesAmount"] = oppValue; payload.Values["SalesPotential"] = oppValue; payload.Values["CloseProbability"] = 5 * rand.Next(0, 20); payload.Values["EstimatedClose"] = closeDate; if (accountPayload.Values["Contacts"] != null) { SDataBatchRequest contact = new SDataBatchRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; /* var feed = contact.Read(); SDataPayload contactPayload = ; if (feed.Entries.Count() != 0) { int i = 1; foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload.Values["Contact" + i] = entry.GetSDataPayload(); i++; } */ payload.Values["Contacts"] = contact; //} } tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "opportunities", Entry = tempEntry }; request.Create(); opportunitiesCount++; SetOppsCreated(opportunitiesCount.ToString()); Debug.WriteLine("Opportunity made for account: " + accountPayload.Values["AccountName"]); }
// Not utilized in this build, was a POC that did not get implemented/was found to be unnecessary upon creation of // a viable UI for the program. #region Spreadsheet Data Creation // Functions that create entries into the database. public void note(List<string> write) { try { // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions. string type = "atNote"; string category = "Note"; //string description = randomDescriptionGenerator(category); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; //string notes = randomNoteGenerator(category, accountPayload, description); int accId = rand.Next(2000); SDataTemplateResourceRequest noteHistoryTemplate = new SDataTemplateResourceRequest(dynamic); noteHistoryTemplate.ResourceKind = "history"; Sage.SData.Client.Atom.AtomEntry tempEntry = noteHistoryTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); payload.Values["Type"] = type; payload.Values["Category"] = category; payload.Values["Description"] = write[3]; payload.Values["Notes"] = write[2]; payload.Values["LongNotes"] = write[3]; payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["AccountId"] = accountPayload.Key; // Checks if there is an associated contact with the account. if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["ContactName"] = contactPayload.Values["Name"]; payload.Values["ContactId"] = contactPayload.Key; } } // Checks if there is an associated opportunity with the account, similar to how the contact was found. if (accountPayload.Values["Opportunities"] != null) { SDataResourceCollectionRequest opp = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "opportunities", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = opp.Read(); SDataPayload oppPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { oppPayload = entry.GetSDataPayload(); break; } payload.Values["OpportunityName"] = oppPayload.Values["Description"]; payload.Values["OpportunityId"] = oppPayload.Key; } } // Checks if there is an associated ticket with the account, similar to how the contact was found. if (accountPayload.Values["Tickets"] != null) { SDataResourceCollectionRequest tick = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "tickets", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = tick.Read(); SDataPayload ticketPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { ticketPayload = entry.GetSDataPayload(); break; } payload.Values["TicketNumber"] = ticketPayload.Values["TicketNumber"]; payload.Values["TicketId"] = ticketPayload.Key; } } payload.Values["StartDate"] = DateTimeOffset.Now.ToUniversalTime(); payload.Values["CompletedDate"] = DateTime.Now.ToUniversalTime(); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "history", Entry = tempEntry }; request.Create(); notesCount++; SetNotesCreated(notesCount.ToString()); Log("Created Note: " + payload.Values["Description"] + "... at time " + DateTime.Now, fileName); } catch (Exception e) { Log(e.ToString(),fileName);; } }
// Functional public void makeActivityFor(SDataPayload opportunityPayload) { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions. string temp = localize(language, "Type Generator", null, null, null, true); string category = localize(language, "Category Generator", null, temp, null, true); string description = localize(language, "Description Generator", null, temp, null, true); string type = "at" + temp; string location = localize(language, "Location Generator", null, temp, null, true); DateTime startTime = randomDateGenerator(); string priority = localize(language, "Priority Generator", null, null, null, true); SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"]; SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic) { ResourceKind = "accounts", ResourceSelector = "'" + key.Key + "'" }; var rawr = getAccount.Read(); SDataPayload accountPayload = rawr.GetSDataPayload(); string notes = randomNoteGenerator(temp, accountPayload, description); DateTime alarm = startTime.AddMinutes(-15); DateTime duration; SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service); activityTemplate.ResourceKind = "activities"; Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); payload.Values["OpportunityName"] = opportunityPayload.Values["Description"]; payload.Values["OpportunityId"] = opportunityPayload.Key; payload.Values["Type"] = type; payload.Values["Category"] = category; // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each. payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["AccountId"] = accountPayload.Key; payload.Values["Description"] = description; //payload.Values["Duration"] = "15 minutes"; payload.Values["StartDate"] = startTime; payload.Values["Location"] = location; payload.Values["Priority"] = priority; payload.Values["LongNotes"] = notes; payload.Values["Notes"] = notes; payload.Values["AlarmTime"] = alarm; tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(service) { ResourceKind = "activities", Entry = tempEntry }; //Creating the entry... request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; activitiesCount++; SetActivitiesCreated(activitiesCount.ToString()); Log(DateTime.Now + " - Created Activity: " + payload.Values["Type"] + " - " + timed + " seconds", fileName); } catch (Exception e) { Log(e.ToString(),fileName);; } }
// Functional public void ticket() { SDataTemplateResourceRequest ticketTemplate = new SDataTemplateResourceRequest(dynamic); ticketTemplate.ResourceKind = "tickets"; Sage.SData.Client.Atom.AtomEntry tempEntry = ticketTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; //accountPayload.Values["UserField1"] = UserID; // Only need account name for the payload to be complete payload.Values["Account"] = accountPayload; try { if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["Contact"] = contactPayload; } } } catch (Exception e) { Log(e.ToString(),fileName);; } tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "tickets", Entry = tempEntry }; request.Create(); //Sage.SData.Client.Atom.AtomEntry ent = request.Read(); //SDataPayload tempLoad = ent.GetSDataPayload(); Debug.WriteLine("Created ticket number: " + accountPayload.Values["AccountName"]); ticketsCount++; // in this case notes created is for tickets for helper and for ticker maker SetNotesCreated(ticketsCount.ToString()); //SDataServiceOperationRequest }
// Functional public void makeTicket() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; SDataTemplateResourceRequest ticketTemplate = new SDataTemplateResourceRequest(dynamic); ticketTemplate.ResourceKind = "tickets"; Sage.SData.Client.Atom.AtomEntry tempEntry = ticketTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int j = 0; do { accountPayload = fetchAccount(); j++; } while (accountPayload == null && j < 50); //accountPayload.Values["UserField1"] = UserID; if (j == 50) return; // Only need account name for the payload to be complete payload.Values["Account"] = accountPayload; try { if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["Contact"] = contactPayload; } } else { int i = rand.Next(0, 150); SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "startIndex", i.ToString() } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["Contact"] = contactPayload; } } } catch (Exception e) { Log(e.ToString(), fileName); } tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "tickets", Entry = tempEntry }; request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; Log(DateTime.Now + " - Created ticket number: " + accountPayload.Values["AccountName"] + " - " + timed + " seconds", fileName); ticketsCount++; SetTicketsCreated(ticketsCount.ToString()); } catch (Exception e) { Log(e.ToString(), fileName); } }
// Functional public void makeLead() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; SDataTemplateResourceRequest leadsTemplate = new SDataTemplateResourceRequest(dynamic); leadsTemplate.ResourceKind = "leads"; bool checker = true; string firstName = ""; string lastName = ""; Sage.SData.Client.Atom.AtomEntry tempEntry = leadsTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); // Checks to see if there is a lead with that name already created do { firstName = localize(language, "Fake First Name", null, null, null, true); lastName = localize(language, "Fake Last Name", null, null, null, true); SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "LastName eq '" + lastName + "'" } } }; var feed = check.Read(); foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { SDataPayload tempPayload = entry.GetSDataPayload(); if ((string)tempPayload.Values["FirstName"] == firstName) { checker = true; break; } else checker = false; } } while (checker); string emailProvider = "gmail"; int temp = rand.Next(0, 4); switch (temp) { case 0: emailProvider = "yahoo"; break; case 1: emailProvider = "gmail"; break; case 2: emailProvider = "mail"; break; case 3: emailProvider = "me"; break; default: emailProvider = "hotmail"; break; } string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString(); payload.Values["CreateUser"] = UserID; payload.Values["CreateDate"] = DateTime.Now.ToUniversalTime(); payload.Values["Company"] = localize(language, "Fake Company Name", null, null, null, true); payload.Values["Email"] = firstName.ToLower() + lastName.ToLower() + "@" + emailProvider + ".com"; payload.Values["FirstName"] = firstName; payload.Values["LastName"] = lastName; payload.Values["LastNameUpper"] = lastName.ToUpper(); payload.Values["Mobile"] = phone; payload.Values["LeadNameFirstLast"] = firstName + " " + lastName; payload.Values["LeadNameLastFirst"] = lastName + ", " + firstName; SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "leads", Entry = tempEntry }; request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; Log(DateTime.Now + " - Created lead: " + payload.Values["Company"] + ", " + payload.Values["LeadNameFirstLast"] + " - " + timed + " seconds", fileName); leadsCount++; SetLeadsCreated(leadsCount.ToString()); } catch (Exception e) { Log(e.ToString(), fileName); } }
// Functional public void makeContact() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; SDataTemplateResourceRequest contactTemplate = new SDataTemplateResourceRequest(dynamic); contactTemplate.ResourceKind = "contacts"; Sage.SData.Client.Atom.AtomEntry tempEntry = contactTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; string firstName = localize(language, "Fake First Name", null, null, null, true); string lastName = localize(language, "Fake Last Name", null, null, null, true); if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); if (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName) { do { firstName = localize(language, "Fake First Name", null, null, null, true); lastName = localize(language, "Fake Last Name", null, null, null, true); } while (contactPayload.Values["FirstName"] == firstName && contactPayload.Values["LastName"] == lastName); } } } } string emailProvider = "gmail"; int temp = rand.Next(0, 4); switch (temp) { case 0: emailProvider = "yahoo"; break; case 1: emailProvider = "gmail"; break; case 2: emailProvider = "mail"; break; case 3: emailProvider = "me"; break; default: emailProvider = "hotmail"; break; } payload.Values["FirstName"] = firstName; payload.Values["LastName"] = lastName; payload.Values["LastNameUpper"] = lastName.ToUpper(); payload.Values["NameLF"] = lastName + ", " + firstName; payload.Values["Name"] = firstName + " " + lastName; payload.Values["FullName"] = lastName + " , " + firstName; payload.Values["NamePFL"] = " " + firstName + " " + lastName; payload.Values["IsPrimary"] = false; payload.Values["Salutation"] = firstName; payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["Account"] = accountPayload; payload.Values["CreateDate"] = DateTime.Now; payload.Values["ModifyDate"] = DateTime.Now; payload.Values["ModifyUser"] = UserID; payload.Values["CreateUser"] = UserID; payload.Values["Email"] = firstName + lastName + "@" + emailProvider + ".com"; string phone = rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString() + rand.Next(9).ToString(); payload.Values["WorkPhone"] = phone; payload.Values["Mobile"] = phone; payload.Values["DoNotEmail"] = false; payload.Values["DoNotFax"] = false; payload.Values["DoNotMail"] = false; payload.Values["DoNotPhone"] = false; payload.Values["DoNotSolicit"] = false; payload.Values["IsServiceAuthorized"] = false; payload.Values["WebAddress"] = accountPayload.Values["WebAddress"]; payload.Values["Status"] = "Active"; payload.Values["Address"] = new SDataPayload { ResourceName = "addresses", Values = { {"Description", "Office"}, {"CreateDate", DateTime.Now}, {"CreateUser", UserID}, {"IsMailing", true}, {"IsPrimary", true}, {"AddressType", "Billing & Shipping"} } }; payload.Values["Description"] = accountPayload.Values["Description"]; payload.Values["PreferredContact"] = "Unknown"; tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "contacts", Entry = tempEntry }; request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; contactsCount++; SetContactsCreated(contactsCount.ToString()); Log(DateTime.Now + " - Created contact: " + payload.Values["Name"] + " - " + timed + " seconds", fileName); } catch (Exception e) { Log(e.ToString(), fileName); } }
// Functional public void makeAccount() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; SDataTemplateResourceRequest accountTemplate = new SDataTemplateResourceRequest(dynamic); accountTemplate.ResourceKind = "accounts"; Sage.SData.Client.Atom.AtomEntry tempEntry = accountTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); bool checker = false; string accountName = ""; do { accountName = localize(language, "Fake Company Name", null, null, null, true); try { SDataResourceCollectionRequest check = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "accounts", QueryValues = { { "where", "AccountNameUpper eq '" + accountName.ToUpper() + "'" } } }; var feed = check.Read(); if (feed.Entries.Count() == 0) checker = false; else checker = true; } catch (Exception e) { Log(e.ToString(),fileName); } } while (checker == true); payload.Values["AccountName"] = accountName; payload.Values["AccountNameUpper"] = accountName.ToUpper(); payload.Values["CreateDate"] = DateTime.Now; payload.Values["CreateUser"] = UserID; payload.Values["Type"] = localize(language, "Account Type", null, null, null, true); payload.Values["Status"] = localize(language, "Account Status", null, null, null, true); tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "accounts", Entry = tempEntry }; request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; accountsCount++; SetAccountsCreated(accountsCount.ToString()); Log(DateTime.Now + " - Created new account: " + payload.Values["AccountName"] + " - " + timed + " seconds", fileName); } catch (Exception e) { Log(e.ToString(),fileName); } }
private void Form1_Load(object sender, EventArgs e) { // SDataTemplateResourceRequest needs .Core so I have a using. SDataTemplateResourceRequest req = new SDataTemplateResourceRequest(_service); req.ResourceKind = "contacts"; //AtomEntry needs Sage.SData.Client.Atom so I added a using AtomEntry entry = req.Read(); var contact = entry.GetSDataPayload(); //get rid of these guys since we do not want to set them. contact.Values.Remove("CreateDate"); contact.Values.Remove("CreateUser"); contact.Values.Remove("ModifyDate"); contact.Values.Remove("ModifyUser"); contact.Values["Account"] = GetEntityPayload("accounts", "AA2EK0013031"); contact.Values["Email"] = "*****@*****.**"; contact.Values["FirstName"] = "Jason"; contact.Values["LastName"] = "Huber"; //removing the address, but you would want it, and it would be another payload like account.... //payload.Values.Remove("Address"); //updated to go and get a new address template and get it in there.. SDataPayload address = GetEntityTemplate("addresses"); address.Values["Description"] = "SalesLogix/Act Office"; address.Values["Address1"] = "8800 n. Gainey Center Drive"; address.Values["City"] = "Scottsdale"; address.Values["State"] = "AZ"; contact.Values["Address"] = address; //payload.Values["Description"] = txtProjectDesc.Text; //payload.Values["StartDate"] = Convert.ToDateTime(dtStartDate.Text).ToString("yyyy-MM-dd"); //payload.Values["EndDate"] = Convert.ToDateTime(dtEndDate.Text).ToString("yyyy-MM-dd"); //now we can send the entry in. //need to go and get the task, then update it, then send it back. Sage.SData.Client.Core.SDataSingleResourceRequest rcu = new Sage.SData.Client.Core.SDataSingleResourceRequest(_service); rcu.ResourceKind = "contacts"; rcu.Entry = entry; try { AtomEntry result = rcu.Create(); //the result here should be 201 instead of 200 because it is a create. //http://interop.sage.com/daisy/sdata/CreateOperation/ErrorHandling.html if (result.GetSDataHttpStatus() == System.Net.HttpStatusCode.Created) { MessageBox.Show("I added the contact!"); } else { MessageBox.Show("Insert Failed. /n" + result.GetSDataHttpMessage()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Functional public void noteFor(SDataPayload opportunityPayload) { try { // Initializing the variables used to populate the payload. Each variable gets a value using a random value generator as defined below the creation functions. string type = "atNote"; string category = "Note"; string description = randomDescriptionGenerator(category); SDataPayload key = (SDataPayload)opportunityPayload.Values["Account"]; SDataSingleResourceRequest getAccount = new SDataSingleResourceRequest(dynamic) { ResourceKind = "accounts", ResourceSelector = "'" + key.Key + "'" }; var rawr = getAccount.Read(); SDataPayload accountPayload = rawr.GetSDataPayload(); string notes = randomNoteGenerator(category, accountPayload, description); int accId = rand.Next(2000); SDataTemplateResourceRequest noteHistoryTemplate = new SDataTemplateResourceRequest(dynamic); noteHistoryTemplate.ResourceKind = "history"; Sage.SData.Client.Atom.AtomEntry tempEntry = noteHistoryTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); payload.Values["OpportunityName"] = opportunityPayload.Values["Description"]; payload.Values["OpportunityId"] = opportunityPayload.Key; payload.Values["Type"] = type; payload.Values["Category"] = category; payload.Values["Description"] = description; payload.Values["Notes"] = notes; payload.Values["LongNotes"] = notes; payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["AccountId"] = accountPayload.Key; payload.Values["StartDate"] = DateTimeOffset.Now.ToUniversalTime(); payload.Values["CompletedDate"] = DateTime.Now.ToUniversalTime(); if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["ContactName"] = contactPayload.Values["Name"]; payload.Values["ContactId"] = contactPayload.Key; } } SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "history", Entry = tempEntry }; request.Create(); notesCount++; SetNotesCreated(notesCount.ToString()); Log("Created Note: " + payload.Values["Description"] + "... at time " + DateTime.Now, fileName); } catch (Exception e) { Log(e.ToString(),fileName);; } }
// Functional public void makeOpportunity() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; SDataTemplateResourceRequest opportunityTemplate = new SDataTemplateResourceRequest(dynamic); opportunityTemplate.ResourceKind = "opportunities"; Sage.SData.Client.Atom.AtomEntry tempEntry = opportunityTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; int oppValue = 500 * rand.Next(5, 1000); DateTime closeDate = DateTime.Now; closeDate = closeDate.AddMonths(3); int month = rand.Next(0, 12); int day = rand.Next(0, 30); closeDate = closeDate.AddMonths(month); closeDate = closeDate.AddDays(day); string type = ""; int x = rand.Next(1, 2); switch (language) { case "English": if (x == 1) type = "Add-On"; else type = "New"; break; case "Chinese": if (x == 1) type = "附加"; else type = "新"; break; } var getUserRequest = new SDataServiceOperationRequest(service) { OperationName = "getCurrentUser", Entry = new Sage.SData.Client.Atom.AtomEntry() }; var temp = getUserRequest.Create(); var userPayload = temp.GetSDataPayload(); userPayload = (SDataPayload)userPayload.Values["response"]; //payload.Values["ActualAmount"] = oppValue; payload.Values["CreateUser"] = UserID; payload.Values["Description"] = accountPayload.Values["AccountName"] + " - Phase " + rand.Next(0, 10); payload.Values["Account"] = accountPayload; payload.Values["Owner"] = accountPayload.Values["Owner"]; //payload.Values["SalesAmount"] = oppValue; payload.Values["SalesPotential"] = oppValue; payload.Values["CloseProbability"] = 1;//5 * rand.Next(0, 20); payload.Values["EstimatedClose"] = closeDate; payload.Values["Stage"] = "1-Prospect"; payload.Values["LeadSource"] = fetchLeadSource(); payload.Values["Type"] = type; payload.Values["AccountManager"] = accountPayload.Values["AccountManager"]; //payload.Values["Weighted"] = oppValue / 100; //payload.Values["OverrideSalesPotential"] = false; //payload.Values["EstimatedClose"] = randomDateGenerator(); if (accountPayload.Values["Contacts"] != null) { SDataBatchRequest contact = new SDataBatchRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; /* var feed = contact.Read(); SDataPayload contactPayload = ; if (feed.Entries.Count() != 0) { int i = 1; foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload.Values["Contact" + i] = entry.GetSDataPayload(); i++; } */ payload.Values["Contacts"] = contact; //} } tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(dynamic) { ResourceKind = "opportunities", Entry = tempEntry }; request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; opportunitiesCount++; SetOppsCreated(opportunitiesCount.ToString()); Log(DateTime.Now + " - Opportunity made for account: " + accountPayload.Values["AccountName"] + " - " + timed + " seconds", fileName); } catch (Exception e) { Log(e.ToString(), fileName); } }
// Functional public void makeActivity() { try { float previous = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; // Initializing the variables used to populate the payload. Each variable gets a value using a random value // generator as defined below the creation functions. string temp = localize(language, "Type Generator", null, null, null, true); string category = localize(language, "Category Generator", null, temp, null, true); string description = localize(language, "Description Generator", null, temp, null, true); string type = "at" + temp; string location = localize(language, "Location Generator", null, temp, null, true); DateTime startTime = randomDateGenerator(); string priority = localize(language, "Priority Generator", null, null, null, true); SDataPayload accountPayload = null; int i = 0; do { accountPayload = fetchAccount(); i++; } while (accountPayload == null && i < 50); if (i == 50) return; string notes = randomNoteGenerator(temp, accountPayload, description); DateTime alarm = startTime.AddMinutes(-15); SDataTemplateResourceRequest activityTemplate = new SDataTemplateResourceRequest(service); activityTemplate.ResourceKind = "activities"; Sage.SData.Client.Atom.AtomEntry tempEntry = activityTemplate.Read(); SDataPayload payload = tempEntry.GetSDataPayload(); payload.Values["Type"] = type; payload.Values["Category"] = category; // Get the program to query the server for the contact name, account name, and retrieve the respective ids for each. payload.Values["AccountName"] = accountPayload.Values["AccountName"]; payload.Values["AccountId"] = accountPayload.Key; // Checks to make sure there is a contact associated with the account, and if so calls a request to get the payload // associated to that contact; then filling in payload.Values if (accountPayload.Values["Contacts"] != null) { SDataResourceCollectionRequest contact = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "contacts", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = contact.Read(); SDataPayload contactPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { contactPayload = entry.GetSDataPayload(); break; } payload.Values["ContactName"] = contactPayload.Values["Name"]; payload.Values["ContactId"] = contactPayload.Key; } } if (temp != "Personal") { // Checks if there is an associated opportunity with the account, similar to how the contact was found. if (accountPayload.Values["Opportunities"] != null) { SDataResourceCollectionRequest opp = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "opportunities", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = opp.Read(); SDataPayload oppPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { oppPayload = entry.GetSDataPayload(); break; } payload.Values["OpportunityName"] = oppPayload.Values["Description"]; payload.Values["OpportunityId"] = oppPayload.Key; } } // Checks if there is an associated ticket with the account, similar to how the contact was found. if (accountPayload.Values["Tickets"] != null) { SDataResourceCollectionRequest tick = new SDataResourceCollectionRequest(dynamic) { ResourceKind = "tickets", QueryValues = { { "where", "Account.Id eq '" + accountPayload.Key + "'" } } }; var feed = tick.Read(); SDataPayload ticketPayload = null; if (feed.Entries.Count() != 0) { foreach (Sage.SData.Client.Atom.AtomEntry entry in feed.Entries) { ticketPayload = entry.GetSDataPayload(); break; } payload.Values["TicketNumber"] = ticketPayload.Values["TicketNumber"]; payload.Values["TicketId"] = ticketPayload.Key; } } } payload.Values["Description"] = description; payload.Values["StartDate"] = startTime; payload.Values["Location"] = location; payload.Values["Priority"] = priority; payload.Values["LongNotes"] = notes; payload.Values["Notes"] = notes; payload.Values["AlarmTime"] = alarm; tempEntry.SetSDataPayload(payload); SDataSingleResourceRequest request = new SDataSingleResourceRequest(service) { ResourceKind = "activities", Entry = tempEntry }; //Creating the entry... request.Create(); float after = DateTime.Now.Minute * 60 * 1000 + DateTime.Now.Second * 1000 + DateTime.Now.Millisecond; float timed = (after - previous) / 1000; activitiesCount++; SetActivitiesCreated(activitiesCount.ToString()); Log(DateTime.Now + " - Created Activity: " + payload.Values["Type"] + " - " + timed + " seconds", fileName); } catch (Exception e) { Log(e.ToString(),fileName);; } }