コード例 #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);
        }
        protected override async Task <Email> ProcessEmail(string workflowTaskId, string projectId, string comments,
                                                           string recipient, string user, string pageUrl)
        {
            Email email;

            if (workflowTaskId == Constants.CloseProjectTaskId.ToString())
            {
                email = new ApproveCloseProjectEmail();
            }
            else if (workflowTaskId == Constants.ArchiveProject.ToString())
            {
                email = new ApproveArchiveProjectEmail();
            }
            else if (workflowTaskId == Constants.ApproveProjectTask.ToString())
            {
                email = new ApproveProjectImplementaionWorkflowEmail();
            }
            else if (workflowTaskId == Constants.PlannedEndDate.ToString())
            {
                email = new ApprovePlannedEndDateEmail();
            }
            else
            {
                email = new ApproveProjectWorkflowEmail();
            }

            await email.SetEmailPeople(_ampRepository, _personService, user, recipient, projectId);

            email.SetSROText();
            email.AMPlink = pageUrl;
            email.Subject = String.Format(email.Subject, projectId, _ampRepository.GetProject(projectId).Title);
            email.Body    = String.Format(email.Body, email.Recipient.Forename, email.Sender.Forename, email.AMPlink, email.sroText);

            return(email);
        }
        protected async override Task <Email> ProcessEmail(string workflowTaskId, string projectId, string comments, string recipient, string user, string pageUrl)
        {
            Email email;

            if (workflowTaskId == Constants.CloseProjectTaskId.ToString())
            {
                email = new RejectCloseProjectEmail();
            }
            else if (workflowTaskId == Constants.ArchiveProject.ToString())
            {
                email = new RejectArchiveProjectEmail();
            }
            else
            {
                email = new RejectProjectWorkflowEmail();
            }

            await email.SetEmailPeople(_ampRepository, _personService, user, recipient, projectId);

            email.SetSROText();
            email.Subject = String.Format(email.Subject, projectId, _ampRepository.GetProject(projectId).Title);
            email.AMPlink = String.Format(email.AMPlink, AMPUtilities.BaseUrl(), projectId, workflowTaskId);
            email.Body    = String.Format(email.Body, email.Recipient.Forename, email.Sender.Forename, email.AMPlink, email.sroText);

            return(email);
        }
コード例 #4
0
        public async Task Construct(WorkflowRequest request, WorkflowResponse response, string userRole)
        {
            string projectStage = _ampRepository.GetProject(request.workflow.ProjectID).Stage;

            SetRequestViewModel(await request.MapWorkflowMasterToWorkflowMasterVm());
            SetResponseViewModel(await response.MapWorkflowMasterToWorkflowMasterVm());
            SetApprovalType(configuration.RequiresDelegatedAuthorityApproval(TaskID));
            SetDocumentRequired(configuration.DocumentRequired(TaskID, projectStage));
            SetTaskDescription(TaskID);
            SetWorkflowDocument();
            SetUserRole(userRole);
        }
        protected override async Task <Email> ProcessEmail(string workflowTaskId, string projectId, string comments,
                                                           string recipient, string user, string pageUrl)
        {
            Email email = new HoDAlertEmail();

            //Get the HoD alert List

            //Decide who gets the e-mail and who is on the cc list.
            await email.SetHoDAlertPeople(_ampRepository, _personService, user, projectId);

            //Get the project approved budget.

            email.SetSROText();
            email.AMPlink = email.AMPlink = String.Format(email.AMPlink, AMPUtilities.BaseUrl(), projectId, workflowTaskId);
            email.Subject = String.Format(email.Subject, projectId, _ampRepository.GetProject(projectId).Title);
            email.Body    = String.Format(email.Body, email.Recipient.Forename, email.Sender.Forename + ' ' + email.Sender.Surname, email.AMPlink, email.sroText);

            return(email);
        }
コード例 #6
0
        protected async override Task <Email> ProcessEmail(string workflowTaskId, string projectId, string comments, string recipient, string user, string pageUrl)
        {
            Email email;

            //switch (workflowTaskId)
            //{
            //    case Constants.WorkflowTaskId.ApproveProject:

            //    default:
            //}

            if (workflowTaskId == Constants.ArchiveProject.ToString())
            {
                email = new RequestArchiveEmail();
            }
            else if (workflowTaskId == Constants.ApproveProjectTask.ToString())
            {
                email = new RequestApprovalEmail();
            }
            else if (workflowTaskId == Constants.ReApproveProjectTaskId.ToString())
            {
                email = new RequestReApprovalEmail();
            }
            else if (workflowTaskId == Constants.PlannedEndDate.ToString())
            {
                email = new RequestPlannedEndDateEmail();
            }
            else if (workflowTaskId == Constants.ApproveAD.ToString())
            {
                email = new RequestAandDApprovalEmail();
            }
            else if (workflowTaskId == Constants.FastTrack.ToString())
            {
                email = new RequestFastTrackApprovalEmail();
            }
            else if (workflowTaskId == Constants.CloseProjectTaskId.ToString())
            {
                email = new RequestCloseProjectEmail();
            }
            else if (workflowTaskId == Constants.CancelWorkflow.ToString())
            {
                email = new RequestCancelEmail();
            }
            else if (workflowTaskId == Constants.ReOpenProject.ToString())
            {
                email = new RequestReOpenProjectEmail();
            }
            else
            {
                return(null);
            }

            await email.SetEmailPeople(_ampRepository, _personService, user, recipient, projectId);

            email.SetSROText();
            email.AMPlink = String.Format(email.AMPlink, AMPUtilities.BaseUrl(), projectId, workflowTaskId);
            email.Subject = String.Format(email.Subject, projectId, _ampRepository.GetProject(projectId).Title);
            email.Body    = String.Format(email.Body, email.Recipient.Forename, email.Sender.Forename, comments, email.AMPlink, email.sroText);

            return(email);
        }
