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

            CRMWorkflow crmWF = new CRMWorkflow();

            crmWF.Config = crmconfig;

            try
            {
                crmWF.EntityId     = NotNull(so.Properties["EntityId"].Value);
                crmWF.WorkflowName = NotNull(so.Properties["WorkflowName"].Value);

                CRMWorkflow response = CRMFunctions.CRMStartWorkflow(crmWF);

                so.Properties.InitResultTable();

                for (int c = 0; c < meth.ReturnProperties.Count; c += 1)
                {
                    Property prop = so.Properties[meth.ReturnProperties[c]];
                    prop = SetCRMWorkflowProperties(prop, response);
                }

                so.Properties.BindPropertiesToResultTable();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #2
0
        public RestResponse <CRMWorkflow> StartWorkflow(CRMWorkflow crmWF, 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/CRMStartWorkflow";

            request.AddBody(crmWF);

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

            return(response);
        }
        private Property SetCRMWorkflowProperties(Property prop, CRMWorkflow task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "entityid":
                    prop.Value = task.EntityId;
                    break;

                case "workflowid":
                    prop.Value = task.WorkflowId;
                    break;
                }
            }

            return(prop);
        }
        public RestResponse<CRMWorkflow> StartWorkflow(CRMWorkflow crmWF, 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/CRMStartWorkflow";

            request.AddBody(crmWF);

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

            return response;
        }