private void ContactFound_Load(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(contactId))
                {
                    mydataService = SDataDataService.mydataService();

                    SDataSingleResourceRequest mydataSingleRequest;
                    mydataSingleRequest = new SDataSingleResourceRequest(mydataService);
                    mydataSingleRequest.ResourceKind = "Contacts";
                    mydataSingleRequest.ResourceSelector = "('" + contactId + "')";
                    AtomEntry myContact = mydataSingleRequest.Read();
                    mydataSingleRequest.Entry = myContact;

                    payload = mydataSingleRequest.Entry.GetSDataPayload();

                    if (payload != null)
                    {
                        txtAccount.Text = payload.Values["AccountName"].ToString().Trim();
                        txtFirstName.Text = payload.Values["FirstName"].ToString().Trim();
                        txtLastName.Text = payload.Values["LastName"].ToString().Trim();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        public void LoadTickets()
        {
            Sage.SData.Client.Core.SDataSingleResourceRequest request = new
                Sage.SData.Client.Core.SDataSingleResourceRequest(_service);

            request.ResourceKind = "tickets";
            //**Be sure to change this query!

            request.QueryValues.Add("include", "Account");
            request.ResourceSelector = "'tDEMOA000002'";
            // Read the feed from the server
            SDataPayload ticket, account;

            //I did this as a seperate so that I could tell when the read comes back
            Sage.SData.Client.Atom.AtomEntry entry = request.Read();
            //and clear the please wait message.
            //first get the payload out for the entry
            ticket = entry.GetSDataPayload();
            account = (SDataPayload)ticket.Values["Account"];
            account.Values["UserField1"] = "Sam";

            //put everything back..
            ticket.Values["Account"] = account;

            entry.SetSDataPayload(ticket);
            request.Entry = entry;
            request.Update();

            if (request.Entry.GetSDataHttpStatus() !=
                System.Net.HttpStatusCode.OK)
            {
                MessageBox.Show("Uh oh. Something went wrong.");
            }
        }
        private void DisplayDetails(DataGridViewCellEventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                SDataSingleResourceRequest oppo = new SDataSingleResourceRequest(service);

                oppo.ResourceKind = "Opportunities";

                oppo.ResourceSelector = "('" + grdOpportunities.Rows[e.RowIndex].Cells[2].Value.ToString() + "')";

                AtomEntry oppoEnty = oppo.Read();

                SDataPayload opportunitiy = (SDataPayload)oppoEnty.GetSDataPayload();

                txtOppoDesc.Text = opportunitiy.Values["Description"].ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void DisplayDetails()
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                SDataSingleResourceRequest oppo = new SDataSingleResourceRequest(service);

                oppo.ResourceKind = "Opportunities";

                oppo.ResourceSelector = "('" + oppoId + "')";

                AtomEntry oppoEnty = oppo.Read();

                SDataPayload opportunitiy = (SDataPayload)oppoEnty.GetSDataPayload();

                txtOppoDescription.Text = opportunitiy.Values["Description"].ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void LoadOpportunities()
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                SDataResourceCollectionRequest oppoContactsCollection = new SDataResourceCollectionRequest(service);

                oppoContactsCollection.ResourceKind = "opportunitycontacts";
                oppoContactsCollection.QueryValues.Add("where", "Contact.Id eq '" + id + "'");

                AtomFeed oppoContactsFeed = oppoContactsCollection.Read();

                if (oppoContactsFeed.Entries.Count() > 0)
                {

                    DataTable table = new DataTable();

                    table.Columns.Add("Id");
                    table.Columns.Add("Description");

                    foreach (AtomEntry entry in oppoContactsFeed.Entries)
                    {
                        SDataPayload oppoContact = entry.GetSDataPayload();

                        SDataPayload tempOppo = (SDataPayload)oppoContact.Values["Opportunity"];

                        SDataSingleResourceRequest oppo = new SDataSingleResourceRequest(service);

                        oppo.ResourceKind = "Opportunities";

                        oppo.ResourceSelector = "('" + tempOppo.Key + "')";

                        AtomEntry oppoEnty = oppo.Read();

                        SDataPayload opportunitiy = (SDataPayload)oppoEnty.GetSDataPayload();

                        DataRow dr = table.NewRow();

                        dr[0] = opportunitiy.Key.ToString();
                        dr[1] = opportunitiy.Values["Description"].ToString();

                        table.Rows.Add(dr);
                    }

                    grdOpportunities.DataSource = table;
                    grdOpportunities.Columns[2].Visible = false;
                    grdOpportunities.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void SingleResource_Verify_CanDelete()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "1"
                          };
            _mock.Setup(s => s.ReadEntry(request)).Returns(TestData.Entry);

            request.Entry = request.Read();

            _mock.Setup(s => s.DeleteEntry(request, request.Entry)).Returns(true);

            var result = request.Delete();
            Expect(result);
        }
        public void SingleResource_Verify_CanUpdate()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "1"
                          };
            _mock.Setup(s => s.ReadEntry(request)).Returns(TestData.Entry);

            var entry = request.Read();
            var payload = entry.GetSDataPayload();
            payload.Values["Title"] = "test update";
            request.Entry = entry;
            _mock.Setup(s => s.UpdateEntry(request, request.Entry)).Returns(TestData.Entry);

            entry = request.Update();
            Expect(entry, Is.Not.Null);
        }
        public void SingleResource_Verify_CanRead()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "1"
                          };
            _mock.Setup(s => s.ReadEntry(request)).Returns(TestData.Entry);

            var entry = request.Read();
            Expect(entry, Is.Not.Null);
        }
        public void SingleResource_Verify_CanProcess_SDataBatchRequest()
        {
            var request1 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "1"
                           };
            var request2 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "2"
                           };
            var request3 = new SDataSingleResourceRequest(_service)
                           {
                               ResourceKind = "employees",
                               ResourceSelector = "3"
                           };
            _mock.Setup(s => s.ReadEntry(request1)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request2)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request3)).Returns(TestData.Entry);

            request2.Entry = request2.Read();
            request3.Entry = request3.Read();

            _mock.Setup(s => s.UpdateEntry(request2, request2.Entry)).Returns(TestData.Entry);
            _mock.Setup(s => s.DeleteEntry(request3, request3.Entry)).Returns(true);

            var payload2 = request2.Entry.GetSDataPayload();
            payload2.Values["MaritalStatus"] = "Married";

            AtomFeed batchfeed;

            using (var batch = new SDataBatchRequest(_service))
            {
                batch.ResourceKind = "employees";
                request1.Read();
                request2.Update();
                request3.Delete();

                _mock.Setup(s => s.CreateFeed(batch, It.IsAny<AtomFeed>())).Returns(TestData.Feed);
                batchfeed = batch.Commit();
            }

            Expect(batchfeed, Is.Not.Null);
        }
        private SDataPayload GetEntityPayload(string entitytypename, string entityid)
        {
            Sage.SData.Client.Core.SDataSingleResourceRequest request = new
                   Sage.SData.Client.Core.SDataSingleResourceRequest(_service);

            request.ResourceKind = entitytypename;

            request.ResourceSelector = string.Format("'{0}'", entityid);
            // Read the feed from the server

            //I did this as a seperate so that I could tell when the read comes back
            Sage.SData.Client.Atom.AtomEntry entry = request.Read();
            //and clear the please wait message.
            //first get the payload out for the entry
            return entry.GetSDataPayload();
        }
