Service class for processing SData Request
Inheritance: ISDataService, ISDataRequestSettings
        public void Service_Verity_CanInitialize()
        {
            var service = new SDataService("http://localhost:59213/sdata/aw/dynamic/-/employees", "lee", "abc123");

            Expect(service.UserName, Is.Not.Null);
            Expect(service.UserName, Is.EqualTo("lee"));

            Expect(service.Password, Is.Not.Null);
            Expect(service.Password, Is.EqualTo("abc123"));

            Expect(service.Protocol, Is.Not.Null);
            Expect(service.Protocol, Is.EqualTo("http"));

            Expect(service.ServerName, Is.Not.Null);
            Expect(service.ServerName, Is.EqualTo("localhost"));

            Expect(service.Port, Is.Not.Null);
            Expect(service.Port, Is.EqualTo(59213));

            Expect(service.VirtualDirectory, Is.Not.Null);
            Expect(service.VirtualDirectory, Is.EqualTo("sdata"));

            Expect(service.ApplicationName, Is.Not.Null);
            Expect(service.ApplicationName, Is.EqualTo("aw"));

            Expect(service.ContractName, Is.Not.Null);
            Expect(service.ContractName, Is.EqualTo("dynamic"));

            Expect(service.DataSet, Is.Not.Null);
            Expect(service.DataSet, Is.EqualTo("-"));
        }
    public static ISDataService mydataService()
    {
        try
        {
            string sData = SLX_Outlook_AddIn.Properties.Settings.Default.SDATA;
            string userName = SLX_Outlook_AddIn.Properties.Settings.Default.UserName;
            string password = SLX_Outlook_AddIn.Properties.Settings.Default.Password;

            string temp = sData.Substring(sData.Length - 1, 1);

            if (temp == "/")
            {
                sData += "sdata/slx/dynamic/-/";
            }
            else
            {
                sData += "/sdata/slx/dynamic/-/";
            }

            ISDataService service;
            service = new SDataService(sData, userName, password);

            return service;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
Esempio n. 3
0
        public SDataConnection(String url, String user, String password)
        {
            this.url = url;
            this.user = user;
            this.password = password;

            ISDataService service = new SDataService(url, user, password);
            var request = new SDataResourceCollectionRequest(service);
            this.request = request;
        }
        public void BatchProcess_RequestRemovedOnDispose()
        {
            var service = new SDataService("http://localhost:59213/sdata/aw/dynamic/-/");

            using (var request = new SDataBatchRequest(service))
            {
                Assert.That(BatchProcess.Instance.Requests, Contains.Item(request));
            }

            Assert.That(BatchProcess.Instance.Requests, Is.Empty);
        }
        public MainForm()
        {
            InitializeComponent();

            var service = new SDataService();

            foreach (TabPage tab in tabControl1.TabPages)
            {
                ((BaseControl) tab.Controls[0]).Service = service;
            }

            tabControl1_SelectedIndexChanged(null, null);
        }
        public void BatchProcess_AddItemWithUnsuitableRequest()
        {
            var service = new SDataService("http://localhost:59213/sdata/aw/dynamic/-/");

            using (var request = new SDataBatchRequest(service) {ResourceKind = "employees"})
            {
                var item = new SDataBatchRequestItem
                           {
                               Url = "http://localhost:59213/sdata/aw/dynamic/-/contacts"
                           };
                var added = BatchProcess.Instance.AddToBatch(item);
                Assert.That(added, Is.False);
                Assert.That(request.Items, Is.Empty);
            }
        }
Esempio n. 7
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() };
 }
Esempio n. 8
0
    private ResourceLocator CreateAccount(SDataService ws, int numContacts, int numOpportunities)
    {
        Dictionary<String, object> accValues = new Dictionary<string, object>();
        accValues["AccountName"] = "Test Account";
        ResourceLocator account = CreateResource(ws, "Account", accValues);
        ResourceLocator[] contactIds = new ResourceLocator[numContacts];
        while (numContacts > 0)
        {
            contactIds[numContacts - 1] = CreateContact(ws, account.Id);
            numContacts--;
        }
        while (numOpportunities > 0)
        {
            CreateOpportunity(ws, account.Id, contactIds);
            numOpportunities--;
        }

        return account;
    }
