Esempio n. 1
0
        public async Task <WorkflowVM> WorkflowByProjectIdAndTaskId(string projectId, Int32 taskId, string user)
        {
            if (string.IsNullOrEmpty(projectId))
            {
                throw new ArgumentException("String is null or empty", "projectId");
            }

            if (string.IsNullOrEmpty(user))
            {
                throw new ArgumentException("String is null or empty", "user");
            }

            ExistingWorkflows     existingWorkflows = new ExistingWorkflows(_ampRepository.GetWorkflowMastersByProjectandTask(projectId, taskId));
            WorkflowRequest       workflowRequest   = new WorkflowRequest(_personService);
            WorkflowResponse      workflowResponse  = new WorkflowResponse(_personService);
            WorkflowConfiguration configuration     = new WorkflowConfiguration();
            WorkflowObject        workflowObj       = new WorkflowObject(_ampRepository, taskId, _documentService);

            string projectStage = _ampRepository.GetProject(projectId).Stage;
            string userRole     = "";

            if (taskId == Constants.PlannedEndDate) // set up the message to workflow screen for planned end date
            {
                ProjectPlannedEndDate projectPlannedEndDate = _ampRepository.GetProjectPlannedEndDate(projectId);
                string message = WorkflowMessages.PlannedEndDatePendingApprovalMessage(projectPlannedEndDate.NewPlannedEndDate);
                workflowObj.WfMessage = message;
            }

            if (existingWorkflows.HasActiveWorkflow())
            {
                workflowRequest.workflow = existingWorkflows.ActiveWorkflowRequest();
                workflowResponse.CreateResponse(workflowRequest.workflow);
                userRole = SetUserRole(user, projectId, workflowRequest.workflow.Recipient);
            }
            else if (existingWorkflows.LastWorkflowWasRejected())
            {
                workflowRequest.workflow  = existingWorkflows.LastRejectedWorkflowRequest();
                workflowResponse.workflow = existingWorkflows.LastRejectedWorkflowResponse();
                userRole = SetUserRole(user, projectId, workflowRequest.workflow.Recipient);
            }
            else
            {
                workflowRequest.CreateRequest(projectId, taskId, user);
                workflowResponse.response = new WorkflowMaster();
                userRole = SetUserRole(user, projectId, null);
            }

            await workflowObj.Construct(workflowRequest, workflowResponse, userRole);

            return(workflowObj);
        }
Esempio n. 2
0
        public async Task <WorkflowVM> WorkflowByWorkflowId(Int32 workflowId, string user)
        {
            string userRole;
            Int32  taskId;
            string projectId;

            ExistingWorkflows existingWorkflows = new ExistingWorkflows(_ampRepository.GetWorkflowMasters(workflowId));

            if (existingWorkflows.HasWorkflows())
            {
                WorkflowRequest       request       = new WorkflowRequest(_personService);
                WorkflowResponse      response      = new WorkflowResponse(_personService);
                WorkflowConfiguration configuration = new WorkflowConfiguration();
                WorkflowObject        workflowObj;
                request.workflow  = existingWorkflows.WorkflowRequest(workflowId);
                response.workflow = existingWorkflows.WorkflowResponse(workflowId);

                taskId    = request.workflow.TaskID;
                projectId = request.workflow.ProjectID;
                string projectStage = _ampRepository.GetProject(projectId).Stage;

                workflowObj = new WorkflowObject(_ampRepository, request.workflow.TaskID, _documentService);
                userRole    = SetUserRole(user, request.workflow.ProjectID, request.workflow.Recipient);

                await workflowObj.Construct(request, response, userRole);

                if (taskId == Constants.PlannedEndDate && response.workflow.StageID != 3)// set up the message to workflow screen for planned end date only if approved
                {
                    ProjectPlannedEndDate projectPlannedEndDate = _ampRepository.GetProjectPlannedEndDatForWorkflowHistory(workflowId);
                    string message = WorkflowMessages.PlannedEndDateWorkflowHistoryMessage(projectPlannedEndDate.CurrentPlannedEndDate, projectPlannedEndDate.NewPlannedEndDate);
                    workflowObj.WfMessage = message;
                }



                return(workflowObj);
            }

            return(null);
        }