Пример #11
0
        // 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);;
            }
        }
Пример #12
0
        // 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);;
            }
        }
Пример #13
0
        // 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);;
            }
        }
        private void UpdateOppoUI(string id)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                SDataResourceCollectionRequest oppoContactsCollection = new SDataResourceCollectionRequest(service);

                oppoContactsCollection.ResourceKind = "opportunitycontacts";
                oppoContactsCollection.QueryValues.Add("where", "Contact.Id eq '" + id + "'");

                AtomFeed oppoContactsFeed = oppoContactsCollection.Read();

                picBoxOpportunity.Visible = false;

                if (oppoContactsFeed.Entries.Count() > 0)
                {

                    DataTable table = new DataTable();

                    table.Columns.Add("Id");
                    table.Columns.Add("Description");
                    table.Columns.Add("Probability");
                    table.Columns.Add("Potential");
                    table.Columns.Add("ActualAmount");
                    table.Columns.Add("Status");

                    //--------------------------------------
                    // Create The Chart
                    ChartEngine engine = new ChartEngine();
                    engine.Size = picBoxOpportunity.Size;
                    ChartCollection charts = new ChartCollection(engine);
                    engine.Charts = charts;
                    int pointCount = 0;

                    ChartPointCollection data = new ChartPointCollection();
                    Chart columnChart = new ColumnChart(data, Color.DarkGreen);
                    columnChart.Fill.Color = Color.FromArgb(50, Color.Green);
                    columnChart.ShowLineMarkers = true;
                    columnChart.DataLabels.Visible = true;

                    foreach (AtomEntry entry in oppoContactsFeed.Entries)
                    {
                        SDataPayload oppoContact = entry.GetSDataPayload();

                        SDataPayload tempOppo = (SDataPayload)oppoContact.Values["Opportunity"];

                        SDataSingleResourceRequest oppo = new SDataSingleResourceRequest(service);

                        oppo.ResourceKind = "Opportunities";

                        oppo.ResourceSelector = "('" + tempOppo.Key + "')";

                        AtomEntry oppoEnty = oppo.Read();

                        SDataPayload opportunitiy = (SDataPayload)oppoEnty.GetSDataPayload();

                        DataRow dr = table.NewRow();

                        dr[0] = opportunitiy.Key.ToString();
                        dr[1] = (opportunitiy.Values["Description"] != null ? opportunitiy.Values["Description"].ToString() : "No Description");
                        dr[2] = (opportunitiy.Values["CloseProbability"] != null ? opportunitiy.Values["CloseProbability"].ToString() + "%" : "0%");
                        dr[3] = (opportunitiy.Values["SalesPotential"] != null ? String.Format("{0:C}", Convert.ToDecimal(opportunitiy.Values["SalesPotential"])) : "");
                        dr[4] = (opportunitiy.Values["ActualAmount"] != null ? String.Format("{0:C}", Convert.ToDecimal(opportunitiy.Values["ActualAmount"])) : "");
                        dr[5] = (opportunitiy.Values["Status"] != null ? opportunitiy.Values["Status"].ToString() : "No Status");

                        pointCount = Convert.ToInt32(opportunitiy.Values["SalesPotential"].ToString().Substring(0,opportunitiy.Values["SalesPotential"].ToString().IndexOf('.')));

                        data.Add(new ChartPoint("Some Data", pointCount));

                        table.Rows.Add(dr);
                    }

                    dgvOpportunities.DataSource = table;
                    dgvOpportunities.Columns["Id"].Visible = false;
                    dgvOpportunities.Refresh();

                    charts.Add(columnChart);
                    engine.GridLines = GridLines.Horizontal;
                    Image image = engine.GetBitmap();
                    //--------------------------------------
                    // At this point we have the chart already
                    //--------------------------------------
                    // show the already generated image
                    picBoxOpportunity.Image = image;

                    if (SLX_Outlook_AddIn.Properties.Settings.Default.OppoChartPanelMinimized == true)
                    {
                        picBoxOpportunity.Visible = false;
                    }
                    else
                    {
                        picBoxOpportunity.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void GatherSLXInformation()
        {
            //Creating a SafeEmail object so I can always get SMTP address even from Exchange emails
            SafeMailItem safeMail = new SafeMailItem();

            safeMail.Item = curEmail;

            string contactId = EmailSearch(safeMail.Sender.SMTPAddress, "Contacts");

            string leadId = EmailSearch(safeMail.Sender.SMTPAddress, "Leads");

            if (!this.InvokeRequired)
            {
                ClearAll();
            }
            else
            {
                this.Invoke(new ClearAll(this.ClearAll), null);
            }

            if (!String.IsNullOrEmpty(contactId))
            {
                SDataSingleResourceRequest tempContact = new SDataSingleResourceRequest(mydataService);

                tempContact.ResourceKind = "Contacts";

                tempContact.Include = "Account,AccountManager/UserInfo,Address";

                tempContact.ResourceSelector = "('" + contactId + "')";

                AtomEntry contactEnty = tempContact.Read();

                SDataPayload contact = (SDataPayload)contactEnty.GetSDataPayload();
                SDataPayload contactAcct = (SDataPayload)contact.Values["Account"];
                SDataPayload contactMgr = (SDataPayload)contact.Values["AccountManager"];
                SDataPayload contactMgrInfo = (SDataPayload)contactMgr.Values["UserInfo"];
                SDataPayload contactAddress = (SDataPayload)contact.Values["Address"];

                if (!this.InvokeRequired)
                {
                    UpdateContactUI(contact);
                    UpdateAccountUI(contactAcct);
                    UpdateManagerUI(contactMgrInfo);
                    UpdateOppoUI(contactId);
                    UpdateTicketUI(contactId);
                    UpdateAddressUI((contactAddress.Values["FullAddress"] != null ? contactAddress.Values["FullAddress"].ToString() : ""));
                }
                else
                {
                    this.BeginInvoke(new UpdateUI(this.UpdateContactUI), contact);
                    this.BeginInvoke(new UpdateUI(this.UpdateAccountUI), contactAcct);
                    this.BeginInvoke(new UpdateUI(this.UpdateManagerUI), contactMgrInfo);
                    this.BeginInvoke(new UpdateOppoUI(this.UpdateOppoUI), contactId);
                    this.BeginInvoke(new UpdateTicketUI(this.UpdateTicketUI), contactId);
                    this.BeginInvoke(new UpdateAddressUI(this.UpdateAddressUI), (contactAddress.Values["FullAddress"] != null ? contactAddress.Values["FullAddress"].ToString() : ""));
                }
            }

            if (!String.IsNullOrEmpty(leadId))
            {
                SDataSingleResourceRequest tempLead = new SDataSingleResourceRequest(mydataService);
                tempLead.ResourceKind = "Leads";
                tempLead.Include = "Address";
                tempLead.ResourceSelector = "('" + leadId + "')";
                AtomEntry leadEnty = tempLead.Read();
                SDataPayload lead = (SDataPayload)leadEnty.GetSDataPayload();

                SDataPayload tempLeadAddress = (SDataPayload)lead.Values["Address"];
                string leadAddressId = tempLeadAddress.Key;
                SDataSingleResourceRequest tempLeadAddressRequest = new SDataSingleResourceRequest(mydataService);
                tempLeadAddressRequest.ResourceKind = "LeadAddresses";
                tempLeadAddressRequest.ResourceSelector = "('" + leadAddressId + "')";
                AtomEntry leadAddressEnty = tempLeadAddressRequest.Read();
                SDataPayload leadAddress = (SDataPayload)leadAddressEnty.GetSDataPayload();

                if (!this.InvokeRequired)
                {
                    UpdateLeadUI(lead);
                    UpdateAddressUI((leadAddress.Values["FullAddress"] != null ? leadAddress.Values["FullAddress"].ToString() : ""));
                }
                else
                {
                    this.BeginInvoke(new UpdateUI(this.UpdateLeadUI), lead);
                    this.BeginInvoke(new UpdateAddressUI(this.UpdateAddressUI), (leadAddress.Values["FullAddress"] != null ? leadAddress.Values["FullAddress"].ToString() : ""));
                }
            }
        }
        private void btnUpdateContact_Click(object sender, EventArgs e)
        {
            try
            {
                var b = new SDataSingleResourceRequest(mydataService);
                b.ResourceKind = "contacts";
                b.ResourceSelector = "'" + slxContact.Id + "'";
                AtomEntry entry = b.Read();
                SDataPayload payload = entry.GetSDataPayload();
                payload.Values["FirstName"] = txtContactFirstName.Text;
                payload.Values["LastName"] = txtContactLastName.Text;
                payload.Values["Title"] = txtContactTitle.Text;

                string wkPhone = txtContactWorkPhone.Text;
                if (!String.IsNullOrEmpty(wkPhone))
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < wkPhone.Length; i++)
                    {
                        if (char.IsLetterOrDigit(wkPhone[i]))
                            sb.Append(wkPhone[i]);
                    }

                    wkPhone = sb.ToString();
                    payload.Values["WorkPhone"] = wkPhone;
                }

                string mPhone = txtContactMobilePhone.Text;
                if (!String.IsNullOrEmpty(mPhone))
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < mPhone.Length; i++)
                    {
                        if (char.IsLetterOrDigit(mPhone[i]))
                            sb.Append(mPhone[i]);
                    }

                    mPhone = sb.ToString();
                    payload.Values["Mobile"] = mPhone;
                }

                b.Entry = entry;
                AtomEntry updatedEnty = b.Update();

                MessageBox.Show("Updates Completed");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }