private void GetEntities(ref ServiceObject so)
        {
            SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0];

            CRMFetchXML fetch = new CRMFetchXML();

            fetch.Config = crmconfig;

            try
            {
                fetch.FetchXML = NotNull(so.Properties["FetchXML"].Value);

                CRMFetchXML response = CRMFunctions.CRMGetEntities(fetch);

                so.Properties.InitResultTable();

                if (response.Entities != null)
                {
                    foreach (CRMState state in response.Entities)
                    {
                        for (int c = 0; c < meth.ReturnProperties.Count; c += 1)
                        {
                            Property prop = so.Properties[meth.ReturnProperties[c]];
                            prop = SetGetEntitiesProperties(prop, state);
                            prop = SetGetEntitiesRESTProperties(prop, response);
                        }
                        so.Properties.BindPropertiesToResultTable();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private Property SetGetEntitiesRESTProperties(Property prop, CRMFetchXML task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "fetchxml":
                    prop.Value = task.FetchXML;
                    break;
                }
            }

            return(prop);
        }
        public RestResponse<CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMGetEntities";

            request.AddBody(crmFetch);

            RestResponse<CRMFetchXML> response = client.Execute<CRMFetchXML>(request);

            return response;
        }
Example #4
0
        public RestResponse <CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMGetEntities";

            request.AddBody(crmFetch);

            RestResponse <CRMFetchXML> response = client.Execute <CRMFetchXML>(request);

            return(response);
        }