Esempio n. 9
0
        private void cmdTest_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = txtUserName.Text;
                string password = txtPassword.Text;
                string url = txtSdata.Text;

                string temp = txtSdata.Text.Substring(txtSdata.Text.Length - 1, 1);

                if (temp == "/")
                {
                    url += "sdata/slx/dynamic/-/";
                }
                else
                {
                    url += "/sdata/slx/dynamic/-/";
                }

                ISDataService service;
                service = new SDataService(url, userName, password);

                SDataResourceCollectionRequest sdataCollection = new SDataResourceCollectionRequest(service);

                sdataCollection.ResourceKind = "Accounts";

                AtomFeed accountFeed = sdataCollection.Read();

                if (accountFeed.Entries.Count() > 0)
                {
                    MessageBox.Show("Test Successful");
                }
            }
            catch (SDataClientException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }
        }
        private void InitializeSDataForMe()
        {
            //remember _service is global (defined up above)
            _service = new Sage.SData.Client.Core.SDataService();
            //yes the above line could have been shorter if I used a using statement;
            //Doing that makes the code harder to read IMO.

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

            //http://localhost:3333/sdata/slx/dynamic/-/clientprojects
            _service.Protocol = "HTTP";
            _service.ServerName = "localhost:3333";
            _service.ApplicationName = "slx";
            _service.VirtualDirectory = "sdata";
            _service.ContractName = "dynamic";
            _service.DataSet = "-";

            //another way of doing this:
            //mydataService = new SDataService("http://localhost:2001/sdata/slx/dynamic/-/", "admin", "");
        }
 public void Service_Verify_CanConstruct()
 {
     var service = new SDataService();
     Expect(service, Is.Not.Null);
 }
Esempio n. 12
0
 private void DeleteResource(SDataService ws, String resourceName, ResourceLocator resourceId)
 {
     var sru = new SDataSingleResourceRequest(ws);
     sru.ResourceKind = resourceName.ToLower() + "s";
     sru.ResourceSelector = "'" + resourceId.Id + "'";
     sru.Delete();
 }
Esempio n. 13
0
        private AtomEntry CreateServiceOperationAsync(SDataService service)
        {
            var request = new SDataServiceOperationRequest(service);
            request.ApplicationName = "sageApp";
            request.ContractName = "test";
            request.OperationName = "computePrice";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/$service/computePrice

            // read the entry from the server
            var asyncRequest = request.CreateAsync();
            ISyndicationResource result;

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

            return result as AtomEntry;
        }
Esempio n. 14
0
        private AtomEntry CreateServiceRequest(SDataService service)
        {
            var request = new SDataServiceOperationRequest(service);
            request.ContractName = "test";
            request.ResourceKind = "products";
            request.OperationName = "computePrice";
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/products/$service/computePrice

            // now reconfigure and generate for globally for the entire contract
            request.ResourceKind = string.Empty;
            // the above configuration generates http://sdata.acme.com/sdata/sageApp/test/-/$service/computePrice

            // read the feed from the server
            return request.Create();
        }
Esempio n. 15
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
        }
Esempio n. 16
0
    private SDataService GetSDataService(String url, String username, String password)
    {
        SDataService service = new SDataService();

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

        Uri sdataUri = new Uri(url);
        service.Protocol = sdataUri.Scheme;
        service.ServerName = sdataUri.Host;
        service.ApplicationName = "slx";
        service.ContractName = "dynamic";
        service.VirtualDirectory = sdataUri.AbsolutePath;
        return service;
    }
 public void Service_Verify_CanConstructWithUrl()
 {
     var service = new SDataService("http://localhost:59213/sdata/aw/dynamic/-/employees", "lee", "abc123");
     Expect(service, Is.Not.Null);
 }
Esempio n. 18
0
    private ResourceLocator CreateOpportunity(SDataService ws, String accountId, ResourceLocator[] contactIds)
    {
        Dictionary<String, object> oppValues = new Dictionary<string, object>();
        oppValues["Account"] = new SDataPayload { Key = accountId };
        oppValues["Description"] = "Test Opportunity";
        oppValues["Owner"] = new SDataPayload { Key = "SYST00000001" };

        SDataPayload[] contacts = new SDataPayload[contactIds.Length];
        int i = 0;
        foreach (ResourceLocator conId in contactIds)
        {
            SDataPayload oppCon = new SDataPayload { ResourceName = "OpportunityContact" };
            oppCon.Values["Contact"] = new SDataPayload { Key = conId.Id };
            contacts[i++] = oppCon;
        }
        oppValues["OpportunityContacts"] = contacts;
        return CreateResource(ws, "Opportunity", oppValues, "opportunities");
    }
