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

            //bool async = false;
            //bool.TryParse(NotNull(so.Properties["ExecuteAsync"].Value), out async);

            CRMTask task = new CRMTask();

            task.Config = crmconfig;

            task.Category       = NotNull(so.Properties["Category"].Value);
            task.Description    = NotNull(so.Properties["Description"].Value);
            task.DueDate        = DateTime.Parse(NotNull(so.Properties["DueDate"].Value));
            task.Duration       = int.Parse(NotNull(so.Properties["Duration"].Value));
            task.OwnerFQN       = NotNull(so.Properties["OwnerFQN"].Value);
            task.OwnerId        = NotNull(so.Properties["OwnerId"].Value);
            task.Owner          = NotNull(so.Properties["Owner"].Value);
            task.Priority       = int.Parse(NotNull(so.Properties["Priority"].Value));
            task.Regarding      = NotNull(so.Properties["Regarding"].Value);
            task.RegardingId    = NotNull(so.Properties["RegardingId"].Value);
            task.State          = int.Parse(NotNull(so.Properties["State"].Value));
            task.Status         = int.Parse(NotNull(so.Properties["Status"].Value));
            task.Subcategory    = NotNull(so.Properties["Subcategory"].Value);
            task.Subject        = NotNull(so.Properties["Subject"].Value);
            task.K2SerialNumber = NotNull(so.Properties["K2SerialNumber"].Value);
            task.K2ActivityName = NotNull(so.Properties["K2ActivityName"].Value);
            task.K2ProcessName  = NotNull(so.Properties["K2ProcessName"].Value);
            if (!string.IsNullOrEmpty(NotNull(so.Properties["K2ProcessInstanceId"].Value)))
            {
                task.K2ProcessInstanceId = int.Parse(NotNull(so.Properties["K2ProcessInstanceId"].Value));
            }
            try
            {
                CRMTask response = CRMFunctions.CRMCreateTask(task);

                if (response != null)
                {
                    so.Properties.InitResultTable();

                    for (int c = 0; c < meth.ReturnProperties.Count; c += 1)
                    {
                        Property prop = so.Properties[meth.ReturnProperties[c]];
                        prop = SetTaskProperties(prop, response);
                    }
                    so.Properties.BindPropertiesToResultTable();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public RestResponse<CRMTask> CreateTask(CRMTask crmTask, 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/CRMCreateTask";

            request.AddBody(crmTask);

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

            return response;
        }
Esempio n. 3
0
        public RestResponse <CRMTask> CreateTask(CRMTask crmTask, 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/CRMCreateTask";

            request.AddBody(crmTask);

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

            return(response);
        }
        private Property SetTaskProperties(Property prop, CRMTask task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "taskid":
                    prop.Value = task.Id;
                    break;

                case "category":
                    prop.Value = task.Category;
                    break;

                case "description":
                    prop.Value = task.Description;
                    break;

                case "duedate":
                    prop.Value = task.DueDate;
                    break;

                case "duration":
                    prop.Value = task.Duration;
                    break;

                case "ownerfqn":
                    prop.Value = task.OwnerFQN;
                    break;

                case "owner":
                    prop.Value = task.Owner;
                    break;

                case "ownerid":
                    prop.Value = task.OwnerId;
                    break;

                case "priority":
                    prop.Value = task.Priority;
                    break;

                case "regarding":
                    prop.Value = task.Regarding;
                    break;

                case "regardingid":
                    prop.Value = task.RegardingId;
                    break;

                case "state":
                    prop.Value = task.State;
                    break;

                case "status":
                    prop.Value = task.Status;
                    break;

                case "subcategory":
                    prop.Value = task.Subcategory;
                    break;

                case "subject":
                    prop.Value = task.Subject;
                    break;

                case "k2serialnumber":
                    prop.Value = task.K2SerialNumber;
                    break;

                case "k2processname":
                    prop.Value = task.K2ProcessName;
                    break;

                case "k2activityname":
                    prop.Value = task.K2ActivityName;
                    break;

                case "k2processinstanceid":
                    prop.Value = task.K2ProcessInstanceId;
                    break;
                }
            }

            return(prop);
        }