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

            try
            {
                WorkflowApprovalProcess 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)));
            }
        }
Esempio n. 2
0
        public IHttpActionResult CancelWorkflowTask(TaskData model)
        {
            var instance = GetInstance(model.InstanceGuid);

            try
            {
                WorkflowApprovalProcess process = GetProcess(instance.Type);

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

                return(Json(new
                {
                    status = 200,
                    message = instance.TypeDescription + " workflow cancelled"
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                var msg = "An error occurred cancelling the workflow: " + ex.Message + ex.StackTrace;
                Log.Error(msg + " for workflow " + instance.Id, ex);
                return(Json(new
                {
                    status = 500,
                    message = msg
                }, ViewHelpers.CamelCase));
            }
        }