コード例 #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);
        }
コード例 #2
0
        public async Task <bool> StartWorkflow(WorkflowVM workflowvm, string user)
        {
            try
            {
                VMToWorkflowMasterMapper workflowMapper = new VMToWorkflowMasterMapper();

                WorkflowMaster request = workflowMapper.MapVMToWorkflowMaster(workflowvm.WorkflowRequest);
                RequestBuilder builder = new RequestBuilder(request, _ampRepository, user);

                builder.BuildWorkflowMaster();

                if (workflowvm.DocumentID != null)
                {
                    WorkflowDocumentBuilder documentBuilder = new WorkflowDocumentBuilder(workflowvm.DocumentID, workflowvm.DocumentDescription, builder.workflow.WorkFlowID, user);
                    documentBuilder.Build();
                    _ampRepository.InsertWorkflowDocument(documentBuilder.Document);
                }

                _ampRepository.InsertWorkFlowMaster(builder.workflow);
                _ampRepository.Save();

                // need to handle planned end date - the planned end date table row for the project
                // is inserted befre workflow task is created. Now the workflow is created
                // and being sennt for approval we need to update the newly created row for the project
                // in the planned end date table with the workflowTaskID
                if (workflowvm.WorkflowRequest.TaskID == Constants.PlannedEndDate)
                {
                    ProjectPlannedEndDate projectPlannedEndToUpdate =
                        _ampRepository.GetProjectPlannedEndDate(request.ProjectID);
                    projectPlannedEndToUpdate.WorkTaskID = request.WorkFlowID;
                    _ampRepository.UpdatePlannedEndDate(projectPlannedEndToUpdate);
                    _ampRepository.Save();
                }

                return(true);
            }
            catch (Exception exception)
            {
                _errorengine.LogError(workflowvm.WorkflowResponse.ProjectID, exception, user);
                return(false);
            }
        }
コード例 #3
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);
        }