public void SingleResource_Verify_CanConstructWithTemplateEntry()
 {
     var entry = new AtomEntry();
     var request = new SDataSingleResourceRequest(_service, entry);
     Expect(request, Is.Not.Null);
     Expect(request.Entry, Is.Not.Null);
 }
        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);
        }
예제 #3
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 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);
            }
        }
 public override void Refresh()
 {
     try
     {
         _sdataSingleResourceRequest = new SDataSingleResourceRequest(Service)
                                       {
                                           ResourceKind = tbSingleResourceKind.Text,
                                           ResourceSelector = tbSingleResourceSelector.Text
                                       };
         tbSingleURL.Text = _sdataSingleResourceRequest.ToString();
     }
     catch (SDataClientException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #6
0
 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() };
 }
예제 #7
0
        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();
            }
        }
        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);
            }
        }
    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;
            }
    }
        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 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);
            }
        }
 public void SingleResource_Verify_CanConstruct()
 {
     var request = new SDataSingleResourceRequest(_service);
     Expect(request, Is.Not.Null);
 }
        public void SingleResource_Verify_ToStringWithResourceKindAndInclude()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "1",
                              Include = "contact"
                          };

            var url = request.ToString();
            Expect(url, Is.EqualTo("http://localhost:59213/sdata/aw/dynamic/-/employees(1)?include=contact"));
        }
        public void SingleResource_Verify_ToStringWithResourceKind()
        {
            var request = new SDataSingleResourceRequest(_service)
                          {
                              ResourceKind = "employees",
                              ResourceSelector = "id = '1234'"
                          };

            var url = request.ToString();
            Expect(url, Is.EqualTo("http://localhost:59213/sdata/aw/dynamic/-/employees(id = '1234')"));
        }
        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);
        }
예제 #19
0
파일: Bot.cs 프로젝트: rjledger/Demo-Bot
        // 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);;
            }
        }
        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);
        }
예제 #21
0
파일: Bot.cs 프로젝트: rjledger/Demo-Bot
        public string GetFakeChineseCompanyName()
        {
            Random rand = new Random();
            // Want to make a request to see if the account already exists
            SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
            {
                ResourceKind = "accounts"
            };

            var names = new[]
                        {
                            #region Values
                             "魏桥纺织股份有限公司",
                            "马鞍山钢铁股份有限公司",	
                               "首都信息发展股份有限公司",	
    "首创置业股份有限公司	",
    "鞍钢新轧钢股份有限公司",	
    "青岛啤酒股份有限公司	",
    "长春达兴药业股份有限公司	",
"长城科技股份有限公司",	
"长城汽车股份有限公司",	
"重庆钢铁股份有限公司",	
"郑州燃气股份有限公司",	
"赛迪顾问股份有限公司",	
"联华超市股份有限公司",	
"经纬纺织机械股份有限公司",
"紫金矿业集团股份有限公司",
            "第一拖拉机股份有限公司",
"皖通高速公路股份有限公司",
"牡丹汽车股份有限公司",
"烟台北方安德利果汁股份有限公司",	
"潍柴动力股份有限公司",
"深圳高速公路股份有限公司",
"深圳市宝德科技股份有限公司",
"深圳市元征科技股份有限公司",
"深圳市东江环保股份有限公司",
"深圳中航实业股份有限公司",
"海南美兰机场股份有限公司",
"浙江玻璃股份有限公司",
"浙江浙大网新兰德股份有限公司",
"浙江沪杭甬高速公路股份有限公司",	
"浙江永隆实业股份有限公司",
"沈阳公用发展股份有限公司",
"江西铜业股份有限公司",	
"江苏宁沪高速公路股份有限公司",	
"江苏南大苏富特软件股份有限公司",
"比亚迪股份有限公司",
"成都普天电缆股份有限公司",
"成都托普科技股份有限公司",
"成渝高速公路股份有限公司",
"庆铃汽车股份有限公司",
"广深铁路股份有限公司",
"广州药业股份有限公司",
"广州广船国际股份有限公司",
"广东科龙电器股份有限公司",
"常茂生物化学工程股份有限公司",
"山东新华制药股份有限公司",
"山东国际电源股份有限公司",
"宝业集团股份有限公司",
"安徽海螺水泥股份有限公司",
"天津泰达生物医学工程股份有限公司",
"天津创业环保股份有限公司",
"天津中新药业集团股份有限公司",
"复地(集团)股份有限公司",
"哈尔滨动力设备股份有限公司",
"吉林省辉南长龙生化药业股份有限公司",	
"吉林化学工业股份有限公司",
"南京熊猫电子股份有限公司",
"华能国际电力股份有限公司",
"华电国际电力股份有限公司",
"北人印刷机械股份有限公司",
"北京首都国际机场股份有限公司",
"北京大唐发电股份有限公司",
"北京同仁堂科技股份有限公司",
"北京北辰实业股份有限公司",
"兖州煤业股份有限公司",
"交大昆机科技股份有限公司",
"中海集装箱运输股份有限公司",
"中海油田服务股份有限公司",
"中海发展股份有限公司",
"中国铝业股份有限公司",
"中国航空科技工业股份有限公司",
"中国网络通信集团",
"中国石油天然气股份有限公司",
"中国石油化工股份有限公司",
"中国石化镇海炼油化工股份有限公司",
"中国石化北京燕化石油化工股份有限公司",
"中国石化仪征化纤股份有限公司",
"中国石化上海石油化工股份有限公司",
"中国电信股份有限公司",
"中国民航信息网络股份有限公司",
"中国平安保险(集团)股份有限公司",
"中国太平洋保险(集团)股份有限公司",
"中国外运股份有限公司",
"中国南方航空股份有限公司",	
"中国人民财产保险股份有限公司",
"中国东方航空股份有限公司",
"东方电机股份有限公司",
"东北虎药业股份有限公司",
"东北电气发展股份有限公司",
"上海复旦微电子股份有限公司",
"上海复旦张江生物医药股份有限公司",
"上海交大慧谷信息产业股份有限公司"

                            #endregion            };
                        };

            var index = rand.Next(1, names.Count());
            return names[index];
        }
