Exemple #1
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            int newStateId = _findingStateRepository.GetOneByCode("PDR");
            var finding    = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.FindingStateID = newStateId;

            _findingRepository.Update(finding);

            _findingStatesHistoryRepository.Add(this.FindingID, newStateId, this.ResponsibleUserId);
            //I Need te Emitter User for reassignment, New responsible User and SGC Responsible To send email
            //REASSIGN FINDING
            var result = _reassignmentsFindingHistoryRepository.Add(this.FindingID, this.ReassignedUserID, this.ResponsibleUserId, "Pendiente");

            if (result)
            {
                //Get emails to notify

                //email of request reassignment user
                var email = _userWorkflowRepository.GetUsersEmailResponsibleFinding();
                EmailAddresses.AddRange(email);
                string reasignedUserName = _userWorkflowRepository.GetFullName(this.ReassignedUserID);
                this.EmailSubject = Data.EmailStrings.GetSubjectFinding(finding.FindingTypeName, "generatereassignment");
                this.EmailMessage = Data.EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "generatereassignment", reasignedUserName);
            }
            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            return(ExecutionResult.Next());
        }
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            int newFindingStateId;
            var finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            if (finding.FindingStateID == _findingStateRepository.GetOneByCode("PDR"))
            {
                //ReassignWithApprovalStep
                newFindingStateId = _findingStatesHistoryRepository.GetPreviousState(this.FindingID, finding.FindingStateID);
            }
            else
            {
                //ReassignWithoutApprovalStep
                newFindingStateId = finding.FindingStateID;
            }
            //last responsable user mail
            EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(this.ResponsibleUserId));
            finding.ResponsibleUserID = this.ReassignedUserID;
            finding.FindingStateID    = newFindingStateId;
            finding.PlantTreatmentID  = this.PlantTreatmentID;
            finding.SectorTreatmentID = this.SectorTreatmentID;
            _findingRepository.Update(finding);

            //Left get SGC Responsible user id
            string SGC_RESPONSIBLE_USER_ID = this.ResponsibleUserId;
            var    result = _reassignmentsFindingHistoryRepository.Add(this.FindingID, this.ReassignedUserID, SGC_RESPONSIBLE_USER_ID, "Approve");

            _findingStatesHistoryRepository.Add(this.FindingID, newFindingStateId, SGC_RESPONSIBLE_USER_ID);

            string oldResponsibleUser = finding.ResponsibleUserFullName;

            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            var email = _findingRepository.GetResponsibleUserEmail(this.ReassignedUserID);

            EmailAddresses.Add(email);
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleFinding());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss());
            this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "reassign");
            this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "reassign", oldResponsibleUser);

            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            return(ExecutionResult.Next());
        }
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            var finding  = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);
            var newState = _findingStatesHistoryRepository.GetPreviousState(this.FindingID, finding.FindingStateID);

            finding.RejectComment  = this.RejectComment;
            finding.FindingStateID = newState;
            _findingRepository.Update(finding);

            _reassignmentsFindingHistoryRepository.Add(this.FindingID, this.ReassignedUserID, this.ResponsibleUserId, "Rejected", this.RejectComment);

            var RESPONSIBLE_SGC_USER_ID = this.ResponsibleUserId;

            _findingStatesHistoryRepository.Add(this.FindingID, newState, RESPONSIBLE_SGC_USER_ID);

            EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID));

            this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "rejectreassignment");
            this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "rejectreassignment");
            //Left email of SGC
            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            return(ExecutionResult.Next());
        }
        public ReassignmentsFindingHistoryOutput Execute(int findingID, string reassignedUserId, string createByUserId)
        {
            ReassignmentsFindingHistory reassignmentsFindingHistory = _reassignmentsFindingHistoryRepository.Add(new ReassignmentsFindingHistory(findingID, reassignedUserId, createByUserId, "Pendiente"));

            return(_mapper.Map <ReassignmentsFindingHistory, ReassignmentsFindingHistoryOutput>(reassignmentsFindingHistory));
        }