Exemple #1
0
 public void UpdateReportValidationBasedOnNewData(ref ReportValidationModel reportValidation, List <string> validStationIdList, List <string> validEmployeeIdList, List <string> validUnitList, List <WorkShiftModel> availableWorkshiftList)
 {
     UpdateReportValidationWithRepeatedUnits(ref reportValidation);
     UpdateReportValidationWithRepeatedCrewMembers(ref reportValidation);
     UpdateReportValidationWithInvalidUnits(validUnitList, ref reportValidation);
     UpdateReportValidationWithInvalidEmployees(validEmployeeIdList, ref reportValidation);
     UpdateReportValidationWithInvalidStations(validStationIdList, ref reportValidation);
     UpdateReportValidationByUnit(availableWorkshiftList, ref reportValidation);
 }
Exemple #2
0
        public void UpdateReportValidationWithRepeatedCrewMembers(ref ReportValidationModel reportValidation)
        {
            //repeatedCrewMemberRowList = new List<int>();
            List <ImportableWorkScheduleUnitModel> workScheduleAdaptedForOneMember = new List <ImportableWorkScheduleUnitModel>();

            foreach (ImportableWorkScheduleUnitModel workScheduleUnitOriginal in
                     WorkScheduleForUnitList.Where(u => !String.IsNullOrEmpty(u.WorkshiftLabel) && u.ShiftDate.HasValue))
            {
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.Doctor, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.Nurse, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.Driver, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.FirstAuxiliar, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.SecondAuxiliar, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
                CloneWorkScheduleWithDateValues(driverEmployeeId: workScheduleUnitOriginal.ThirdAuxiliar, workScheduleAdaptedForOneMember: workScheduleAdaptedForOneMember, workScheduleUnitOriginal: workScheduleUnitOriginal);
            }

            workScheduleAdaptedForOneMember = workScheduleAdaptedForOneMember.Distinct().OrderBy(u => u.Driver).ThenBy(u => u.Row).ThenBy(u => u.WorkshiftLabel).ThenBy(u => u.ShiftDate.Value).ToList();

            for (int i = 1; i < workScheduleAdaptedForOneMember.Count; i++)
            {
                if (workScheduleAdaptedForOneMember[i].Driver.Equals(workScheduleAdaptedForOneMember[i - 1].Driver) &&
                    workScheduleAdaptedForOneMember[i].ShiftDate.Value.Equals(workScheduleAdaptedForOneMember[i - 1].ShiftDate.Value) &&
                    workScheduleAdaptedForOneMember[i].WorkshiftLabel.Equals(workScheduleAdaptedForOneMember[i - 1].WorkshiftLabel) &&
                    !workScheduleAdaptedForOneMember[i].Row.Equals(workScheduleAdaptedForOneMember[i - 1].Row))
                {
                    reportValidation.AddReportItem(
                        WorkScheduleValidationType.EMPLOYEE_DUPLICATED_AT_DAY,
                        GetConflictingDataMessage(workScheduleAdaptedForOneMember[i - 1].Row, workScheduleAdaptedForOneMember[i].Row,
                                                  Properties.Resources.EMPLOYEE_LABEL, workScheduleAdaptedForOneMember[i].Driver),
                        new List <string>()
                    {
                        workScheduleAdaptedForOneMember[i - 1].ID, workScheduleAdaptedForOneMember[i].ID
                    });
                }
            }
            //return repeatedCrewMemberRowList.Count > 0;
        }