예제 #22
0
파일: Bot.cs 프로젝트: rjledger/Demo-Bot
        // 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);;
            }

        }
예제 #23
0
        private static void Main()
        {
            var service = new SDataService();

            // set user name to authenticate with
            service.UserName = "******";
            // set password to authenticate with
            service.Password = "";

            service.Protocol = "HTTP";
            service.ServerName = "sdata.acme.com";
            service.ApplicationName = "sageApp";
            service.VirtualDirectory = "sdata";

            AtomFeed feed;
            AtomEntry entry;
            SDataPayload payload;

            #region CREATE an Entry

            // read the template for accounts
            var tru1 = new SDataTemplateResourceRequest(service);
            tru1.ContractName = "test";
            tru1.ResourceKind = "accounts";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts/$template 

            // read the entry from the server
            entry = service.ReadEntry(tru1);

            // TODO: Make changes to the entry payload
            payload = entry.GetSDataPayload();

            var sru1 = new SDataSingleResourceRequest(service);
            sru1.ContractName = "test";
            sru1.ResourceKind = "accounts";

            var newEntry = service.CreateEntry(sru1, entry);

            #endregion

            #region CREATE a BATCH Operaton (Synchronous)

            // create the BatchURL
            var sbu = new SDataBatchRequest(service);
            sbu.ContractName = "test";
            sbu.ResourceKind = "products";
            // the configuration above generates http://sdata.acme.com/sageApp/test/-/products/$batch 

            using (var batch = new SDataBatchRequest(service))
            {
                // read the template for accounts
                var templateResourceRequest = new SDataTemplateResourceRequest(service);
                templateResourceRequest.ContractName = "test";
                templateResourceRequest.ResourceKind = "accounts";
                // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts/$template 

                // read the entry from the server
                var templateEntry = service.ReadEntry(templateResourceRequest);

                var insertRequest = new SDataSingleResourceRequest(service);
                insertRequest.ContractName = "test";
                insertRequest.ResourceKind = "accounts";

                // do some stuff with the entry

                service.CreateEntry(insertRequest, templateEntry);

                // build, submit and get
                var result = batch.Commit();
            }

            #endregion

            #region CREATE a BATCH Operation (Asynchronous)

            // create the BatchURL
            sbu = new SDataBatchRequest(service);
            sbu.ContractName = "test";
            sbu.ResourceKind = "products";

            // the configuration above generates http://sdata.acme.com/sageApp/test/-/products/$batch 

            using (var batch = new SDataBatchRequest(service))
            {
                // read the template for accounts
                var templateResourceRequest = new SDataTemplateResourceRequest(service);
                templateResourceRequest.ContractName = "test";
                templateResourceRequest.ResourceKind = "accounts";
                // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts/$template 

                // read the entry from the server
                var templateEntry = service.ReadEntry(templateResourceRequest);

                var insertRequest = new SDataSingleResourceRequest(service);
                insertRequest.ContractName = "test";
                insertRequest.ResourceKind = "accounts";

                // do some stuff with the entry

                var request = batch.CreateAsync();
                ISyndicationResource result;

                // wait around until the response is ready
                do
                {
                    var progress = request.Progress;
                } while ((result = request.Refresh()) == null);

                feed = result as AtomFeed;
            }

            #endregion

            #region READ a Resource Collection Feed

            // Read a Resource Collection Feed
            var rcu = new SDataResourceCollectionRequest(service);
            rcu.ContractName = "test";
            rcu.DataSet = "prod";
            rcu.ResourceKind = "accounts";

            // pageing
            rcu.StartIndex = 21;
            rcu.Count = 10;

            // query
            rcu.QueryValues.Add("where", "accountid='123456789abc'");
            rcu.QueryValues.Add("orderby", "'account'");

            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/prod/accounts?startIndex=21&count=10 
            // Read the feed from the server
            feed = service.ReadFeed(rcu);

            #endregion

            #region READ a Single Resource Entry

            // Read a Single Resource Entry
            var sru = new SDataSingleResourceRequest(service);
            sru.ContractName = "test";
            sru.ResourceKind = "accounts";
            sru.ResourceSelector = "'A001'";
            // the above configuration generates  http://sdata.acme.com/sdata/sageApp/test/-/accounts('A001') 

            // read the entry from the server
            entry = service.ReadEntry(sru);

            #endregion

            #region READ a Resource Property

            var rpu = new SDataResourcePropertyRequest(service);
            rpu.ContractName = "test";
            rpu.ResourceKind = "accounts";
            rpu.ResourceSelector = "'A001'";
            rpu.ResourceProperties.Add("postalAddress");
            rpu.ResourceProperties.Add("country");
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/accounts('A001')/postalAddress/country

            // read the entry from the server
            entry = service.ReadEntry(rpu);

            // now reconfigure and read property as a feed
            rpu.ResourceProperties.Add("salesOrders('0023')");
            rpu.ResourceProperties.Add("orderLines");
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts('A001')/salesOrders('0023')/orderLines

            // read the feed from the server
            service.ReadFeed(rpu);

            #endregion

            #region READ a Template Resource

            var tru = new SDataTemplateResourceRequest(service);
            tru.ContractName = "test";
            tru.ResourceKind = "accounts";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts/$template 

            // read the entry from the server
            entry = service.ReadEntry(tru);

            #endregion

            #region READ a Resource Schema

            var rsu = new SDataResourceSchemaRequest(service);
            rsu.ContractName = "test";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/$schema

            // read the feed from the server
            var schema = service.ReadSchema(rsu);

            // now reconfigurate and set resource kind and version
            rsu.ResourceKind = "accounts";
            rsu.Version = "5";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/accounts/$schema?version=5

            // read the entry from the server
            schema = service.ReadSchema(rsu);

            #endregion

            #region READ System Resources or Services

            var su = new SDataSystemRequest(service);

            // the above configuration generates http://sdata.acme.com/sdata/$system
            // read the feed from the server
            service.ReadFeed(su);

            #endregion

            #region READ Intermediate URLS

            #region READ Enumeration of Applications

            var iau = new IntermediateApplicationsRequest(service);

            // the above configuration generates http://sdata.acme.com/sdata

            // read the feed from the server
            service.ReadFeed(iau);

            #endregion

            #region READ Enumeration of DataSets

            var idu = new IntermediateDataSetsRequest(service);
            // the above configuration generates http://sdata.acme.com/sdata/sageApp

            // read the feed from the server
            feed = service.ReadFeed(idu);

            #endregion

            #region READ Enumeration of Contracts

            var icu = new IntermediateContractsRequest(service);

            // the above configuration generates http://sdata.acme.com/sdata/sageApp

            // read the feed from the server
            feed = service.ReadFeed(icu);

            #endregion

            #region READ Enumeration of Resource Collections

            var ircu = new IntermediateResourceCollectionsRequest(service);
            ircu.ContractName = "test";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test

            // read the feed from the server
            feed = service.ReadFeed(ircu);

            #endregion

            #region READ Enumeration of Services

            var isu = new IntermediateServicesRequest(service);
            isu.ContractName = "test";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/$service

            // read the feed from the server
            service.ReadFeed(isu);

            // reconfigure and set the resource kind
            isu.ResourceKind = "accounts";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/accounts/$service
            // read the feed from the server
            service.ReadFeed(isu);

            #endregion

            #endregion

            #region Update an Entry

            // Read a Single Resource Entry
            var sru2 = new SDataSingleResourceRequest(service);
            sru2.ContractName = "test";
            sru2.ResourceKind = "accounts";
            sru2.ResourceSelector = "'A001'";
            // the above configuration generates  http://sdata.acme.com/sdata/sageApp/test/accounts('A001') 

            // TODO: Make changes to the entry payload
            payload = newEntry.GetSDataPayload();
            // update the server
            service.UpdateEntry(sru2, newEntry);

            #endregion

            #region DELETE an Entry

            service.DeleteEntry(sru2, newEntry);

            #endregion
        }
        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);
            }
        }
