Example #1
0
        private void SendEmailAuditRescheduling(CorrectiveAction correctiveAction)
        {
            List <string> listMails = new List <string>();

            using (var scope = _serviceProvider.CreateScope())
            {
                var     _ctx                = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;
                var     _emailSender        = scope.ServiceProvider.GetService(typeof(IEmailSender)) as IEmailSender;
                Users   newResponsibleUser  = _ctx.Users.Where(x => x.Id == correctiveAction.ResponsibleUserID).SingleOrDefault();
                Users   lastResponsibleUser = _ctx.Users.Where(x => x.Id == correctiveAction.LastResponsibleUserID).SingleOrDefault();
                Sectors sector              = _ctx.Sectors.Where(x => x.SectorID == correctiveAction.SectorTreatmentID).SingleOrDefault();
                listMails.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID)));
                listMails.Add(newResponsibleUser.Email);
                listMails.Add(lastResponsibleUser.Email);
                string newResponsibleName  = newResponsibleUser.FirstName + " " + newResponsibleUser.Surname;
                string lastResponsibleName = lastResponsibleUser.FirstName + " " + lastResponsibleUser.Surname;
                string description         = correctiveAction.Description;
                string sectorName          = sector.Name;
                string estado             = correctiveAction.CorrectiveActionState.Name;
                int    correctiveActionID = correctiveAction.CorrectiveActionID;
                _emailSender.SendEmailAsync(listMails.ToArray(), new string[0], new string[0], $"HoshinCloud – Reasignación de Acción Correctiva",
                                            SetMessageEmail(newResponsibleName,
                                                            lastResponsibleName,
                                                            description,
                                                            sectorName,
                                                            estado,
                                                            correctiveActionID), true, System.Net.Mail.MailPriority.High);
            }
        }
//        internal void sendOrganizationalMessage(CorrectiveAction ca, NtfNotificationevent ne, QmsWorkitemcomment comment)

        internal void sendOrganizationalMessage(CorrectiveAction ca, NtfNotificationevent ne, QmsWorkitemcomment comment)
        {
            List<SecUser> users = getReviewersInOrg(ca.AssignedToOrgId.Value);
            string[] emails = new string[users.Count];
            NtfNotification notification = new NtfNotification();
            notification.CreatedAt = DateTime.Now;
            notification.Title = string.Format(ne.TitleTemplate,ca.Id);
            notification.Message = formatMessage(ca,comment);
            notification.HasBeenRead = 0;
            notification.WorkitemId = ca.Id;
            notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest;
            notification.SendAsEmail = 1;
            notification.NotificationEventId = ne.NotificationEventId;

            int i = 0;
            foreach(var user in users)
            {
                NtfNotification newNotification = notification.Clone();
                newNotification.UserId = user.UserId;
                context.Add(newNotification);
                emails[i] = user.EmailAddress;
                i++;                
            }
            send(emails,notification.Title,notification.Message);
            context.SaveChanges();            
        }
Example #3
0
        public static CorrectiveAction MapToUIModelOnCreate(CorrectiveActionFormViewModel vm, string[] selectedErrorTypes)
        {
            var logSnippet = "[CorrectiveActionUtil][MapToUIModelOnCreate] => ";

            CorrectiveAction newCorrectiveAction = new CorrectiveAction
            {
                Id = vm.CorrectiveActionId,
                ActionRequestTypeId = Int32.Parse(vm.ActionRequestTypeId),
                EmplId             = CorrectiveActionUtil.ExtractEmplId(vm.EmployeeSearchResult),
                Employee           = null,  // CorrectiveActionService will hydrate this object
                NOACode            = vm.NatureOfAction,
                NatureOfAction     = new ReferenceService().RetrieveNatureOfAction(vm.NatureOfAction),
                EffectiveDateOfPar = (DateTime)vm.EffectiveDateOfPar,
                IsPaymentMismatch  = vm.IsPaymentMismatch,
                Details            = vm.Details,
                ActionId           = Int32.Parse(vm.StatusTypeId)
            };

            Console.WriteLine(logSnippet + $"(vm.CorrectiveActionId): '{vm.CorrectiveActionId}' / (vm.NatureOfAction): '{vm.NatureOfAction}'");
            Console.WriteLine(logSnippet + "(newCorrectiveAction.NatureOfAction == null): " + (newCorrectiveAction.NatureOfAction == null));
            if (newCorrectiveAction.NatureOfAction != null)
            {
                Console.WriteLine(logSnippet + $"(newCorrectiveAction.NatureOfAction.NoaCode): '{newCorrectiveAction.NatureOfAction.NoaCode}' / (newCorrectiveAction.NatureOfAction.RoutesToBr): '{newCorrectiveAction.NatureOfAction.RoutesToBr}'");
            }

            ErrorTypeDictionary errorTypeDict = new ErrorTypeDictionary();

            foreach (var errorTypeId in selectedErrorTypes)
            {
                newCorrectiveAction.ErrorTypes.Add(errorTypeDict.GetErrorType(Int32.Parse(errorTypeId)));
            }

            return(newCorrectiveAction);
        }
Example #4
0
//        internal int createCorrectiveAction(EhriError ehriError, User submittedBy)
        private void createCorrectiveAction(User submittedBy)
        {
            //create corrective action
            CorrectiveAction correctiveAction = new CorrectiveAction();
            correctiveAction.EmplId = entity.EmplId;
            correctiveAction.Employee = entity.Employee;          
            correctiveAction.NOACode = "000";
            correctiveAction.NatureOfAction = referenceService.RetrieveNatureOfAction("000");
            correctiveAction.Details = entity.Details;
            correctiveAction.EffectiveDateOfPar = DateTime.Now;
            correctiveAction.ParEffectiveDate = null;
            correctiveAction.IsPaymentMismatch=false;
            correctiveAction.ErrorTypes = new System.Collections.Generic.List<ErrorType>();
            correctiveAction.ActionId = 37;  //37 Save As Draft
            correctiveAction.CreatedAtOrgId = submittedBy.OrgId.Value;
            correctiveAction.CreatedByUserId = submittedBy.UserId;
            correctiveAction.ActionRequestTypeId = 1;
            correctiveAction.RowVersion = 1;
            int caId = correctiveActionService.Save(correctiveAction,submittedBy);

            //create corrective action history item to denote it came from an EHRI error
            correctiveAction.Id = caId;
            string message = string.Format("Corrective Action Created from EHRI Error {0} by {1},<br/><br/>Details:<br/>{2}",entity.Id,submittedBy.DisplayName,entity.QmsErrorMessageText);
            correctiveActionService.addHistory(correctiveAction,submittedBy,message);

            //close out ehri error
            entity.CorrectiveActionId = caId;
            entity.ResolvedAt = DateTime.Now;
        }
Example #5
0
        public static string ToJson(this CorrectiveAction ca)
        {
            StringBuilder sb = new StringBuilder("CorrectiveAction = {");

            sb.Append("Id: ");
            sb.Append(ca.Id);
            sb.Append(", AssignedToUserId: ");
            sb.Append(ca.AssignedToUserId);
            sb.Append(", ActionRequestTypeId: ");
            sb.Append(ca.ActionRequestTypeId);
            sb.Append(", EmplId: ");
            sb.Append(ca.EmplId);
            sb.Append(", NOACode: ");
            sb.Append(ca.NOACode);

            sb.Append(", (NatureOfAction == null): ");
            sb.Append(ca.NatureOfAction == null);

            if (ca.NatureOfAction != null)
            {
                sb.Append(", NatureOfAction.RoutesToBr: ");
                sb.Append(ca.NatureOfAction.RoutesToBr);
            }

            sb.Append(", EffectiveDateOfPar: ");
            sb.Append(ca.EffectiveDateOfPar);
            sb.Append(", IsPaymentMismatch: ");
            sb.Append(ca.IsPaymentMismatch);
            sb.Append(", StatusId: ");
            sb.Append(ca.StatusId);
            sb.Append(", ActionId: ");
            sb.Append(ca.ActionId);

            sb.Append(", ErrorTypes = [");
            if (ca.ErrorTypes != null)
            {
                int count = 0;
                foreach (var errorType in ca.ErrorTypes)
                {
                    if (count > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append("ErrorType: {");
                    sb.Append(" errorType.Id: ");
                    sb.Append(errorType.Id);
                    sb.Append(", errorType.RoutesToBR: ");
                    sb.Append(errorType.RoutesToBR);
                    sb.Append(", errorType.Description: ");
                    sb.Append(errorType.Description);
                    sb.Append("}");
                }
            }
            sb.Append("]");
            sb.Append("}");
            return(sb.ToString());
        }
Example #6
0
        public static CorrectiveActionFormViewModel MapToViewModel(CorrectiveAction entity, int userId, string useCase, List <ModuleMenuItem> moduleMenuItems, bool userCanAssign = false)
        {
            string logSnippet = "[CorrectiveActionUtil][MapToViewModel] => ";

            Console.WriteLine(logSnippet + $"(userId).................................: '{userId}'");
            Console.WriteLine(logSnippet + $"(useCase)................................: '{useCase}'");
            Console.WriteLine(logSnippet + $"(entity.IsReadOnly)......................: {entity.IsReadOnly}");
            Console.WriteLine(logSnippet + $"(userCanAssign)..........................: {userCanAssign}");
            Console.WriteLine(logSnippet + $"(CorrectiveAction.CreatedByUser == null).: {entity.CreatedByUser == null}");
            Console.WriteLine(logSnippet + $"(CorrectiveAction.CreatedByOrg == null)..: {entity.CreatedByOrg == null}");
            Console.WriteLine(logSnippet + $"(CorrectiveAction.AssignedToUser == null): {entity.AssignedToUser == null}");
            Console.WriteLine(logSnippet + $"(CorrectiveAction.AssignedToOrg == null).: {entity.AssignedToOrg == null}");

            CorrectiveActionFormViewModel viewModel = new CorrectiveActionFormViewModel {
                UserId             = userId,
                CorrectiveActionId = entity.Id,
                CorrectiveActionIdForAddComment = entity.Id,
                EmployeeSearchResult            = entity.Employee.SearchResultValue,
                NatureOfAction        = entity.NOACode,
                EffectiveDateOfPar    = entity.EffectiveDateOfPar,
                IsPaymentMismatch     = entity.IsPaymentMismatch,
                ActionRequestTypeId   = entity.ActionRequestTypeId.ToString(),
                Details               = entity.Details,
                CanAssign             = userCanAssign && entity.IsAssignable,
                Comments              = entity.Comments,
                Histories             = entity.Histories,
                StatusLabel           = entity.Status.StatusLabel,
                DateSubmitted         = entity.CreatedAt.ToString("MMMM dd, yyyy"),
                CreatedByUserName     = entity.CreatedByUser.DisplayName,
                CreatedByOrgLabel     = entity.CreatedByOrg.OrgLabel,
                AssignedToUserName    = (entity.AssignedToUser == null) ? "Unassigned" : entity.AssignedToUser.DisplayName,
                AssignedToOrgLabel    = (entity.AssignedToOrg == null)  ? "Unassigned" : entity.AssignedToOrg.OrgLabel,
                RowVersion            = entity.RowVersion,
                PersonnelOfficeIDDesc = entity.Employee.PersonnelOfficeIdentifierDescription,
                IsReadOnly            = entity.IsReadOnly,
                UseCase               = useCase,
                Controller            = MenuUtil.FindControllerForUseCase(useCase, moduleMenuItems)
            };

            if (String.IsNullOrEmpty(viewModel.Details) ||
                String.IsNullOrWhiteSpace(viewModel.Details))
            {
                viewModel.Details = "None provided";
            }

            if (entity.StatusId != null && entity.StatusId.HasValue)
            {
                viewModel.CurrentStatusId = (int)entity.StatusId;
            }

            Console.WriteLine(logSnippet + "BEGIN: CorrectiveActionFormViewModel.ToString()");
            Console.WriteLine(viewModel);
            Console.WriteLine(logSnippet + "END: CorrectiveActionFormViewModel.ToString()");

            return(viewModel);
        }
Example #7
0
 public void Delete(CorrectiveAction correctiveAction)
 {
     using (var scope = _serviceProvider.CreateScope())
     {
         var _ctx          = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;
         var entity        = _ctx.CorrectiveActions.Where(x => x.CorrectiveActionID == correctiveAction.CorrectiveActionID).FirstOrDefault();
         var historyStates = _ctx.CorrectiveActionStatesHistory.Where(x => x.CorrectiveActionID == correctiveAction.CorrectiveActionID);
         _ctx.CorrectiveActionStatesHistory.RemoveRange(historyStates);
         _ctx.Remove(entity);
         _ctx.SaveChanges();
     }
 }
Example #8
0
        /// <summary>
        /// Получает список воздушных судов из запроса
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public static CorrectiveActionCollection GetCorrectiveActionCollection(DataTable table)
        {
            CorrectiveActionCollection items = new CorrectiveActionCollection();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                CorrectiveAction item = new CorrectiveAction();
                Fill(table.Rows[i], item);
                items.Add(item);
            }

            return(items);
        }