Exemple #3
0
        public void UpdateReportValidationWithRepeatedUnits(ref ReportValidationModel reportValidation)//out List<int> repeatedUnitRowList
        {
            List <ImportableWorkScheduleUnitModel> workScheduleForChecking;

            workScheduleForChecking = WorkScheduleForUnitList.Where(u => !String.IsNullOrEmpty(u.UnitId) && !String.IsNullOrEmpty(u.WorkshiftLabel) && u.ShiftDate.HasValue)
                                      .OrderBy(u => u.UnitId).ThenBy(u => u.ShiftDate.Value).ThenBy(u => u.WorkshiftLabel).ToList();
            for (int i = 1; i < workScheduleForChecking.Count; i++)
            {
                if (workScheduleForChecking[i].UnitId.Equals(workScheduleForChecking[i - 1].UnitId) &&
                    workScheduleForChecking[i].ShiftDate.Value.Equals(workScheduleForChecking[i - 1].ShiftDate.Value) &&
                    workScheduleForChecking[i].WorkshiftLabel.Equals(workScheduleForChecking[i - 1].WorkshiftLabel))
                {
                    reportValidation.AddReportItem(
                        WorkScheduleValidationType.UNIT_DUPLICATED_AT_DAY,
                        GetConflictingDataMessage(workScheduleForChecking[i - 1].Row, workScheduleForChecking[i].Row,
                                                  ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.UNIT_ID_COL_NUM], workScheduleForChecking[i].UnitId),
                        new List <string>()
                    {
                        workScheduleForChecking[i - 1].ID, workScheduleForChecking[i].ID
                    });
                    //repeatedUnitRowList.Add(workScheduleForChecking)
                }
            }
        }
Exemple #4
0
        private ReportValidationModel UpdateReportValidationByUnit(List <WorkShiftModel> availableWorkshiftList, ref ReportValidationModel reportValidation)
        {
            foreach (ImportableWorkScheduleUnitModel ws in WorkScheduleForUnitList)
            {
                ws.UpdateReportValidation(ref reportValidation, availableWorkshiftList);
            }

            return(reportValidation);
        }
Exemple #5
0
 private void UpdateReportValidationWithReplacingData(string oldValue, string newValue, ImportableWorkScheduleUnitModel workScheduleForUnit, string colLabel, ref ReportValidationModel reportValidation)
 {
     if ((oldValue ?? String.Empty) != (newValue ?? String.Empty))
     {
         reportValidation.AddReportItem(
             WorkScheduleValidationType.CONFLICT_WITH_PREVIOUS_DATA,
             GetReplacingDataMessage(workScheduleForUnit.Row, colLabel,
                                     (oldValue ?? String.Empty), (newValue ?? String.Empty)),
             new List <string>()
         {
             workScheduleForUnit.ID
         });
     }
 }
Exemple #6
0
 public void UpdateReportValidationBasedOnOldData(ref ReportValidationModel reportValidation, List <WorkShiftModel> availableWorkshiftList, List <WorkScheduleUnitModel> unitForceMapList)
 {
     UpdateReportValidationAlertingConflictsWithPreviousData(unitForceMapList, availableWorkshiftList, ref reportValidation);
 }
Exemple #7
0
 private void UpdateReportValidationWithReplacingData(UnitCrewMember oldCrewMember, UnitCrewMember newCrewMember, ImportableWorkScheduleUnitModel workScheduleForUnit, string colLabel, ref ReportValidationModel reportValidation)
 {
     if ((oldCrewMember != null ? oldCrewMember.EmployeeId.ToString() : String.Empty) != (newCrewMember != null ? newCrewMember.EmployeeId.ToString() : String.Empty))
     {
         reportValidation.AddReportItem(
             WorkScheduleValidationType.CONFLICT_WITH_PREVIOUS_DATA,
             GetReplacingDataMessage(workScheduleForUnit.Row, colLabel,
                                     (oldCrewMember != null ? oldCrewMember.EmployeeId.ToString() : String.Empty), (newCrewMember != null ? newCrewMember.EmployeeId.ToString() : String.Empty)),
             new List <string>()
         {
             workScheduleForUnit.ID
         });
     }
 }
Exemple #8
0
        public void UpdateReportValidationAlertingConflictsWithPreviousData(List <WorkScheduleUnitModel> unitForceMapList, List <WorkShiftModel> availableWorkShiftList, ref ReportValidationModel reportValidation)
        {
            foreach (WorkScheduleUnitModel oldUnitForceMap in unitForceMapList)
            {
                ImportableWorkScheduleUnitModel workScheduleForUnit = WorkScheduleForUnitList
                                                                      .Where(ws => ws.ShiftDate.HasValue &&
                                                                             ws.ShiftDate.Value.Date.CompareTo(oldUnitForceMap.ShiftDate.Date) == 0 &&
                                                                             ws.WorkshiftLabel == oldUnitForceMap.CurrentWorkShift.Label &&
                                                                             ws.UnitId == oldUnitForceMap.UnitId
                                                                             ).FirstOrDefault();

                if (workScheduleForUnit == null)
                {
                    continue;
                }

                WorkScheduleUnitModel newUnitForceMap = workScheduleForUnit.ToWorkScheduleUnitModel(availableWorkShiftList);

                // necessary condition because the old cell phone takes the number registered in the Active Unit

                /*if(!String.IsNullOrEmpty(newUnitForceMap.CellPhone))
                 *  UpdateReportValidationWithReplacingData(oldUnitForceMap.CellPhone, newUnitForceMap.CellPhone, workScheduleForUnit,
                 *                                            WorkScheduleForUnitModel.colNames[WorkScheduleForUnitModel.CELL_PHONE_COL_NUM], ref reportValidation);
                 *
                 * UpdateReportValidationWithReplacingData(oldUnitForceMap.Remarks, newUnitForceMap.Remarks, workScheduleForUnit,
                 *                                            WorkScheduleForUnitModel.colNames[WorkScheduleForUnitModel.REMARK_COL_NUM], ref reportValidation);
                 */
                UpdateReportValidationWithReplacingData(oldUnitForceMap.Station == null ? null : oldUnitForceMap.Station.StationId,
                                                        newUnitForceMap.Station == null ? null : newUnitForceMap.Station.StationId, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.STATION_NAME_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.Doctor, newUnitForceMap.Doctor, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.DOCTOR_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.Driver, newUnitForceMap.Driver, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.DRIVER_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.Nurse, newUnitForceMap.Nurse, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.NURSE_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.FirstAuxiliar, newUnitForceMap.FirstAuxiliar, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.FIRST_AUXILIAR_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.SecondAuxiliar, newUnitForceMap.SecondAuxiliar, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.SECOND_AUXILIAR_COL_NUM], ref reportValidation);

                UpdateReportValidationWithReplacingData(oldUnitForceMap.ThirdAuxiliar, newUnitForceMap.ThirdAuxiliar, workScheduleForUnit,
                                                        ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.THIRD_AUXILIAR_COL_NUM], ref reportValidation);

                //TODO: UpdateReportValidationWithReplacingData (isURAM)
            }
        }
Exemple #9
0
        public void UpdateReportValidationWithInvalidStations(List <string> validStationIdList, ref ReportValidationModel reportValidation)
        {
            List <string> invalidStationIdList = WorkScheduleForUnitList.Select(wsU => wsU.StationId).Except(validStationIdList).ToList <string>();

            if (invalidStationIdList.Count == 0)
            {
                return;
            }

            foreach (ImportableWorkScheduleUnitModel workScheduleWithInvalidUnit in
                     WorkScheduleForUnitList.Where(u => invalidStationIdList.Contains(u.StationId)))
            {
                reportValidation.AddReportItem(
                    WorkScheduleValidationType.INVALID_STATION,
                    workScheduleWithInvalidUnit.GetMessage(ImportableWorkScheduleUnitModel.colNames[ImportableWorkScheduleUnitModel.STATION_NAME_COL_NUM],
                                                           workScheduleWithInvalidUnit.StationName ?? String.Empty),
                    new List <string>()
                {
                    workScheduleWithInvalidUnit.ID
                });
            }
        }
Exemple #10
0
        public void UpdateReportValidationWithInvalidEmployees(List <string> validEmployeeIdList, ref ReportValidationModel reportValidation)
        {
            List <string> allEmployeeIdsOfWorkSchedule = WorkScheduleForUnitList.Select(wsU => wsU.Driver)
                                                         .Union(WorkScheduleForUnitList.Select(wsU => wsU.ThirdAuxiliar)
                                                                .Union(WorkScheduleForUnitList.Select(wsU => wsU.SecondAuxiliar)
                                                                       .Union(WorkScheduleForUnitList.Select(wsU => wsU.FirstAuxiliar)
                                                                              .Union(WorkScheduleForUnitList.Select(wsU => wsU.Nurse)
                                                                                     .Union(WorkScheduleForUnitList.Select(wsU => wsU.Doctor)
                                                                                            ))))).ToList <string>();

            List <string> invalidEmployeeIdList = allEmployeeIdsOfWorkSchedule.Except(
                validEmployeeIdList.Union(new List <string>()
            {
                null, String.Empty
            })).ToList <string>();

            if (invalidEmployeeIdList.Count == 0)
            {
                return;
            }

            foreach (ImportableWorkScheduleUnitModel workScheduleWithInvalidEmployeeId in WorkScheduleForUnitList)
            {
                List <string> employeeInvalidListByUnit = new List <string>();

                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.Driver))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.Driver);
                }
                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.Doctor))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.Doctor);
                }
                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.Nurse))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.Nurse);
                }
                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.FirstAuxiliar))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.FirstAuxiliar);
                }
                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.SecondAuxiliar))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.SecondAuxiliar);
                }
                if (invalidEmployeeIdList.Contains(workScheduleWithInvalidEmployeeId.ThirdAuxiliar))
                {
                    employeeInvalidListByUnit.Add(workScheduleWithInvalidEmployeeId.ThirdAuxiliar);
                }

                if (employeeInvalidListByUnit.Count > 0)
                {
                    reportValidation.AddReportItem(
                        WorkScheduleValidationType.INVALID_EMPLOYEE_ID,
                        workScheduleWithInvalidEmployeeId.GetMessage(Properties.Resources.EMPLOYEE_LABEL, String.Join(",", employeeInvalidListByUnit)),
                        new List <string>()
                    {
                        workScheduleWithInvalidEmployeeId.ID
                    });
                }
            }
        }
Exemple #11
0
        public void UpdateReportValidation(ref ReportValidationModel reportValidation, List <WorkShiftModel> availableWorkShiftList)
        {
            List <string> repeatedEmployeeIdList = new List <string>();
            List <string> workScheduleIdList     = new List <string>()
            {
                this.ID
            };

            string messageInfo;


            if (this.HasRepeatedEmployeeId(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.EMPLOYEE_DUPLICATED_ON_UNIT, messageInfo, workScheduleIdList);
            }

            if (this.HasOverflowOfCellPhoneLength(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.DATA_LENGTH_OVERFLOW, messageInfo, workScheduleIdList);
            }

            if (this.HasOverflowOfRemarkLength(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.DATA_LENGTH_OVERFLOW, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfDoctor(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfNurse(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfFirstAuxiliar(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfSecondAuxiliar(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfThirdAuxiliar(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (!this.IsFormatValidOfDriver(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_EMPLOYEE_ID, messageInfo, workScheduleIdList);
            }

            if (this.HasRequiredFieldsNotFilled(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.MISSED_DATA, messageInfo, workScheduleIdList);
            }

            if (this.HasFieldsShoudBeFilledButNotRequired(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.DATA_SHOULD_BE_FILLED, messageInfo, workScheduleIdList);
            }

            if (this.IsInvalidDateFormat(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.WRONG_DATA_FORMAT, messageInfo, workScheduleIdList);
            }

            try
            {
                if (!this.IsForwardShiftTime(availableWorkShiftList, out messageInfo))
                {
                    reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_DATE, messageInfo, workScheduleIdList);
                }
            }
            catch
            {
            }

            if (this.IsInvalidWorkshift(availableWorkShiftList, out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_WORKSHIFT, messageInfo, workScheduleIdList);
            }

            if (this.IsURAMWithInvalidCrew(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_CREW, messageInfo, workScheduleIdList);
            }

            if (this.IsSAVWithInvalidCrew(out messageInfo))
            {
                reportValidation.AddReportItem(WorkScheduleValidationType.INVALID_CREW_FORMATION, messageInfo, workScheduleIdList);
            }
        }