Esempio n. 19
0
        public Bot(string address, string startWorking, string endWorking, string userID, string password, System.Windows.Forms.Label progressLab, System.Windows.Forms.Label activitiesCreate, System.Windows.Forms.Label notesCreate, System.Windows.Forms.Label activitiesComplete, System.Windows.Forms.Label leadCreate, System.Windows.Forms.Label accountCreate, System.Windows.Forms.Label contactCreate, System.Windows.Forms.Label oppCreate, System.Windows.Forms.Label ticketCreate, System.Windows.Forms.Label oppUpdate, System.Windows.Forms.Label leadPromote, System.Windows.Forms.Label role, decimal activityCompleteAm, ComboBox roleSelect, bool noteCheck, bool activityCheck, bool leadCheck, bool accountCheck, bool contactCheck, bool oppCheck, bool ticketCheck, bool oppUpdateCheck, bool actCompleteCheck, bool leadPromoteCheck, decimal reliabilityValue, string creationUpper)
        {
            service = new SDataService("https://" + address + "/sdata/slx/system/-/") { UserName = userID, Password = password };
            dynamic = new SDataService("https://" + address + "/sdata/slx/dynamic/-/") { UserName = userID, Password = password };
            UserID = userID;
            Password = password;
            firstRun = true;
            progressLabel = progressLab;
            activitiesCreated = activitiesCreate;
            activitiesCompleted = activitiesComplete;
            activityCompleteAmount = activityCompleteAm;
            leadCreated = leadCreate;
            accountCreated = accountCreate;
            contactCreated = contactCreate;
            oppCreated = oppCreate;
            ticketCreated = ticketCreate;
            oppUpdated = oppUpdate;
            roleLabel = role;
            notesCreated = notesCreate;
            leadPromoted = leadPromote;
            roleSelector = roleSelect;
            noteCheckBox = noteCheck;
            activityCheckBox = activityCheck;
            leadCheckBox = leadCheck;
            accountCheckBox = accountCheck;
            contactCheckBox = contactCheck;
            oppCheckBox = oppCheck;
            ticketCheckBox = ticketCheck;
            oppUpdateCheckBox = oppUpdateCheck;
            completeActivityBox = actCompleteCheck;
            leadPromoteCheckBox = leadPromoteCheck;
            reliability = Convert.ToDouble(reliabilityValue);
            notesCount = 0;
            activitiesCount = 0;
            activitiesCompleteCount = 0;
            leadsCount = 0;
            ticketsCount = 0;
            opportunitiesCount = 0;
            oppsUpdatedCount = 0;
            accountsCount = 0;
            contactsCount = 0;
            leadsPromotedCount = 0;
            if (creationUpper != "")
                upperBoundMonth = Convert.ToInt32(creationUpper);
            else
                upperBoundMonth = 0;
            if (startWorking == "")
                startWork = Convert.ToDateTime("7:30AM");
            else
                startWork = Convert.ToDateTime(startWorking + "AM");
            if (endWorking == "")
                endWork = Convert.ToDateTime("6:30PM");
            else
                endWork = Convert.ToDateTime(endWorking + "PM");
            //writer = new StreamWriter(@"C:\Swiftpage\" + UserID + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + ".txt");
            fileName = @"C:\Swiftpage\" + UserID + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + ".txt";

            // Change which user creates data in Chinese (Simplified) by adding '|| UserID == "user"' after current value, or merely replace 'China' with the desired user.
            if (UserID == "China")
                language = "Chinese";
        }
Esempio n. 20
0
 private ResourceLocator[] CreateAccounts(SDataService svc, int numAccounts, int numContacts, int numOpportunities)
 {
     ResourceLocator[] createdAccounts = new ResourceLocator[numAccounts];
     while (numAccounts > 0)
     {
         createdAccounts[numAccounts - 1] = CreateAccount(svc, numContacts, numOpportunities);
         numAccounts--;
     }
     return createdAccounts;
 }
        private bool testSettings()
        {
            try
            {

                string userName = Properties.Settings.Default.UserName;
                string password = Properties.Settings.Default.Password;
                string url = Properties.Settings.Default.SDATA;

                if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(url))
                {
                    return false;
                }

                string temp = url.Substring(url.Length - 1, 1);

                if (temp == "/")
                {
                    url += "sdata/slx/dynamic/-/";
                }
                else
                {
                    url += "/sdata/slx/dynamic/-/";
                }

                ISDataService service;
                service = new SDataService(url, userName, password);

                SDataResourceCollectionRequest sdataCollection = new SDataResourceCollectionRequest(service);

                sdataCollection.ResourceKind = "Accounts";

                AtomFeed accountFeed = sdataCollection.Read();

                if (accountFeed.Entries.Count() > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (SDataClientException ex)
            {
                return false;
            }
        }
Esempio n. 22
0
 private ResourceLocator CreateContact(SDataService ws, String accountId)
 {
     Dictionary<String, object> conValues = new Dictionary<string, object>();
     conValues["Account"] = new SDataPayload { Key = accountId };
     conValues["LastName"] = "Test";
     conValues["FirstName"] = "Joe";
     return CreateResource(ws, "Contact", conValues);
 }