Example #9
0
        /// <summary>
        /// Удаляет информацию об заданном агрегате
        /// </summary>
        /// <param name="index"></param>
        public bool Contains(CorrectiveAction ContainedAction)
        {
            int i;

            for (i = 0; i < _Actions.Count; i++)
            {
                if (_Actions[i] == ContainedAction)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #10
0
        public static string[] ExtractErrorTypeIds(CorrectiveAction entity)
        {
            List <string> errorTypeIdList = new List <string>();

            if (entity != null && entity.ErrorTypes != null)
            {
                foreach (var errorType in entity.ErrorTypes)
                {
                    errorTypeIdList.Add(errorType.Id.ToString());
                }
            }

            return(errorTypeIdList.ToArray());
        }
Example #11
0
 /// <summary>
 /// Заполняет поля
 /// </summary>
 /// <param name="row"></param>
 /// <param name="item"></param>
 public static void Fill(DataRow row, CorrectiveAction item)
 {
     item.ItemId           = DbTypes.ToInt32(row["CorrectiveActionItemID"]);
     item.IsDeleted        = DbTypes.ToBool(row["CorrectiveActionIsDeleted"]);
     item.DiscrepancyId    = DbTypes.ToInt32(row["CorrectiveActionDiscrepancyID"]);
     item.Description      = DbTypes.ToString(row["CorrectiveActionDescription"]);
     item.ShortDescription = DbTypes.ToString(row["CorrectiveActionShortDescription"]);
     item.AddNo            = DbTypes.ToString(row["CorrectiveActionADDNo"]);
     item.IsClosed         = DbTypes.ToBool(row["CorrectiveActionIsClosed"]);
     item.PartNumberOff    = DbTypes.ToString(row["CorrectiveActionPartNumberOff"]);
     item.SerialNumberOff  = DbTypes.ToString(row["CorrectiveActionSerialNumberOff"]);
     item.PartNumberOn     = DbTypes.ToString(row["CorrectiveActionPartNumberOn"]);
     item.SerialNumberOn   = DbTypes.ToString(row["CorrectiveActionSerialNumberOn"]);
     item.CRSID            = DbTypes.ToInt32(row["CorrectiveActionCRSID"]);
 }
Example #12
0
        public CorrectiveAction Update(CorrectiveAction updateCorrectiveAction)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                var correctiveAction = _mapper.Map <CorrectiveAction, CorrectiveActions>(updateCorrectiveAction);

                _ctx.Entry(correctiveAction).State = EntityState.Modified;
                _ctx.SaveChanges();

                return(_mapper.Map <CorrectiveActions, CorrectiveAction>(correctiveAction));
            }
        }
Example #13
0
        public CorrectiveAction Add(CorrectiveAction correctiveAction)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                CorrectiveActions newCorrectiveAction = _mapper.Map <CorrectiveAction, CorrectiveActions>(correctiveAction);

                _ctx.CorrectiveActions.Add(newCorrectiveAction);
                _ctx.SaveChanges();

                return(_mapper.Map <CorrectiveActions, CorrectiveAction>(newCorrectiveAction));
            }
        }
Example #14
0
        /// <summary>
        /// Удаляет информацию об заданном агрегате
        /// </summary>
        /// <param name="index"></param>
        public void Remove(CorrectiveAction RemovedAction)
        {
            int i;

            //CorrectiveAction action = null;
            for (i = 0; i < _Actions.Count; i++)
            {
                if (_Actions[i] == RemovedAction)
                {
                    _Actions.RemoveAt(i);
                    break;
                }
            }
            //_Actions.RemoveAt(i);
            //    OnCollectionChange();
        }
//        internal void sendIndividualMessage(CorrectiveAction ca, NtfNotificationevent ne, User submitter, QmsWorkitemcomment comment)

        internal void sendIndividualMessage(CorrectiveAction ca, NtfNotificationevent ne, User submitter, QmsWorkitemcomment comment)
        {
            if(submitter.UserId != ca.CreatedByUserId.Value) // if the person doing the action is the originator they don't get a message since they did the action
            {
                SecUser user;                
                NtfNotification notification = new NtfNotification();
                notification.CreatedAt = DateTime.Now;
                notification.HasBeenRead = 0;
                notification.Title = string.Format(ne.TitleTemplate,ca.Id);
                notification.WorkitemId = ca.Id;
                notification.WorkItemTypeCode = WorkItemTypeEnum.CorrectiveActionRequest;
                notification.SendAsEmail = 1;
                notification.NotificationEventId = ne.NotificationEventId;
                notification.Message = formatMessage(ca,comment);
                switch(ne.NotificationEventCode)
                {
                    case CorrectiveActionNotificationType.CA_Assigned:
                        notification.UserId = ca.AssignedToUserId.Value;
//                        notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.AssignedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName);
                        break;
                    case CorrectiveActionNotificationType.CA_Created:
                        notification.UserId = ca.CreatedByUserId.Value;
//                        notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.CreatedAt.ToShortDateString(),ca.EmplId,ca.Employee.FullName);
                        break;
                    case CorrectiveActionNotificationType.CA_Returned:
                        notification.UserId = ca.CreatedByUserId.Value;
//                        notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.UpdatedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName);
                        break;
                    case CorrectiveActionNotificationType.CA_Closed:
                        notification.UserId = ca.CreatedByUserId.Value;
//                        notification.Message = string.Format(ne.MessageTemplate,ca.Id, ca.ResolvedAt.Value.ToShortDateString(),ca.EmplId,ca.Employee.FullName);
                        break;                    
                    case CorrectiveActionNotificationType.CA_Withdrawn:
                        notification.UserId = ca.AssignedToUserId.Value;
//                        notification.Message = string.Format(ne.MessageTemplate,ca.Id,  ca.UpdatedAt.Value.ToShortDateString(), ca.EmplId, ca.Employee.FullName);
                        break;
                    default:
                        //not a indivual message type
                        break;
                }
                user = userRepository.RetrieveByUserId(notification.UserId);
                send(user.EmailAddress,notification.Title,notification.Message);

                context.Add(notification);
                context.SaveChanges();
            }
        }
