public IHttpActionResult ResubmitWorkflowTask(TaskData model)
        {
            WorkflowInstancePoco instance = GetInstance(model.InstanceGuid);

            try
            {
                WorkflowApprovalProcess process = GetProcess(instance.Type);
                IUser currentUser = Utility.GetCurrentUser();

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

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

                return(Json(new
                {
                    message = $"Changes resubmitted successfully. Page will be {instance.TypeDescriptionPastTense.ToLower()} following workflow completion.",
                    status = 200
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"An error occurred processing the approval on {instance.Node.Name} [{instance.NodeId}]";
                Log.Error(msg, ex);

                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }
        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)));
            }
        }
Beispiel #3
0
        public IHttpActionResult ResubmitWorkflowTask(TaskData model)
        {
            WorkflowInstancePoco instance = GetInstance(model.InstanceGuid);

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

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

                return(Json(new
                {
                    message = "Changes resubmitted successfully. Page will be " + instance.TypeDescriptionPastTense.ToLower() + " following workflow completion.",
                    status = 200
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = "An error occurred processing the approval: " + ex.Message + ex.StackTrace;
                Log.Error(msg + " for workflow " + instance.Id, ex);

                return(Json(new
                {
                    message = msg,
                    status = 500
                }, ViewHelpers.CamelCase));
            }
        }
Beispiel #4
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));
            }
        }
Beispiel #5
0
        public IHttpActionResult RejectWorkflowTask(TaskData model)
        {
            var instance = GetInstance(model.InstanceGuid);

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

                instance = process.ActionWorkflow(
                    instance,
                    WorkflowAction.Reject,
                    Utility.GetCurrentUser().Id,
                    model.Comment
                    );

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

                return(Json(new
                {
                    message = msg,
                    status = 500
                }, ViewHelpers.CamelCase));
            }
        }
        public IHttpActionResult ApproveWorkflowTask(TaskData model)
        {
            WorkflowInstancePoco instance = GetInstance(model.InstanceGuid);

            try
            {
                WorkflowApprovalProcess process = GetProcess(instance.Type);
                IUser currentUser = Utility.GetCurrentUser();

                instance = process.ActionWorkflow(
                    instance,
                    WorkflowAction.Approve,
                    currentUser.Id,
                    model.Comment
                    );

                string msg    = string.Empty;
                string logMsg = string.Empty;

                switch (instance.WorkflowStatus)
                {
                case WorkflowStatus.PendingApproval:
                    msg    = $"Approval completed successfully. Page will be {instance.TypeDescriptionPastTense.ToLower()} following workflow completion.";
                    logMsg = $"Workflow {instance.TypeDescription} task on {instance.Node.Name} [{instance.NodeId}] approved by {currentUser.Name}";
                    break;

                case WorkflowStatus.Approved:
                    msg    = "Workflow approved successfully.";
                    logMsg = $"Workflow approved by {currentUser.Name} on {instance.Node.Name} [{instance.NodeId}]";

                    if (instance.ScheduledDate.HasValue)
                    {
                        string scheduled = $" Page scheduled for {instance.TypeDescription} at {instance.ScheduledDate.Value.ToString("dd MMM YYYY", CultureInfo.CurrentCulture)}";
                        msg    += scheduled;
                        logMsg += scheduled;
                    }
                    else
                    {
                        msg += $" Page has been {instance.TypeDescriptionPastTense.ToLower()}";
                    }
                    break;
                }

                Log.Info(logMsg);

                return(Json(new
                {
                    message = msg,
                    status = 200
                }, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                string msg = $"An error occurred processing the approval on {instance.Node.Name} [{instance.Node.Id}]";
                Log.Error(msg, ex);

                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, msg)));
            }
        }
Beispiel #7
0
        public IHttpActionResult ApproveWorkflowTask(TaskData model)
        {
            var instance = GetInstance(model.InstanceGuid);

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

                instance = process.ActionWorkflow(
                    instance,
                    WorkflowAction.Approve,
                    Utility.GetCurrentUser().Id,
                    model.Comment
                    );

                var msg = string.Empty;

                switch (instance.WorkflowStatus)
                {
                case WorkflowStatus.PendingApproval:
                    msg = "Approval completed successfully. Page will be " + instance.TypeDescriptionPastTense.ToLower() + " following workflow completion.";
                    break;

                case WorkflowStatus.Approved:
                    msg = "Workflow approved successfully.";

                    if (instance.ScheduledDate.HasValue)
                    {
                        msg += " Page scheduled for " + instance.TypeDescription + " at " + instance.ScheduledDate.ToString();
                    }
                    else
                    {
                        msg += " Page has been " + instance.TypeDescriptionPastTense.ToLower();
                    }
                    break;
                }

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