Пример #1
0
        public void ApproveWorkflow(WorkflowVM workflowVm, string userId)
        {
            try
            {
                VMToWorkflowMasterMapper workflowMapper = new VMToWorkflowMasterMapper();

                WorkflowMaster request  = workflowMapper.MapVMToWorkflowMaster(workflowVm.WorkflowRequest);
                WorkflowMaster response = workflowMapper.MapVMToWorkflowMaster(workflowVm.WorkflowResponse);

                ResponseBuilder responseBuilder = new ResponseBuilder(response, _ampRepository, userId);
                RequestModifier requestModifier = new RequestModifier(request);

                responseBuilder.BuildApprovalResponse();
                requestModifier.Modify();

                _ampRepository.InsertWorkFlowMaster(responseBuilder.workflow);
                _ampRepository.UpdateWorkFlowMaster(requestModifier.workflow);
                _ampRepository.Save();
            }
            catch (Exception exception)
            {
            }
        }
Пример #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);
            }
        }