示例#1
0
        /// <summary>
        /// Get Attached Documents
        /// </summary>
        /// <param name="taskOid">TaskOid</param>
        /// <returns>List of DocumentModel</returns>
        private IEnumerable <DocumentModel> GetAttachedDocuments(Guid taskOid)
        {
            var properties = TasksService.GetPropertiesForTask(
                new GetPropertiesForTaskRequest {
                TaskOid = taskOid
            });

            var docs = new List <DocumentModel>();
            var oids = new List <Guid>();

            foreach (var prop in properties.Properties)
            {
                if (prop.Type == PropertyType.FlowDoc.ToString())
                {
                    oids.Add(Guid.Parse(prop.Value));
                }
            }

            var res = DocsDocument.DocumentInfos(oids.ToArray());

            return(res.Select(d => new DocumentModel
            {
                DocumentOid = d.OidDocument.ToString(),
                DocumentName = d.DocumentName
            }).ToList());
        }
示例#2
0
        /// <summary>
        /// Get Task Parameters
        /// </summary>
        /// <param name="taskOid">TaskOid</param>
        /// <returns>List of PropertyInfo</returns>
        private PropertyInfo[] GetTaskParameters(Guid taskOid)
        {
            var properties = TasksService.GetPropertiesForTask(new GetPropertiesForTaskRequest
            {
                TaskOid = taskOid
            });

            return(properties.Properties.ToArray());
        }
        public HttpResponseMessage Operations(string toid, string op, [FromBody] TaskInfo task, string result = "", string message = "")
        {
            Guid oid;

            if (!Guid.TryParse(toid, out oid))
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            try
            {
                if (op.Equals(TaskOperation.Assign.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    TasksService.AssignTaskTo(new AssignTaskToRequest
                    {
                        User    = task.AcceptedBy,
                        TaskOid = oid
                    });
                }
                else if (op.Equals(TaskOperation.Complete.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    TasksService.CompleteTask(new CompleteTaskRequest
                    {
                        TaskId = toid,
                        User   = task.AcceptedBy,
                        Result = result
                    });
                }
                else if (op.Equals(TaskOperation.GiveBack.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    TasksService.GiveBackTask(new GiveBackTaskRequest
                    {
                        TaskOid = oid
                    });
                }
                else if (op.Equals(TaskOperation.Approve.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    var properties = TasksService.GetPropertiesForTask(new GetPropertiesForTaskRequest
                    {
                        TaskOid = Guid.Parse(toid)
                    });

                    var taskFromDb = TasksService.GetTask(new GetTaskRequest {
                        TaskOid = Guid.Parse(toid)
                    });

                    // Do I need this?
                    // If this is necessary think of notification

                    /*
                     * TasksService.AddTraceToWorkflow(new AddTraceToWorkflowRequest
                     *  {
                     *      WorkflowOid = taskFromDb.Task.WorkflowOid.ToString(),
                     *      TaskOid = toid,
                     *      User = task.AcceptedBy,
                     *      Message = message
                     *  });
                     */

                    TasksService.ApproveTask(new ApproveTaskRequest
                    {
                        TaskId        = toid,
                        CorrelationId = taskFromDb.Task.TaskCorrelationId,
                        TaskCode      = taskFromDb.Task.TaskCode,
                        Result        = result,
                        UserName      = task.AcceptedBy,
                        WorkflowId    = taskFromDb.Task.WorkflowOid.ToString(),
                        Parameters    = new PropertyInfos(properties.Properties)
                    });
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }