Пример #1
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.ExpirationDate    = this.ExpirationDate;
            finding.ContainmentAction = this.ContainmentAction;
            finding.CauseAnalysis     = this.CauseAnalysis;
            finding.Comment           = this.Comment;

            int newStateId = _findingStateRepository.GetOneByCode("ENC");

            //Delete Evidences
            foreach (var deleteEvidence in DeleteEvidencesUrls)
            {
                _findingEvidenceRepository.Delete(finding.FindingID, deleteEvidence);
            }

            //Add Evidences
            foreach (var newEvidence in NewEvidencesUrls)
            {
                _findingEvidenceRepository.Add(finding.FindingID, newEvidence);
            }

            //Add to history if the first time edit
            if (finding.FindingStateID != newStateId)
            {
                _findingStatesHistoryRepository.Add(finding.FindingID, newStateId, finding.ResponsibleUserID);
            }

            finding.FindingStateID = newStateId;
            _findingRepository.Update(finding);
            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            return(ExecutionResult.Next());
        }
Пример #2
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());
        }
Пример #3
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.FinalComment = this.FinalComment;
            if (State == "Finalizado OK")
            {
                finding.FindingStateID = _findingStateRepository.GetOneByCode("FOK");
            }
            else if (State == "Finalizado No OK")
            {
                finding.FindingStateID = _findingStateRepository.GetOneByCode("FNK");
            }
            else if (State == "Cerrado")
            {
                finding.FindingStateID = _findingStateRepository.GetOneByCode("CER");
            }

            _findingRepository.Update(finding);
            _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, finding.ResponsibleUserID);

            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            // responsible
            EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID));
            //User creator
            EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.EmitterUserID));
            // SGC
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            // Boss, colaborator
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB());
            this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "close");
            this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "close");

            _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());
        }
Пример #5
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            if (context.PersistenceData == null && FindingID == 0)
            {
                //NEW FINDING
                FindingWorkflowData finding = new FindingWorkflowData(Description, PlantLocationId, SectorLocationId, PlantTreatmentId, SectorTreatmentId, FindingTypeId, EmitterUserId, ResponsibleUserId);
                finding.WorkflowId     = context.Workflow.Id;
                finding.FindingStateID = _findingStateRepository.GetOneByCode("ESP");

                //Go to DB and save the Finding.
                FindingWorkflowData createdFinding = _findingRepository.Add(finding);

                //Add State to history
                _findingStatesHistoryRepository.Add(createdFinding.FindingID, createdFinding.FindingStateID, createdFinding.EmitterUserID);

                //Add Evidence
                foreach (var evidence in NewEvidencesUrls)
                {
                    _findingEvidenceRepository.Add(createdFinding.FindingID, evidence);
                }

                //Get the email of the Responsible User
                //EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(ResponsibleUserId));
                //GetType the email of the finding responsible
                EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleFinding());

                createdFinding = _findingRepository.GetOneByWorkflowId(createdFinding.WorkflowId);

                this.EmailSubject = EmailStrings.GetSubjectFinding(createdFinding.FindingTypeName, "new");
                this.EmailMessage = EmailStrings.GetMessageFinding(createdFinding, _emailSettings.Url, "new");

                _hub.Clients.All.SendAsync("transferfindingsdata", createdFinding);
                //_hub.Clients.All.SendCoreAsync("transferfindingsdata", createdFinding)
                return(ExecutionResult.Next());
            }
            else
            {
                _findingRepository.setWorkflowID(FindingID, context.Workflow.Id);
                return(ExecutionResult.Next());
            }
        }
Пример #6
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.FinalComment = this.FinalComment;
            int newStateId = _findingStateRepository.GetOneByCode("RCZ");

            finding.FindingStateID = newStateId;
            _findingRepository.Update(finding);

            ////Delete Evidences
            //foreach (var deleteEvidence in DeleteEvidencesUrls)
            //{
            //    _findingEvidenceRepository.Delete(finding.FindingID, deleteEvidence);
            //}

            ////Add Evidences
            //foreach (var newEvidence in NewEvidencesUrls)
            //{
            //    _findingEvidenceRepository.Add(finding.FindingID, newEvidence);
            //}

            //WE NEED GET THE RESPONSIBLESGCUSERID
            var RESPONSIBLESGCUSERID = finding.ResponsibleUserID;

            _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, RESPONSIBLESGCUSERID);

            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            //usuario creador de hallazgo
            EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.EmitterUserID));
            this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "reject");
            this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "reject");

            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            return(ExecutionResult.Next());
        }
Пример #7
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.Description       = this.Description;
            finding.PlantLocationID   = this.PlantLocationID;
            finding.SectorLocationID  = this.SectorLocationID;
            finding.PlantTreatmentID  = this.PlantTreatmentID;
            finding.SectorTreatmentID = this.SectorTreatmentID;
            finding.ResponsibleUserID = this.ResponsibleUserID;
            finding.FindingTypeID     = this.FindingTypeID;
            finding.ExpirationDate    = this.ExpirationDate;



            if (State == "ApproveWithPDCA")
            {
                int newStateId = _findingStateRepository.GetOneByCode("APD");
                finding.FindingStateID = newStateId;
                _findingRepository.Update(finding);
                var correctiveAction = new CorrectiveActionWorkflowData();
                correctiveAction.Description       = finding.Description;
                correctiveAction.PlantLocationID   = finding.PlantLocationID;
                correctiveAction.SectorLocationID  = finding.SectorLocationID;
                correctiveAction.PlantTreatmentID  = finding.PlantTreatmentID;
                correctiveAction.SectorTreatmentID = finding.SectorTreatmentID;
                correctiveAction.ResponsibleUserID = finding.ResponsibleUserID;
                correctiveAction.FindingID         = finding.FindingID;
                correctiveAction.EmitterUserID     = EmitterUserID;
                correctiveAction.ReviewerUserID    = ReviewerUserID;
                correctiveAction.CreationDate      = DateTime.Today;
                correctiveAction.Flow        = "CorrectiveAction";
                correctiveAction.FlowVersion = 1;
                _workflowCore.StartFlow(correctiveAction);
            }
            else if (State == "Approve")
            {
                int newStateId = _findingStateRepository.GetOneByCode("APR");
                finding.FindingStateID = newStateId;
                _findingRepository.Update(finding);
            }

            //Delete Evidences
            foreach (var deleteEvidence in DeleteEvidencesUrls)
            {
                _findingEvidenceRepository.Delete(finding.FindingID, deleteEvidence);
            }

            //Add Evidences
            foreach (var newEvidence in NewEvidencesUrls)
            {
                _findingEvidenceRepository.Add(finding.FindingID, newEvidence);
            }

            //Left obtain Responsible SGC ID
            string IDRESPONSIBLESGC = finding.ResponsibleUserID;

            _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, IDRESPONSIBLESGC);

            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB());
            var email = _findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID);

            EmailAddresses.Add(email);

            this.EmailSubject = Data.EmailStrings.GetSubjectFinding(finding.FindingTypeName, "approve");
            this.EmailMessage = Data.EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "approve");

            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            //Get Responsible User Email.
            return(ExecutionResult.Next());
        }