コード例 #7
0
        public async Task <ComponentPartnerVM> Build()
        {
            _componentPartnerVm = new ComponentPartnerVM();

            ComponentMaster componentMaster = _ampRepository.GetComponent(_ComponentID);
            ProjectMaster   projectMaster   = _ampRepository.GetProject(componentMaster.ProjectID);

            //Get the chain from DB
            List <DeliveryChain> deliveryChains = _ampRepository.GetDeliveryChainsByComponent(_ComponentID).OrderBy(x => x.ChainID).ToList();

            //New Delivery Chain list object
            List <DeliveryChainListVM> deliveryChainListVms;

            //Map Chain to VM
            Mapper.CreateMap <DeliveryChain, DeliveryChainListVM>();
            deliveryChainListVms = Mapper.Map <List <DeliveryChain>, List <DeliveryChainListVM> >(deliveryChains);

            //Get Descriptions for all
            List <int>    listOfPartners  = new List <int>();
            List <string> listOfSuppliers = new List <string>();


            foreach (DeliveryChainListVM chain in deliveryChainListVms)
            {
                //Check Parent
                if (chain.ParentType == "P")
                {
                    listOfPartners.Add(Int32.Parse(chain.ParentID));
                }
                if (chain.ParentType == "S")
                {
                    listOfSuppliers.Add(chain.ParentID.ToString());
                }

                //Check Child
                if (chain.ChildType == "P")
                {
                    listOfPartners.Add(Int32.Parse(chain.ChildID));
                }
                if (chain.ChildType == "S")
                {
                    listOfSuppliers.Add(chain.ChildID.ToString());
                }
            }

            //Get List of IDs and Names from PartnerMaster based on list of Partners
            List <PartnerMaster> partnerMasters = _ampRepository.GetDeliveryChainsByIDList(listOfPartners);

            //

            //Get List of IDs and Names from ARIES Suppliers based on list of Suppliers
            IEnumerable <SupplierVM> SupplierVms = await _AriesService.GetSuppliers(listOfSuppliers, "");


            //Map description
            foreach (DeliveryChainListVM chainList in deliveryChainListVms)
            {
                if (chainList.ParentType == "P")
                {
                    foreach (PartnerMaster partners in partnerMasters)
                    {
                        if (Int32.Parse(chainList.ParentID) == partners.PartnerID)
                        {
                            chainList.ParentName = partners.PartnerName;
                        }
                    }
                }
                if (chainList.ParentType == "S")
                {
                    foreach (SupplierVM suppliers in SupplierVms)
                    {
                        if (Int32.Parse(chainList.ParentID) == Int32.Parse(suppliers.SupplierID))
                        {
                            chainList.ParentName = suppliers.SupplierName;
                        }
                    }
                }

                //Check Child
                if (chainList.ChildType == "P")
                {
                    foreach (PartnerMaster partners in partnerMasters)
                    {
                        if (Int32.Parse(chainList.ChildID) == partners.PartnerID)
                        {
                            chainList.ChildName = partners.PartnerName;
                        }
                    }
                }
                if (chainList.ChildType == "S")
                {
                    foreach (SupplierVM suppliers in SupplierVms)
                    {
                        if (Int32.Parse(chainList.ChildID) == Int32.Parse(suppliers.SupplierID))
                        {
                            chainList.ChildName = suppliers.SupplierName;
                        }
                    }
                }
            }

            List <PartnersTier1> tier1Partners = await _AriesService.GetTier1Partners(_ComponentID);

            DeliveryChainsVM deliveryChainsVM = new DeliveryChainsVM();

            //Here we would need to map in all the descriptions. 4 loops? 2 for each ID type and 2 for parent and child.
            //We will need 2 get methods. They will take a list of ID's and return ID's and names, one for partner and one for supplier.
            //Then we can set deliveryChains to the view model.

            deliveryChainsVM.deliveryChains      = deliveryChainListVms;
            _componentPartnerVm.DeliveryChainsVm = deliveryChainsVM;
            _componentPartnerVm.Tier1Partners    = tier1Partners;

            DeliveryChainVM deliveryChainVm = new DeliveryChainVM();

            _componentPartnerVm.DeliveryChainsVm = deliveryChainsVM;

            return(_componentPartnerVm);
        }