예제 #25
0
파일: Bot.cs 프로젝트: rjledger/Demo-Bot
        public string GetFakeCompanyName()
        {
            Random rand = new Random();
            // Want to make a request to see if the account already exists
            SDataSingleResourceRequest request = new SDataSingleResourceRequest(service)
                {
                    ResourceKind = "accounts"
                };

            var names = new[]
                        {
                            #region Values
                            "Acme, Inc.",
                            "Widget Corp",
                            "123 Warehousing",
                            "Demo Company",
                            "Smith and Co.",
                            "Foo Bars",
                            "ABC Telecom",
                            "Fake Brothers",
                            "QWERTY Logistics",
                            "Demo, inc.",
                            "Sample Company",
                            "Sample, inc",
                            "Acme Corp",
                            "Allied Biscuit",
                            "Ankh-Sto Associates",
                            "Extensive Enterprise",
                            "Galaxy Corp",
                            "Globo-Chem",
                            "Mr. Sparkle",
                            "Globex Corporation",
                            "LexCorp",
                            "LuthorCorp",
                            "North Central Positronics",
                            "Omni Consumer Products",
                            "Praxis Corporation",
                            "Sombra Corporation",
                            "Sto Plains Holdings",
                            "Tessier-Ashpool",
                            "Wayne Enterprises",
                            "Wentworth Industries",
                            "ZiffCorp",
                            "Bluth Company",
                            "Strickland Propane",
                            "Thatherton Fuels",
                            "Three Waters",
                            "Water and Power",
                            "Western Gas & Electric",
                            "Mammoth Pictures",
                            "Mooby Corp",
                            "Gringotts",
                            "Thrift Bank",
                            "Flowers By Irene",
                            "The Legitimate Businessmens Club",
                            "Osato Chemicals",
                            "Transworld Consortium",
                            "Universal Export",
                            "United Fried Chicken",
                            "Virtucon",
                            "Kumatsu Motors",
                            "Keedsler Motors",
                            "Powell Motors",
                            "Industrial Automation",
                            "Sirius Cybernetics Corporation",
                            "U.S. Robotics and Mechanical Men",
                            "Colonial Movers",
                            "Corellian Engineering Corporation",
                            "Incom Corporation",
                            "General Products",
                            "Leeding Engines Ltd.",
                            "Blammo",
                            "Input, Inc.",
                            "Mainway Toys",
                            "Videlectrix",
                            "Zevo Toys",
                            "Ajax",
                            "Axis Chemical Co.",
                            "Barrytron",
                            "Carrys Candles",
                            "Cogswell Cogs",
                            "Spacely Sprockets",
                            "General Forge and Foundry",
                            "Duff Brewing Company",
                            "Dunder Mifflin",
                            "General Services Corporation",
                            "Monarch Playing Card Co.",
                            "Krustyco",
                            "Initech",
                            "Roboto Industries",
                            "Primatech",
                            "Sonky Rubber Goods",
                            "St. Anky Beer",
                            "Stay Puft Corporation",
                            "Vandelay Industries",
                            "Wernham Hogg",
                            "Gadgetron",
                            "Burleigh and Stronginthearm",
                            "BLAND Corporation",
                            "Nordyne Defense Dynamics",
                            "Petrox Oil Company",
                            "Roxxon",
                            "McMahon and Tate",
                            "Sixty Second Avenue",
                            "Charles Townsend Agency",
                            "Spade and Archer",
                            "Megadodo Publications",
                            "Rouster and Sideways",
                            "C.H. Lavatory and Sons",
                            "Globo Gym American Corp",
                            "The New Firm",
                            "SpringShield",
                            "Compuglobalhypermeganet",
                            "Data Systems",
                            "Gizmonic Institute",
                            "Initrode",
                            "Taggart Transcontinental",
                            "Atlantic Northern",
                            "Niagular",
                            "Plow King",
                            "Big Kahuna Burger",
                            "Big T Burgers and Fries",
                            "Chez Quis",
                            "Chotchkies",
                            "The Frying Dutchman",
                            "Klimpys",
                            "The Krusty Krab",
                            "Monks Diner",
                            "Milliways",
                            "Minuteman Cafe",
                            "Taco Grande",
                            "Tip Top Cafe",
                            "Moes Tavern",
                            "Central Perk",
                            "Chasers",
                            "Wal-Mart Stores, Inc.",
                            "Exxon Mobil Corporation",
                            "Chevron Corp.",
                            "General Electric Company",
                            "Bank of America",
                            "ConocoPhillips",
                            "AT&T Inc.",
                            "Ford Motor Company",
                            "JPMorgan Chase & Co.",
                            "Hewlett-Packard Co.",
                            "Berkshire Hathaway Inc.",
                            "Citigroup Incorporated",
                            "Verizon Communications, Incorporated",
                            "McKesson Corporation",
                            "General Motors Company",
                            "American International Group",
                            "Cardinal Health",
                            "CVS Caremark Corporation",
                            "Wells Fargo & Company",
                            "International Business Machines Corp.",
                            "UnitedHealth Group",
                            "Procter & Gamble Co.",
                            "The Kroger Co.",
                            "AmerisourceBergen Corporation",
                            "Costco Wholesale Corporation",
                            "Valero Energy Corporation",
                            "Archer Daniels Midland Company",
                            "Home Depot U S A , Inc.",
                            "Target Corporation, Inc.",
                            "WellPoint, Inc.",
                            "Walgreen Company",
                            "Johnson & Johnson",
                            "State Farm Mutual Automobile Insurance Company",
                            "Medco Health Solutions, Inc.",
                            "Microsoft Corporation",
                            "United Technologies Corporation",
                            "Dell Inc",
                            "The Goldman Sachs Group, Inc.",
                            "Pfizer Incorporated",
                            "Marathon Oil Corporation",
                            "Lowes Companies, Inc.",
                            "United Parcel Service, Inc.",
                            "Lockheed Martin Corp.",
                            "Best Buy Co. Inc.",
                            "Dow Chemical Company",
                            "Supervalu Inc.",
                            "Sears Holdings Corporation",
                            "International Assets Holding Corporation (Orland...",
                            "PepsiCo Inc.",
                            "Metlife, Incorporated",
                            "Safeway, Inc.",
                            "Freddie Mac",
                            "SYSCO Corporation",
                            "Apple Inc.",
                            "The Walt Disney Co.",
                            "Cisco Systems, Inc.",
                            "Comcast Corporation",
                            "FedEx Corporation",
                            "Northrop Grumman Corporation",
                            "Intel Corp",
                            "Aetna Inc.",
                            "New York Life Insurance Company",
                            "Prudential Financial, Incorporated",
                            "Caterpillar",
                            "Sprint Nextel Corporation",
                            "Allstate Insurance Company",
                            "General Dynamics Corporation",
                            "Morgan Stanley",
                            "Liberty Mutual Holding Company Inc",
                            "The Coca-Cola Co.",
                            "Humana Inc.",
                            "Honeywell International Inc.",
                            "Abbott Laboratories",
                            "News Corporation",
                            "HCA Inc.",
                            "Sunoco, Inc.",
                            "Hess Corporation",
                            "Ingram Micro Inc.",
                            "Fannie Mae",
                            "Time Warner Inc.",
                            "Johnson Controls, Inc.",
                            "Delta Air Lines, Inc.",
                            "Merck & Co",
                            "DuPont",
                            "Tyson Foods, Inc.",
                            "American Express",
                            "Rite Aid Corporation",
                            "TIAA-CREF",
                            "CHS Inc.",
                            "Massachusetts Mutual Life Insurance Company",
                            "Philip Morris International Inc",
                            "Raytheon Company",
                            "Express Scripts, Inc.",
                            "The Hartford Financial Services Group Inc.",
                            "The Travelers Companies, Inc.",
                            "Publix Super Markets, Inc.",
                            "Amazon.com, Inc.",
                            "Staples, Inc.",
                            "Google Inc.",
                            "Macys, Inc.",
                            "International Paper Company",
                            "Oracle Corporation",
                            "3M Company",
                            "John Deere Company",
                            "McDonalds Corporation",
                            "Tech Data Corporation",
                            "Motorola Mobility, Inc",
                            "Fluor Corporation",
                            "Eli Lilly and Company",
                            "Coca-Cola Enterprises",
                            "Bristol-Myers Squibb Company",
                            "Northwestern Mutual Life Insurance Company",
                            "DIRECTV",
                            "Emerson Electric Co.",
                            "Nationwide Mutual Insurance Company",
                            "The TJX Companies, Inc.",
                            "American Airlines",
                            "U.S. Bancorp",
                            "PNC Financial Services Group Inc",
                            "Nike, Inc.",
                            "Murphy Oil Corporation",
                            "Kimberly-Clark Corporation",
                            "Alcoa Inc.",
                            "Plains All American Pipeline, L.P.",
                            "CIGNA Corporation",
                            "AFLAC Incorporated",
                            "Time Warner Cable, Inc.",
                            "USAA",
                            "J. C. Penney Company, Inc.",
                            "Exelon Corporation",
                            "Kohls Corporation",
                            "Whirlpool Corporation",
                            "Altria Group, Inc.",
                            "Computer Sciences Corporation",
                            "Tesoro Corporation",
                            "United Continental Holdings, Inc.",
                            "Goodyear Tire & Rubber Co.",
                            "Avnet, Inc.",
                            "ManpowerGroup",
                            "Capital One",
                            "Southern Company",
                            "Health Net, Inc.",
                            "Florida Power & Light Company",
                            "L-3 Communications Inc",
                            "Occidental Petroleum Corp",
                            "Colgate-Palmolive Company",
                            "Xerox Corporation",
                            "Dominion",
                            "Freeport-McMoRan Copper & Gold",
                            "General Mills, Inc.",
                            "AES Corporation",
                            "Arrow Electronics, Inc.",
                            "Halliburton",
                            "Amgen Inc.",
                            "Medtronic Inc.",
                            "Progressive Corporation",
                            "GAP, Inc. / Banana Republic / Old Navy",
                            "Smithfield Foods, Inc.",
                            "Union Pacific Corporation",
                            "Loews Corporation",
                            "EMC Corporation",
                            "BNSF Railway Company",
                            "Coventry Health Care, Inc.",
                            "Illinois Tool Works Inc.",
                            "Viacom Inc.",
                            "Toys R Us, Incorporated",
                            "American Electric Power Company, Inc.",
                            "Pacific Gas and Electric Corp",
                            "ConEdison Solutions",
                            "Chubb Corporation",
                            "CBS Corporation",
                            "ConAgra Foods, Inc.",
                            "FirstEnergy Corp",
                            "Sara Lee Corporation",
                            "Duke Energy Corporation",
                            "National Oilwell Varco",
                            "Continental Airlines, Inc.",
                            "Kellogg Company",
                            "Baxter International Inc.",
                            "Public Service Enterprise Group Incorporated.",
                            "Edison International",
                            "Aramark Corporation",
                            "PPG Industries, Inc.",
                            "Community Health Systems, Incorporated",
                            "Office Depot, Inc.",
                            "KBR, Inc.",
                            "Eaton Corporation",
                            "Dollar General Corporation",
                            "Waste Management, Inc.",
                            "Monsanto Company",
                            "Omnicom Group Inc.",
                            "Jabil Circuit, Inc.",
                            "DISH Network Corporation",
                            "TRW Automotive Holdings Corp.",
                            "Navistar, Inc.",
                            "Jacobs Engineering Group Inc.",
                            "World Fuel Services Corporation",
                            "Nucor Corporation",
                            "Danaher Corporation",
                            "Dean Foods Company",
                            "ONEOK, Inc.",
                            "Liberty Global, Inc.",
                            "United States Steel Corporation",
                            "AutoNation, Inc.",
                            "Marriott International, Inc",
                            "SAIC, Inc.",
                            "YUM! Brands, Inc.",
                            "Branch Banking & Trust (BB&T)",
                            "Cummins, Inc.",
                            "Entergy Corporation",
                            "Textron Inc.",
                            "Marsh & McLennan Companies",
                            "US Airways Group, Inc.",
                            "Texas Instruments Incorporated",
                            "SunTrust Banks, Inc.",
                            "QUALCOMM Incorporated",
                            "Land OLakes Inc",
                            "Liberty Media Corporation",
                            "Avon Products, Inc.",
                            "Southwest Airlines Co.",
                            "Parker Hannifin Corporation",
                            "The Mosaic Company",
                            "BJs Wholesale Club, Inc.",
                            "Heinz North America",
                            "Thermo Fisher Scientific Inc.",
                            "UNUM Group",
                            "Genuine Parts Company",
                            "Guardian Life",
                            "Kiewit Building Group Inc.",
                            "Progress Energy Inc.",
                            "RR Donnelley & Sons Company",
                            "Starbucks Corporation",
                            "Lear Corporation",
                            "Baker Hughes",
                            "Xcel Energy Inc.",
                            "Penske Automotive Group, Inc.",
                            "Energy Future Holdings",
                            "The Great Atlantic & Pacific Tea Co. - A&P",
                            "Fifth Third Bancorp",
                            "State Street Corporation",
                            "First Data Corporation",
                            "Pepco Holdings, Inc.",
                            "URS Corporation",
                            "Tenet Healthcare Corporation",
                            "Regions Financial Corporation",
                            "GameStop Corp.",
                            "Lincoln Financial Group",
                            "Genworth Financial, Inc.",
                            "XTO Energy Inc.",
                            "CSX Corporation",
                            "Anadarko Petroleum Corporation",
                            "Devon Energy Corp",
                            "Praxair, Inc.",
                            "NRG Energy, Incorporated",
                            "Caesars Entertainment, Inc.",
                            "Automatic Data Processing, Incorporated (ADP)",
                            "The Principal Financial Group, Inc.",
                            "eBay Inc.",
                            "Assurant Inc.",
                            "Limited Brands, Inc.",
                            "Nordstrom, Inc.",
                            "Apache Corporation",
                            "R.J. Reynolds Tobacco Company",
                            "Air Products and Chemicals, Inc.",
                            "The Bank of New York Mellon",
                            "CenterPoint Energy, Inc.",
                            "Williams Companies, Inc.",
                            "Smith International, Inc.",
                            "Republic Services, Inc.",
                            "Boston Scientific Corporation",
                            "Ashland Chemical Company",
                            "Sempra Energy",
                            "PACCAR Inc.",
                            "Owens & Minor, Inc.",
                            "Whole Foods Market, Inc.",
                            "DTE Energy Company",
                            "Discover Financial Services",
                            "Norfolk Southern Corporation",
                            "Ameriprise Financial Services Inc.",
                            "Crown Holdings, Inc.",
                            "Icahn Enterprises L.P.",
                            "Masco Corporation",
                            "Cablevision Systems Corporation",
                            "Huntsman Corporation",
                            "SYNNEX Corporation",
                            "Newmont Mining Corporation",
                            "Chesapeake Energy Corporation",
                            "Eastman Kodak Company",
                            "AON Corporation",
                            "Campbell Soup Company",
                            "PPL Corporation",
                            "C.H. Robinson Worldwide, Inc",
                            "Integrys Energy Group, Inc.",
                            "Quest Diagnostics Incorporated",
                            "Western Digital Corp.",
                            "Family Dollar Stores, Inc.",
                            "Winn-Dixie Stores, Inc.",
                            "Ball Corporation",
                            "The Estee Lauder Companies Inc.",
                            "The Shaw Group Inc.",
                            "VF Corporation",
                            "Darden Restaurants, Inc.",
                            "Becton, Dickinson and Company (BD)",
                            "OfficeMax, Inc.",
                            "Bed Bath and Beyond",
                            "Kinder Morgan",
                            "Ross Stores, Inc",
                            "Pilgrims Pride Corporation",
                            "Hertz Corporation",
                            "The Sherwin-Williams Company",
                            "Ameren Corporation",
                            "Reinsurance Group of America, Incorporated",
                            "O-I (Owens Illinois), Inc.",
                            "CarMax, Inc.",
                            "Gilead Sciences, Inc.",
                            "Precision Castparts Corp.",
                            "Visa, Inc.",
                            "Commercial Metals Company",
                            "WellCare Health Plans, Inc.",
                            "AutoZone, Inc.",
                            "Western Refining, Inc.",
                            "Dole Food Company, Inc.",
                            "Charter Communications, Inc.",
                            "Stryker Corporation",
                            "Goodrich Corporation",
                            "Visteon Corporation",
                            "NiSource Inc.",
                            "AGCO Corporation",
                            "Calpine Corporation",
                            "Henry Schein Medical Systems, Inc.",
                            "Hormel Foods Corporation",
                            "ACS Government Systems, Inc.",
                            "Thrivent Financial for Lutherans",
                            "Yahoo!, Inc.",
                            "American Family Insurance Group",
                            "Sonic Automotive, Inc.",
                            "Peabody Energy Corporation",
                            "Omnicare, Inc.",
                            "Dillards, Inc.",
                            "W.W. Grainger, Inc.",
                            "CMS Energy Corporation",
                            "Fortune Brands, Inc.",
                            "AECOM",
                            "Symantec Corporation",
                            "DaVita, Inc.",
                            "KeyCorp",
                            "MEADWESTVACO",
                            "Interpublic Group of Companies Inc",
                            "Virgin Media Inc.",
                            "MGM Resorts International",
                            "The First American Financial Corporation",
                            "Avery Dennison Corporation",
                            "The McGraw-Hill Companies, Inc.",
                            "Enbridge Energy Partners, L.P.",
                            "Ecolab Inc.",
                            "Fidelity National Financial, Inc.",
                            "Dover Corporation",
                            "Global Partners LP",
                            "UGI Corporation",
                            "Gannett Company, Inc.",
                            "Harris Corporation",
                            "Barnes & Noble, Inc.",
                            "Newell Rubbermaid Inc.",
                            "Smurfit-Stone Container Enterprises Inc.",
                            "Pitney Bowes Inc.",
                            "EMCOR Group, Inc.",
                            "Dr Pepper Snapple Group Inc.",
                            "Weyerhaeuser Company",
                            "SunGard Data Systems Inc.",
                            "CH2M HILL Companies, Ltd.",
                            "The Pantry, Inc.",
                            "Domtar Corp.",
                            "The Clorox Company",
                            "Northeast Utilities",
                            "Oshkosh Corporation",
                            "Mattel, Inc",
                            "Energy Transfer Partners, L.P.",
                            "Advance Auto Parts, Inc",
                            "Advanced Micro Devices, Inc.",
                            "Corning Incorporated",
                            "Mohawk Industries, Inc.",
                            "PetSmart, Inc.",
                            "Reliance Steel and Aluminum",
                            "The Hershey Company",
                            "YRC WorldWide Inc.",
                            "Dollar Tree, Inc.",
                            "Dana Holding Company",
                            "Cameron International Corporation",
                            "Nash Finch Company",
                            "Pacific Life Insurance Company",
                            "Terex Corporation",
                            "Universal Health Services, Inc.",
                            "Amerigroup Corporation",
                            "Sanmina-SCI Corporation",
                            "Jarden Corporation",
                            "Tutor Perini Corporation",
                            "Mutual of Omaha Insurance Company",
                            "Avis Budget Group, Inc.",
                            "Autoliv ASP, Inc.",
                            "Mylan Inc.",
                            "Western Union Company",
                            "Celanese Corporation",
                            "Eastman Chemical Company",
                            "Telephone and Data Systems, Inc.",
                            "Polo Ralph Lauren Corporation",
                            "Auto-Owners Insurance Group",
                            "Core-Mark International Inc",
                            "Applied Materials Inc.",
                            "CenturyLink, Inc.",
                            "Atmos Energy Corporation",
                            "Ryder System, Inc.",
                            "SPX Corporation",
                            "Foot Locker, Inc.",
                            "OReilly Automotive, Inc.",
                            "Harley-Davidson, Inc.",
                            "HollyFrontier Corporation",
                            "Micron Technology, Inc.",
                            "Owens Corning",
                            "EOG Resources, Inc.",
                            "Big Lots Stores, Inc.",
                            "Spectra Energy Partners, L.P.",
                            "Starwood Hotels & Resorts Worldwide, Inc.",
                            "United Stationers Inc.",
                            "TravelCenters of America, Inc.",
                            "BlackRock, Inc.",
                            "Laboratory Corporation of America",
                            "Health Management Associates, Inc.",
                            "NYSE Euronext, Inc.",
                            "St. Jude Medical, Inc.",
                            "Tenneco Incorporated",
                            "El Paso Corporation",
                            "WESCO Distribution, Inc.",
                            "CONSOL Energy Inc.",
                            "Meritor, Inc.",
                            "NCR Corporation",
                            "Unisys Corporation",
                            "The Lubrizol Corporation",
                            "Alliant Techsystems, Inc.",
                            "The Washington Post Company",
                            "Las Vegas Sands, Inc.",
                            "Group 1 Automotive, Inc.",
                            "Genzyme Corporation",
                            "Allergan, Inc.",
                            "Broadcom Corporation",
                            "Agilent Technologies, Inc.",
                            "Rockwell Collins, Inc.",
                            "W. R. Berkley Corporation",
                            "Charles Schwab Corporation",
                            "Dicks Sporting Goods Inc",
                            "FMC Technologies, Inc.",
                            "NII Holdings, Inc.",
                            "General Cable Corporation",
                            "Graybar Electric Company, Inc.",
                            "Biogen Idec Inc.",
                            "AbitibiBowater",
                            "Flowserve Corporation",
                            "Airgas Inc",
                            "CNO Financial Group, Inc.",
                            "Rockwell Automation, Inc.",
                            "Kindred Healthcare, Inc.",
                            "American Financial Group, Inc.",
                            "Kelly Services, Inc.",
                            "Spectrum Group International",
                            "RadioShack Corporation",
                            "CA Technologies, Inc.",
                            "Con-Way Freight Inc.",
                            "Erie Insurance Group",
                            "Caseys General Stores, Inc.",
                            "Centene Corporation",
                            "Sealed Air Corporation",
                            "Frontier Oil Corporation",
                            "SCANA Corporation",
                            "Live Nation, Inc.",
                            "Fiserv, Inc.",
                            "Host Hotels & Resorts, Inc.",
                            "H&R Block",
                            "Electronic Arts Inc.",
                            "Franklin Templeton Investments",
                            "Wisconsin Energy Corporation (We Energies)",
                            "Northern Trust Corporation",
                            "MDU Resources Group, Inc.",
                            "CB Richard Ellis Group, Inc.",
                            "Blockbuster LLC",
                            "Baker Hughes",
                            "Insight Enterprises, Inc.",
                            "Levi Strauss and Co.",
                            "Graphic Packaging Holding Company",
                            "Targa Resources Inc.",
                            "Zimmer Holdings, Inc.",
                            "Expeditors International of Washington, Inc.",
                            "Pulte Group",
                            "Ruddick Corporation",
                            "AK Steel Corporation",
                            "Hasbro, Inc.",
                            "Unified Grocers, Inc.",
                            "Energizer Holdings, Inc.",
                            "CIT Group Inc.",
                            "Apollo Group, Inc.",
                            "BorgWarner Inc.",
                            "Steel Dynamics, Inc.",
                            "Realogy Corporation",
                            "Forest Laboratories, Inc.",
                            "Del Monte Foods Company",
                            "Cincinnati Financial Corporation",
                            "Ralcorp a/k/a Bremner Food Group",
                            "Hanesbrands Inc.",
                            "Michaels Stores, Inc.",
                            "Lexmark International, Inc.",
                            "Hospira, Inc.",
                            "NuStar Energy L.P.",
                            "Centex Corporation",
                            "Old Republic International Corporation",
                            "Asbury Automotive Group, Inc.",
                            "Certegy",
                            "Manitowoc Company, Inc",
                            "Simon Property Group, Inc.",
                            "Cintas Corporation",
                            "M&T Bank Corporation",
                            "Stater Brothers Markets",
                            "Level 3 Communications, Inc",
                            "The J. M. Smucker Company",
                            "Wyndham Worldwide Corp.",
                            "Nalco Holding Company",
                            "Stanley Black & Decker, Inc.",
                            "Lorillard Tobacco Company",
                            "FM Global",
                            "Corn Products International, Inc.",
                            "Molina Healthcare, Inc.",
                            "D.R. Horton, Inc.",
                            "Constellation Brands, Inc.",
                            "The Neiman Marcus Group, Inc.",
                            "Brinker International, Inc.",
                            "Seaboard Corporation",
                            "Joy Global Inc",
                            "Sonoco Products Co.",
                            "Edward Jones",
                            "NV Energy Inc",
                            "The Wendys Company",
                            "Temple-Inland Inc.",
                            "Burlington Coat Factory Corporation",
                            "SanDisk Corporation",
                            "VWR International, LLC",
                            "The Timken Company",
                            "Discovery Communications, Inc.",
                            "Bemis Company, Inc.",
                            "US Oncology Inc",
                            "ABM Industries Incorporated",
                            "MetroPCS Communications, Inc.",
                            "Chiquita Brands International, Inc.",
                            "UNFI",
                            "Alliant Energy Corporation",
                            "Allegheny Energy, Inc.",
                            "Annaly Mortgage Management, Inc.",
                            "THE NASDAQ STOCK MARKET INTERNATIONAL LTD.",
                            "NetApp Inc",
                            "Alaska Air Group, Inc.",
                            "Marshall & Ilsley Bank",
                            "RPM International Inc.",
                            "Pactiv Corporation",
                            "Legg Mason",
                            "Belk, Inc.",
                            "Hyatt Hotels Corporation",
                            "Puget Sound Energy Inc",
                            "Jones Group Inc",
                            "NVIDIA Corporation",
                            "Exide Technologies",
                            "Zions Bancorporation",
                            "Quanta Services, Inc.",
                            "Juniper Networks, Inc.",
                            "TECO Energy, Inc.",
                            "Pinnacle West Capital Corporation",
                            "Collective Brands Inc.",
                            "JetBlue Airways Corporation",
                            "Life Technologies Corporation",
                            "Cognizant Technology Solutions Corp.",
                            "Beckman Coulter, Inc.",
                            "Ingles Markets, Inc.",
                            "Huntington Bancshares Inc.",
                            "The ServiceMaster Company",
                            "COUNTRY Financial",
                            "USG Corporation",
                            "Coach, Inc.",
                            "Torchmark Corporation",
                            "Brightpoint",
                            "Tractor Supply Company, Inc.",
                            "J.B. Hunt Transport Services, Incorporated",
                            "Vanguard Health Systems, Inc.",
                            "McCormick & Company Inc",
                            "Berry Plastics Corporation",
                            "Steelcase Inc.",
                            "Intuit Inc.",
                            "Warner Music Group",
                            "Securian Financial",
                            "NSTAR Gas & Electric Company",
                            "Systemax Inc.",
                            "Comerica Incorporated",
                            "Ambac Financial Group, Inc.",
                            "The Scotts Miracle-Gro Company",
                            "CVR Energy, Inc.",
                            "General Growth Properties, Inc"

                            #endregion            };
                        };

                var index = rand.Next(1, names.Count());
            return names[index];
        }
        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();
        }
        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);
            }
        }
예제 #28
0
파일: Bot.cs 프로젝트: rjledger/Demo-Bot
        // 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);;
            }
        }
        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);
            }
        }
        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);
            }
        }