//        internal string formatMessage(CorrectiveAction ca, QmsWorkitemcomment comment)
        internal string formatMessage(CorrectiveAction ca, QmsWorkitemcomment comment)
        {
            template = "Corrective Acton ID: {0}<br/>Employee: {1}-{2}<br/>Request Type: {3}<br/>NOA: {4}<br/>Effective Date: {5}<br/>Updated on: {6}<br/>Correction Requested:{7}<br/>";
            string dateToUse = ca.UpdatedAt.HasValue ? ca.UpdatedAt.Value.ToShortDateString() : ca.CreatedAt.ToShortDateString();
            message = string.Format(template,ca.Id,ca.EmplId, ca.Employee.FullName, getActionRequestType(ca.ActionRequestTypeId.Value) ,ca.NOACode,ca.EffectiveDateOfPar,dateToUse,ca.Details);
            string commentTemplate = "Latest Comment:{0}<br/> by {1} on {2}";
            if(comment != null)
            {
                string commentText = string.Format(commentTemplate,comment.Message,comment.Author.DisplayName,comment.CreatedAt.ToShortDateString());
                message += commentText;
            }
            else
            {
                message += "No comments have been made.";
            }
            message += "<br/><br/>" + string.Format(footerTemplate,ca.Id);
            return message;
        }
Example #17
0
        /// <summary>
        /// Возвращает список параметров, которые могут использоваться в запросах
        /// </summary>
        public static SqlParameter[] GetParameters(CorrectiveAction item)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@ItemID", DbTypes.DbObject(item.ItemId)));
            parameters.Add(new SqlParameter("@IsDeleted", DbTypes.DbObject(item.IsDeleted)));
            parameters.Add(new SqlParameter("@DiscrepancyID", DbTypes.DbObject(item.DiscrepancyId)));
            parameters.Add(new SqlParameter("@Description", DbTypes.DbObject(item.Description)));
            parameters.Add(new SqlParameter("@ShortDescription", DbTypes.DbObject(item.ShortDescription)));
            parameters.Add(new SqlParameter("@ADDNo", DbTypes.DbObject(item.AddNo)));
            parameters.Add(new SqlParameter("@IsClosed", DbTypes.DbObject(item.IsClosed)));
            parameters.Add(new SqlParameter("@PartNumberOff", DbTypes.DbObject(item.PartNumberOff)));
            parameters.Add(new SqlParameter("@SerialNumberOff", DbTypes.DbObject(item.SerialNumberOff)));
            parameters.Add(new SqlParameter("@PartNumberOn", DbTypes.DbObject(item.PartNumberOn)));
            parameters.Add(new SqlParameter("@SerialNumberOn", DbTypes.DbObject(item.SerialNumberOn)));
            parameters.Add(new SqlParameter("@CRSID", DbTypes.DbObject(item.CRSID)));


            return(parameters.ToArray());
        }
 public void Send(CorrectiveAction correctiveAction,string notificationEventCode, User submitter)
 {
     EmployeeService employeeService = new EmployeeService();
     correctiveAction.Employee = employeeService.RetrieveById(correctiveAction.EmplId);
     notificationEvent = notificationRepository.RetrieveNotificationEventByCode(notificationEventCode);
     originator = userRepository.RetrieveByUserId(correctiveAction.CreatedByUserId.Value);
     bool willSendtoSubmitter = ((originator.UserId == submitter.UserId) && (notificationEvent.NotificationEventType.NotificationEventTypeCode == NotificationEventType.INDIV));
     if(!willSendtoSubmitter)
     {
         notificationEventType = notificationEvent.NotificationEventType;
         QmsWorkitemcomment comment = correctiveActionRepository.RetrieveLatestComment(correctiveAction.Id);
         switch(notificationEventType.NotificationEventTypeCode)
         {
             case NotificationEventType.INDIV:
                 sendIndividualMessage(correctiveAction,notificationEvent, submitter,comment);
                 break;
             case NotificationEventType.ORG:
                 sendOrganizationalMessage(correctiveAction,notificationEvent,comment);
                 break;
             default:
                 break;
         }
     }
 } 
Example #19
0
 /// <summary>
 /// Добавляет информацию об агрегате в коллекцию
 /// </summary>
 public void Add(CorrectiveAction Action)
 {
     _Actions.Add(Action);
     //    oilCondition.DataChange += ComponentOilConditionCollection_DataChange;
     //    OnCollectionChange();
 }
 public static string GetCorrectiveActionDescription(CorrectiveAction action)
 {
     switch (action)
     {
         case CorrectiveAction.CreateCCChannel:
             return "Create CableCARD™ channel matching this channel map entry";
         case CorrectiveAction.CreateMergedCCAndQAMChannels:
             return "Create both CableCARD™ and QAM channels matching this channel map entry, and merge them.";
         case CorrectiveAction.CreateQAMAndMerge:
             return "Create QAM channel and merge it with the existing CableCARD™ channel.";
         case CorrectiveAction.CreateQAMWithoutMerge:
             return "Create ClearQAM channel, but don't merge it with the existing CableCARD™ channel.";
         case CorrectiveAction.CreateUnmergedCCAndQAMChannels:
             return "Create CableCARD™ and ClearQAM channels matching this channel map entry, but don't merge them";
         case CorrectiveAction.MergeCCChannelToQAMWithNumberUpdate:
             return "Create CableCARD™ channel and merge it to the existing QAM channel matching this channel map entry, updating the number in the guide to match the CableCARD™ channel number";
         case CorrectiveAction.MergeQAM:
             return "Merge Existing ClearQAM channel with this CableCARD™ channel";
         case CorrectiveAction.RemoveBogusCCChannel:
             return "Remove CableCARD sources incorrectly using EIA (QAM) channel number";
         case CorrectiveAction.RemoveIncorrectQAM:
             return "Remove merged ClearQAM channel with incorrect EIA number";
         case CorrectiveAction.RemoveOtherCCChannel:
             return "Remove the other CableCARD channel merged with this one that doesn't have the same EIA number in the channel map.";
         case CorrectiveAction.RemoveThisCCChannel:
             return "Remove this CableCARD channel, leaving the one that is merged with it which doesn't have the same EIA number in the channel map";
         case CorrectiveAction.ReplaceIncorrectQAM:
             return "Replace merged ClearQAM channel with incorrect EIA numbers with corrected one";
         default:
             return action.ToString();
     }
 }
 public void UpdateStatus()
 {
     merged_channels_ = null;
     listings_ = null;
     QAMChannelStatus old_status = qam_status_;
     qam_status_ = DetermineQAMChannelStatus(channel_map_entry_, out exists_as_ota_);
     if (qam_status_ != old_status)
     {
         CorrectiveAction old_corrective_action = selected_action_;
         selected_action_ = CorrectiveAction.None;
         NotifyStatusChanged(new StatusChangedEventArgs(old_corrective_action, old_status, qam_status_));
     }
 }
 private ChannelMapEntryWrapper(ChannelMapEntry entry)
 {
     channel_map_entry_ = entry;
     qam_status_ = DetermineQAMChannelStatus(entry, out exists_as_ota_);
     selected_action_ = CorrectiveAction.None;
 }
Example #23
0
        internal int ExecuteUpdates(CorrectiveAction correctiveAction, User submittedBy, string history)
        {
            submitter   = submittedBy;
            this.entity = correctiveAction;
            int retval = entity.Id;

            isNewTicket = retval == 0;
            routesToRBC = determineIfTicketRoutesToRBC(); // if submitted by PPRM this would need to be skipped
            StatusTransition action         = referenceRepository.RetrieveOrgStatusTranstion(correctiveAction.ActionId);
            string           actionToStatus = action.ToStatus.StatusCode;

            this.entity.StatusId = action.ToStatus.StatusId;
            if (isNewTicket)
            {
                this.entity.CreatedAt       = DateTime.Now;
                this.entity.CreatedByUserId = submitter.UserId;
                this.entity.CreatedAtOrgId  = submitter.OrgId.Value;
                this.entity.AssignedToOrgId = submitter.OrgId.Value;
                QmsCorrectiveactionrequest initialCar = correctiveAction.QmsCorrectiveActionRequest;
                correctiveActionRepository.context.Add(initialCar);
                correctiveActionRepository.context.SaveChanges();
                retval         = initialCar.Id;
                this.entity.Id = initialCar.Id;
            }
            else
            {
                this.entity.UpdatedAt = DateTime.Now;
            }



            if (actionToStatus == StatusType.UNASSIGNED)
            {
                ActionDescription = string.Format("{0} submitted Corrective Action for resolution<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Submitted;
                SubmitForResolution();
            }
            else if (actionToStatus == StatusType.ASSIGNED)
            {
                ActionDescription = string.Format("{0} assigned Corrective Action<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Assigned;
                AssignToUser(entity);
            }
            else if (actionToStatus == StatusType.CLOSED)
            {
                ActionDescription = string.Format("{0} closed Corrective Action<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Closed;
                Close(entity);
            }
            else if (actionToStatus == StatusType.CLOSED_ACTION_COMPLETED)
            {
                ActionDescription = string.Format("{0} completed Corrective Action<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Closed;
                CloseActionCompleted(entity);
            }
            else if (actionToStatus == StatusType.DRAFT)
            {
                if (isNewTicket)
                {
                    ActionDescription = string.Format("{0} created Corrective Action", submitter.DisplayName);
                    correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                    NotificationEventType = CorrectiveActionNotificationType.CA_Created;
                    SaveAsDraft(entity);
                }
                else
                {
                    ActionDescription = string.Format("{0} withdrew Corrective Action<br/>{1}", submitter.DisplayName, history);
                    correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                    NotificationEventType = CorrectiveActionNotificationType.CA_Withdrawn;
                    WithdrawItem(entity);
                }
            }
            else if (actionToStatus == StatusType.PENDING_REVIEW)
            {
                ActionDescription = string.Format("{0} submitted Corrective Action for review<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_PendingReview;
                SubmitForReview(entity);
            }
            else if (actionToStatus == StatusType.RETURNED)
            {
                ActionDescription = string.Format("{0} returned Corrective Action to originator<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Returned;
                Return(entity);
            }
            else if (actionToStatus == StatusType.REROUTED)
            {
                ActionDescription = string.Format("{0} rerouted Corrective Action<br/>{1}", submitter.DisplayName, history);
                correctiveActionService.addHistory(this.entity, submitter, ActionDescription);
                NotificationEventType = CorrectiveActionNotificationType.CA_Rerouted;

                Reroute(entity);
            }
            else
            {
                throw new InvalidStatusTypeException(actionToStatus + " is not a valid StatusType.");
            }
            QmsCorrectiveactionrequest car = this.entity.QmsCorrectiveActionRequest;

            correctiveActionRepository.Update(car);
            saveErrors(this.entity.ErrorTypes, retval, isNewTicket);
            correctiveActionRepository.context.SaveChanges();

            return(retval);
        }
Example #24
0
 public void Update(CorrectiveAction entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     base.Update(entity);
     _unitOfWork.Save();
 }
Example #25
0
        public static CorrectiveAction MapToUIModelOnUpdate(CorrectiveActionFormViewModel vm, string[] selectedErrorTypes, CorrectiveAction existingCA)
        {
            var logSnippet = "[CorrectiveActionUtil][MapToUIModelOnUpdate] => ";

            Console.WriteLine(logSnippet + $"(vm.Details): '{vm.Details}'");


            existingCA.EmplId              = CorrectiveActionUtil.ExtractEmplId(vm.EmployeeSearchResult);
            existingCA.Employee            = null; // CorrectiveActionService will hydrate this object
            existingCA.NOACode             = vm.NatureOfAction;
            existingCA.NatureOfAction      = new ReferenceService().RetrieveNatureOfAction(vm.NatureOfAction);
            existingCA.EffectiveDateOfPar  = (DateTime)vm.EffectiveDateOfPar;
            existingCA.IsPaymentMismatch   = vm.IsPaymentMismatch;
            existingCA.ActionId            = Int32.Parse(vm.StatusTypeId);
            existingCA.RowVersion          = vm.RowVersion;
            existingCA.ActionRequestTypeId = int.Parse(vm.ActionRequestTypeId);
            existingCA.Details             = vm.Details;

            if (vm.AssignedToUserId.HasValue)
            {
                existingCA.AssignedToUserId = vm.AssignedToUserId;
            }

            Console.WriteLine(logSnippet + $"(existingCA.Id): '{existingCA.Id}' / (existingCA.NatureOfAction): '{existingCA.NatureOfAction}'");
            Console.WriteLine(logSnippet + "(existingCA.NatureOfAction == null): " + (existingCA.NatureOfAction == null));
            if (existingCA.NatureOfAction != null)
            {
                Console.WriteLine(logSnippet + $"(existingCA.NatureOfAction.NoaCode): '{existingCA.NatureOfAction.NoaCode}' / (existingCA.NatureOfAction.RoutesToBr): '{existingCA.NatureOfAction.RoutesToBr}'");
            }

            ErrorTypeDictionary errorTypeDict = new ErrorTypeDictionary();

            existingCA.ErrorTypes = new List <ErrorType>();
            foreach (var errorTypeId in selectedErrorTypes)
            {
                existingCA.ErrorTypes.Add(errorTypeDict.GetErrorType(Int32.Parse(errorTypeId)));
            }

            return(existingCA);
        }
        // [Authorize(Roles = "SC_SPECIALIST,SC_REVIEWER,PPRB_SPECIALIST,PPRB_REVIEWER")]
        public IActionResult Create
        (
            [Bind("EmployeeSearchResult, NatureOfAction,EffectiveDateOfPar,IsPaymentMismatch,ErrorTypeIds,ActionRequestTypeId,StatusTypeId,Details")]
            CorrectiveActionFormViewModel correctiveActionVM, string[] selectedErrorTypes
        )
        {
            if (HttpContext == null ||
                HttpContext.Session == null ||
                HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY) == null)
            {
                return(RedirectToAction("Warning", "Home"));
            }

            string logSnippet = new StringBuilder("[")
                                .Append(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"))
                                .Append("][CorrectiveActionsController][HttpPost][Create] => ")
                                .ToString();

            UserViewModel qmsUserVM = HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY);

            Console.WriteLine(logSnippet + $"(qmsUserVM): {qmsUserVM}");

            if (qmsUserVM.CanCreateCorrectiveAction == false)
            {
                return(RedirectToAction("UnauthorizedAccess", "Home"));
            }

            ///////////////////////////////////////////////////////////////////////////////////
            // Error Categories Validation
            ///////////////////////////////////////////////////////////////////////////////////
            if (selectedErrorTypes == null || selectedErrorTypes.Count() == 0)
            {
                Console.WriteLine(logSnippet + "No error categories/types selected. Adding a model error.");
                ModelState.AddModelError(string.Empty, "Please select at least one error category.");
            }

            ///////////////////////////////////////////////////////////////////////////////////
            // Employee Search
            ///////////////////////////////////////////////////////////////////////////////////
            string emplIdStr = CorrectiveActionUtil.ExtractEmplId(correctiveActionVM.EmployeeSearchResult);
            long   emplIdLong;

            if (String.IsNullOrEmpty(emplIdStr) == false &&
                long.TryParse(emplIdStr, out emplIdLong) == true)
            {
                try
                {
                    Employee employee = _employeeService.RetrieveById(emplIdStr);
                }
                catch (EmployeeNotFoundException enfe)
                {
                    Console.WriteLine(logSnippet + "EmployeeNotFoundException encountered:");
                    Console.WriteLine(enfe.Message);
                    ModelState.AddModelError(string.Empty, $"Employee not found with Employee ID of '{emplIdStr}'");
                }
            }

            Console.WriteLine(logSnippet + $"(ModelState.IsValid): {ModelState.IsValid}");

            if (ModelState.IsValid)
            {
                CorrectiveAction correctiveActionModel = CorrectiveActionUtil.MapToUIModelOnCreate(correctiveActionVM, selectedErrorTypes);
                User             qmsUser = _userService.RetrieveByEmailAddress(qmsUserVM.EmailAddress);

                Console.WriteLine(logSnippet + "CorrectiveAction (BEFORE SAVE) => BEGIN");
                Console.WriteLine(correctiveActionModel.ToJson());
                Console.WriteLine(logSnippet + "END <= CorrectiveAction (BEFORE SAVE)");

                int entityId = _correctiveActionService.Save(correctiveActionModel, qmsUser);

                Console.WriteLine(logSnippet
                                  + $"Newly created CorrectiveAction #{entityId} has been saved to the database, redirecting in Home Index page");

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // PREPARE SUCCESS MESSAGE
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                string msgKey = Guid.NewGuid().ToString();
                string msgVal = $"Corrective Action with an ID of {entityId} has been created for {correctiveActionVM.EmployeeSearchResult}";
                HttpContext.Session.SetObject(msgKey, msgVal);

                return(RedirectToAction("Index", "Home", new { @mk = msgKey }));
            }
            else
            {
                Console.WriteLine(logSnippet + "ModelState IS NOT VALID, returning User to Create Corrective Actions page");
                if (selectedErrorTypes != null || selectedErrorTypes.Count() > 0)
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////
                    // The HttpContext.Items collection is used to store data while processing a single request.
                    // The collection's contents are discarded after a request is processed.
                    /////////////////////////////////////////////////////////////////////////////////////////////
                    HttpContext.Items[CorrectiveActionsConstants.SELECTED_ERROR_TYPES_KEY] = selectedErrorTypes;
                }

                return(View());
            }
        }
        // [Authorize(Roles = "SC_SPECIALIST,SC_REVIEWER,PPRB_SPECIALIST,PPRB_REVIEWER,PPRM_SPECIALIST,PPRM_REVIEWER")]
        public IActionResult Edit(int?id, string useCase, string mk = null)
        {
            if (HttpContext == null ||
                HttpContext.Session == null ||
                HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY) == null)
            {
                return(RedirectToAction("Warning", "Home"));
            }

            string logSnippet = new StringBuilder("[")
                                .Append(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"))
                                .Append("][CorrectiveActionsController][HttpGet][Edit] => ")
                                .ToString();

            UserViewModel qmsUserVM = HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY);

            Console.WriteLine(logSnippet + $"(qmsUserVM): {qmsUserVM}");

            if (qmsUserVM.CanEditCorrectiveAction == false && qmsUserVM.CanViewAllCorrectiveActions == false)
            {
                return(RedirectToAction("UnauthorizedAccess", "Home"));
            }

            if (id == null || id.HasValue == false)
            {
                Console.WriteLine(logSnippet + $"ID that was passed-in is null or has no value. Cannot continue. (id: '{id}')");
                return(NotFound());
            }

            Console.WriteLine(logSnippet + $"(CorectiveActionId): '{id}'");
            Console.WriteLine(logSnippet + $"(useCase)..........: '{useCase}'");

            User             qmsUser = _userService.RetrieveByEmailAddress(qmsUserVM.EmailAddress);
            CorrectiveAction entity  = _correctiveActionService.RetrieveById(id.Value, qmsUser);

            Console.WriteLine(logSnippet + "(CorrectiveAction.Status == null): " + (entity.Status == null));

            Console.WriteLine(logSnippet + "CorrectiveAction.ToJson() => BEGIN");
            Console.WriteLine(entity.ToJson());
            Console.WriteLine(logSnippet + "END <= CorrectiveAction.ToJson()");

            HttpContext.Items[CorrectiveActionsConstants.NOA_CODE_KEY]          = entity.NOACode;
            HttpContext.Items[CorrectiveActionsConstants.CURRENT_STATUS_ID_KEY] = entity.StatusId;

            string[] selectedErrorTypeIds = CorrectiveActionUtil.ExtractErrorTypeIds(entity);
            HttpContext.Items[CorrectiveActionsConstants.SELECTED_ERROR_TYPES_KEY] = selectedErrorTypeIds;

            Console.WriteLine(logSnippet + $"(qmsUserVM.CanAssignTasks).....: {qmsUserVM.CanAssignTasks}");
            Console.WriteLine(logSnippet + $"(CorrectiveAction.IsAssignable): {entity.IsAssignable}");

            HttpContext.Items[CorrectiveActionsConstants.IS_ASSIGNABLE_KEY] = false;
            HttpContext.Items[CorrectiveActionsConstants.CURRENT_ASSIGNED_TO_USER_ID_KEY] = null;

            if (qmsUserVM.CanAssignTasks && entity.IsAssignable)
            {
                HttpContext.Items[CorrectiveActionsConstants.IS_ASSIGNABLE_KEY] = true;
                if (entity.AssignedByUserId.HasValue)
                {
                    HttpContext.Items[CorrectiveActionsConstants.CURRENT_ASSIGNED_TO_USER_ID_KEY] = entity.AssignedToUserId.ToString();
                }
                else
                {
                    HttpContext.Items[CorrectiveActionsConstants.CURRENT_ASSIGNED_TO_USER_ID_KEY] = null;
                }
            }

            if (HttpContext.Session.GetObject <bool>(CorrectiveActionsConstants.NEWLY_CREATED_COMMENT_KEY) == true)
            {
                ViewData[CorrectiveActionsConstants.NEWLY_CREATED_COMMENT_KEY] = HttpContext.Session.GetObject <bool>(CorrectiveActionsConstants.NEWLY_CREATED_COMMENT_KEY);
                HttpContext.Session.SetObject(CorrectiveActionsConstants.NEWLY_CREATED_COMMENT_KEY, false);
            }

            ViewData[CorrectiveActionsConstants.CA_EDIT_MESSAGE_KEY] = null;
            if (String.IsNullOrEmpty(mk) == false && String.IsNullOrWhiteSpace(mk) == false)
            {
                if (HttpContext.Session.GetObject <string>(mk) != null)
                {
                    ViewData[CorrectiveActionsConstants.CA_EDIT_MESSAGE_KEY] = HttpContext.Session.GetObject <string>(mk);
                    HttpContext.Session.SetObject(mk, null);
                }
            }

            List <ModuleMenuItem> moduleMenuItems = HttpContext.Session.GetObject <List <ModuleMenuItem> >(MiscConstants.MODULE_MENU_ITEMS_SESSION_KEY);

            return(View(CorrectiveActionUtil.MapToViewModel(entity, qmsUserVM.UserId, useCase, moduleMenuItems, qmsUserVM.CanAssignTasks)));
        }
Example #28
0
 public CorrectiveAction UpdateByReassign(CorrectiveAction correctiveAction)
 {
     this.Update(correctiveAction);
     this.SendEmailAuditRescheduling(correctiveAction);
     return(correctiveAction);
 }
        // [Authorize(Roles = "SC_SPECIALIST,SC_REVIEWER,PPRB_SPECIALIST,PPRB_REVIEWER,PPRM_SPECIALIST,PPRM_REVIEWER")]
        public IActionResult Edit
        (
            [Bind("EmployeeSearchResult, NatureOfAction,EffectiveDateOfPar,IsPaymentMismatch,ErrorTypeIds,ActionRequestTypeId,StatusTypeId,CurrentStatusId,CorrectiveActionId,AssignedToUserId,RowVersion,Details")]
            CorrectiveActionFormViewModel correctiveActionVM, string[] selectedErrorTypes
        )
        {
            if (HttpContext == null ||
                HttpContext.Session == null ||
                HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY) == null)
            {
                return(RedirectToAction("Warning", "Home"));
            }

            string logSnippet = new StringBuilder("[")
                                .Append(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"))
                                .Append("][CorrectiveActionsController][HttpPost][Edit] => ")
                                .ToString();

            UserViewModel qmsUserVM = HttpContext.Session.GetObject <UserViewModel>(MiscConstants.USER_SESSION_VM_KEY);

            Console.WriteLine(logSnippet + $"(qmsUserVM): {qmsUserVM}");

            if (qmsUserVM.CanEditCorrectiveAction == false)
            {
                return(RedirectToAction("UnauthorizedAccess", "Home"));
            }

            Console.WriteLine(logSnippet + $"(correctiveActionVM.AssignedToUserId): '{correctiveActionVM.AssignedToUserId}'");
            Console.WriteLine(logSnippet + $"(correctiveActionVM.CurrentStatusId).: '{correctiveActionVM.CurrentStatusId}'");

            ///////////////////////////////////////////////////////////////////////////////////
            // Error Categories Validation
            ///////////////////////////////////////////////////////////////////////////////////
            if (selectedErrorTypes == null || selectedErrorTypes.Count() == 0)
            {
                Console.WriteLine(logSnippet + "No error categories/types selected. Adding a model error.");
                ModelState.AddModelError(string.Empty, "Please select at least one error category.");
            }

            ///////////////////////////////////////////////////////////////////////////////////
            // Employee Search
            ///////////////////////////////////////////////////////////////////////////////////
            string emplIdStr = CorrectiveActionUtil.ExtractEmplId(correctiveActionVM.EmployeeSearchResult);
            long   emplIdLong;

            if (String.IsNullOrEmpty(emplIdStr) == false &&
                long.TryParse(emplIdStr, out emplIdLong) == true)
            {
                try
                {
                    Employee employee = _employeeService.RetrieveById(emplIdStr);
                }
                catch (EmployeeNotFoundException enfe)
                {
                    Console.WriteLine(logSnippet + "EmployeeNotFoundException encountered:");
                    Console.WriteLine(enfe.Message);
                    ModelState.AddModelError(string.Empty, $"Employee not found with Employee ID of '{emplIdStr}'");
                }
            }

            User             qmsUser             = _userService.RetrieveByEmailAddress(qmsUserVM.EmailAddress);
            CorrectiveAction oldCorrectiveAction = _correctiveActionService.RetrieveById(correctiveActionVM.CorrectiveActionId, qmsUser);

            if (correctiveActionVM.CorrectiveActionId != oldCorrectiveAction.Id)
            {
                StringBuilder sb = new StringBuilder(logSnippet);
                sb.Append("Corrective Action ID discrepancy detected: ");
                sb.Append("UIModel ID: '");
                sb.Append(oldCorrectiveAction.Id);
                sb.Append("'; ViewModel ID: '");
                sb.Append(correctiveActionVM.CorrectiveActionId);
                sb.Append("'.");
                Console.WriteLine(sb.ToString());
            }

            if (correctiveActionVM.RowVersion != oldCorrectiveAction.RowVersion)
            {
                StringBuilder sb = new StringBuilder(logSnippet);
                sb.Append("Row version discrepancy detected for Corrective Action (ID: '");
                sb.Append(oldCorrectiveAction.Id);
                sb.Append("'). UIModel Row Version: '");
                sb.Append(oldCorrectiveAction.RowVersion);
                sb.Append("'; ViewModel Row Version: '");
                sb.Append(correctiveActionVM.RowVersion);
                sb.Append("'.");
                Console.WriteLine(sb.ToString());
            }

            Console.WriteLine(logSnippet + "(ModelState.IsValid): " + (ModelState.IsValid));

            if (ModelState.IsValid)
            {
                CorrectiveAction updatedCorrectiveAction = CorrectiveActionUtil.MapToUIModelOnUpdate(correctiveActionVM, selectedErrorTypes, oldCorrectiveAction);

                Console.WriteLine(logSnippet + "Updated CorrectiveAction (BEFORE SAVE) => BEGIN");
                Console.WriteLine(updatedCorrectiveAction.ToJson());
                Console.WriteLine("END <= Updated CorrectiveAction (BEFORE SAVE)");
                Console.WriteLine(logSnippet + $"(updatedCorrectiveAction.AssignedToUserId)(BEFORE SAVE): '{updatedCorrectiveAction.AssignedToUserId}'");

                int entityId = 0;
                try
                {
                    entityId = _correctiveActionService.Save(updatedCorrectiveAction, qmsUser);
                }
                catch (LockingException lockExc)
                {
                    Console.WriteLine(logSnippet + "(BEGIN CorrectiveActionLockingException:");
                    Console.WriteLine(lockExc.Message);
                    Console.WriteLine(logSnippet + "(:END CorrectiveActionLockingException");
                }

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // WRITE SUCCESS MESSAGE TO LOG
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                Console.WriteLine(logSnippet + "Record saved to DB, redirecting in CorrectiveAction Index page");
                Console.WriteLine(logSnippet + $"Updated CorrectiveAction #{updatedCorrectiveAction.Id} has been saved to the database, redirecting in Home Index page");

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // PREPARE SUCCESS MESSAGE FOR USER
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                string msgKey = Guid.NewGuid().ToString();
                string msgVal = $"Corrective Action with an ID of {entityId} has been updated for {correctiveActionVM.EmployeeSearchResult}";
                HttpContext.Session.SetObject(msgKey, msgVal);

                return(RedirectToAction("Index", "Home", new { @mk = msgKey }));
            }
            else
            {
                Console.WriteLine(logSnippet + "ModelState IS NOT VALID, returning User to Edit Corrective Actions page");
                if (selectedErrorTypes != null || selectedErrorTypes.Count() > 0)
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////
                    // The HttpContext.Items collection is used to store data while processing a single request.
                    // The collection's contents are discarded after a request is processed.
                    /////////////////////////////////////////////////////////////////////////////////////////////
                    HttpContext.Items[CorrectiveActionsConstants.SELECTED_ERROR_TYPES_KEY] = selectedErrorTypes;
                    HttpContext.Items[CorrectiveActionsConstants.CURRENT_STATUS_ID_KEY]    = correctiveActionVM.CurrentStatusId;
                }

                if (qmsUserVM.CanAssignTasks && oldCorrectiveAction.IsAssignable)
                {
                    HttpContext.Items[CorrectiveActionsConstants.IS_ASSIGNABLE_KEY] = true;
                    if (oldCorrectiveAction.AssignedByUserId.HasValue)
                    {
                        HttpContext.Items[CorrectiveActionsConstants.CURRENT_ASSIGNED_TO_USER_ID_KEY] = oldCorrectiveAction.AssignedToUserId.ToString();
                    }
                    else
                    {
                        HttpContext.Items[CorrectiveActionsConstants.CURRENT_ASSIGNED_TO_USER_ID_KEY] = null;
                    }
                }

                correctiveActionVM.CorrectiveActionId = oldCorrectiveAction.Id;
                correctiveActionVM.CorrectiveActionIdForAddComment = oldCorrectiveAction.Id;
                correctiveActionVM.Details   = oldCorrectiveAction.Details;
                correctiveActionVM.Comments  = oldCorrectiveAction.Comments;
                correctiveActionVM.Histories = oldCorrectiveAction.Histories;

                correctiveActionVM.StatusLabel       = oldCorrectiveAction.Status.StatusLabel;
                correctiveActionVM.DateSubmitted     = oldCorrectiveAction.CreatedAt.ToString("MMMM dd, yyyy");
                correctiveActionVM.CreatedByUserName = oldCorrectiveAction.CreatedByUser.DisplayName;
                correctiveActionVM.CreatedByOrgLabel = oldCorrectiveAction.CreatedByOrg.OrgLabel;

                correctiveActionVM.IsReadOnly = oldCorrectiveAction.IsReadOnly;

                return(View(correctiveActionVM));
            }
        }
 public StatusChangedEventArgs(
     CorrectiveAction old_corrective_action,
     QAMChannelStatus old_status, QAMChannelStatus new_status)
     : base()
 {
     old_corrective_action_ = old_corrective_action;
     old_status_ = old_status;
     new_status_ = new_status;
 }