private Property SetBulkActionTasksRESTProperties(Property prop, CRMBulkActionTask task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "fetchxml":
                    prop.Value = task.FetchXML;
                    break;

                case "fromstate":
                    prop.Value = task.FromState;
                    break;

                case "fromstatus":
                    prop.Value = task.FromStatus;
                    break;

                case "tostate":
                    prop.Value = task.ToState;
                    break;

                case "tostatus":
                    prop.Value = task.ToStatus;
                    break;
                }
            }
            return(prop);
        }
        private void BulkActionTasksSetCriteria(ref ServiceObject so)
        {
            SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0];

            CRMBulkActionTask fetch = new CRMBulkActionTask();

            fetch.Config = crmconfig;

            try
            {
                string fetchstring = string.Empty;
                if (!string.IsNullOrEmpty(NotNull(so.Properties["K2ActivityName"])))
                {
                    fetchstring = Resources.K2CRMTaskCleanUpFinishRule.Replace("[entityid]", NotNull(so.Properties["RegardingId"].Value)).Replace("[entityname]", NotNull(so.Properties["Regarding"].Value));
                    fetchstring = fetchstring.Replace("[processname]", NotNull(so.Properties["K2ProcessName"].Value));
                    fetchstring = fetchstring.Replace("[statecode]", NotNull(so.Properties["FromState"].Value));
                    fetchstring = fetchstring.Replace("[processinstanceid]", NotNull(so.Properties["K2ProcessInstanceId"].Value));
                }
                else
                {
                    fetchstring = Resources.K2CRMTaskCleanUpState0FetchXML.Replace("[entityid]", NotNull(so.Properties["RegardingId"].Value)).Replace("[entityname]", NotNull(so.Properties["Regarding"].Value));
                    fetchstring = fetchstring.Replace("[activityname]", NotNull(so.Properties["K2ActivityName"].Value));
                    fetchstring = fetchstring.Replace("[processname]", NotNull(so.Properties["K2ProcessName"].Value));
                    fetchstring = fetchstring.Replace("[statecode]", NotNull(so.Properties["FromState"].Value));
                    fetchstring = fetchstring.Replace("[processinstanceid]", NotNull(so.Properties["K2ProcessInstanceId"].Value));
                }

                fetch.FetchXML   = fetchstring;
                fetch.FromState  = int.Parse(NotNull(so.Properties["FromState"].Value));
                fetch.FromStatus = int.Parse(NotNull(so.Properties["FromStatus"].Value));
                fetch.ToState    = int.Parse(NotNull(so.Properties["ToState"].Value));
                fetch.ToStatus   = int.Parse(NotNull(so.Properties["ToStatus"].Value));

                CRMBulkActionTask response = CRMFunctions.CRMBulkActionTasks(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 = SetBulkActionTasksRESTProperties(prop, response);
                        }
                        so.Properties.BindPropertiesToResultTable();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public RestResponse<CRMBulkActionTask> BulkActionTasks(CRMBulkActionTask crmBulk, 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/CRMBulkActionTasks";

            request.AddBody(crmBulk);

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

            return response;
        }
Example #4
0
        public RestResponse <CRMBulkActionTask> BulkActionTasks(CRMBulkActionTask crmBulk, 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/CRMBulkActionTasks";

            request.AddBody(crmBulk);

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

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

            CRMBulkActionTask fetch = new CRMBulkActionTask();

            fetch.Config = crmconfig;

            try
            {
                fetch.FetchXML   = NotNull(so.Properties["FetchXML"].Value);
                fetch.FromState  = int.Parse(NotNull(so.Properties["FromState"].Value));
                fetch.FromStatus = int.Parse(NotNull(so.Properties["FromStatus"].Value));
                fetch.ToState    = int.Parse(NotNull(so.Properties["ToState"].Value));
                fetch.ToStatus   = int.Parse(NotNull(so.Properties["ToStatus"].Value));

                CRMBulkActionTask response = CRMFunctions.CRMBulkActionTasks(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 = SetBulkActionTasksRESTProperties(prop, response);
                        }
                        so.Properties.BindPropertiesToResultTable();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }