Ejemplo n.º 1
0
        public IHttpActionResult CancelWorkflowTask(TaskData model)
        {
            WorkflowInstancePoco instance = GetInstance(model.InstanceGuid);

            try
            {
                WorkflowProcess process     = GetProcess(instance.Type);
                IUser           currentUser = _utility.GetCurrentUser();

                instance = process.CancelWorkflow(
                    instance,
                    currentUser.Id,
                    model.Comment
                    );

                Log.Info($"{instance.TypeDescription} request for {instance.Node.Name} [{instance.NodeId}] was cancelled by {currentUser.Name}");

                return(Json(new
                {
                    status = 200,
                    message = instance.TypeDescription + " workflow cancelled"
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"An error occurred cancelling the workflow on {instance.Node.Name} [{instance.NodeId}]";
                Log.Error(msg, ex);

                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult CancelWorkflowTask(TaskData model)
        {
            WorkflowInstancePoco instance = _instancesService.GetPopulatedInstance(model.InstanceGuid);

            try
            {
                WorkflowProcess process     = instance.GetProcess();
                IUser           currentUser = _utility.GetCurrentUser();

                instance = process.CancelWorkflow(
                    instance,
                    currentUser.Id,
                    model.Comment
                    );

                string typeDescription = instance.WorkflowType.Description(instance.ScheduledDate);

                Log.Info($"{typeDescription} request for {instance.Node.Name} [{instance.NodeId}] was cancelled by {currentUser.Name}");

                _hubContext.Clients.All.TaskCancelled(
                    _tasksService.ConvertToWorkflowTaskList(instance.TaskInstances.ToList(), instance: instance)
                    .LastOrDefault());

                return(Json(new
                {
                    status = 200,
                    message = typeDescription + " workflow cancelled"
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"An error occurred cancelling the workflow on {instance.Node.Name} [{instance.NodeId}]";
                Log.Error(msg, ex);

                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }