/// <summary> /// Approve Task /// </summary> /// <param name="workflowOid"></param> /// <param name="taskOid"></param> /// <param name="message"></param> /// <param name="correlationId"></param> /// <param name="taskCode"></param> /// <param name="parameters"></param> /// <param name="result"></param> private void ApproveTask(string workflowOid, string taskOid, string message, int correlationId, string taskCode, IEnumerable <PropertyInfo> parameters, string result) { TasksService.AddTraceToWorkflow(new AddTraceToWorkflowRequest { WorkflowOid = workflowOid, TaskOid = taskOid, User = HttpContext.User.Identity.Name, Message = message }); TasksService.ApproveTask(new ApproveTaskRequest { TaskId = taskOid, CorrelationId = correlationId, TaskCode = taskCode, Result = result, UserName = HttpContext.User.Identity.Name, WorkflowId = workflowOid, Parameters = new PropertyInfos(parameters) }); }
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)); }