Exemple #1
0
 private string GetExceptionMessageToDateConflicted(ImportableWorkScheduleUnitModel ws1, ImportableWorkScheduleUnitModel ws2, int colIndex, List <int> conflictedRows)
 {
     return(String.Format("Linhas [ {0} ] apresentaram conflito em {1:dd/MM/yyyy}, no campo: {2}",
                          String.Join(",", conflictedRows),
                          ws1.ShiftDate.Value,
                          ImportableWorkScheduleUnitModel.colNames[colIndex]));
 }
Exemple #2
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 #3
0
        private static void CloneWorkScheduleWithDateValues(string driverEmployeeId, List <ImportableWorkScheduleUnitModel> workScheduleAdaptedForOneMember, ImportableWorkScheduleUnitModel workScheduleUnitOriginal)
        {
            if (!String.IsNullOrEmpty(driverEmployeeId))
            {
                ImportableWorkScheduleUnitModel workScheduleUnitOneMember = new ImportableWorkScheduleUnitModel();
                workScheduleUnitOneMember.Driver             = driverEmployeeId;
                workScheduleUnitOneMember.WorkshiftLabel     = workScheduleUnitOriginal.WorkshiftLabel;
                workScheduleUnitOneMember.ShiftDateCellValue = workScheduleUnitOriginal.ShiftDateCellValue;
                workScheduleUnitOneMember.Row = workScheduleUnitOriginal.Row;

                workScheduleAdaptedForOneMember.Add(workScheduleUnitOneMember);
            }
        }
Exemple #4
0
 public bool Equals(ImportableWorkScheduleUnitModel other)
 {
     if (this != null && other != null)
     {
         var type = typeof(WorkScheduleUnitModel);
         var unequalProperties =
             from propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
             let thisValue = type.GetProperty(propertyInfo.Name).GetValue(this, null)
                             let otherValue = type.GetProperty(propertyInfo.Name).GetValue(other, null)
                                              where thisValue != otherValue && (thisValue == null || !thisValue.Equals(otherValue))
                                              select thisValue;
         return(!unequalProperties.Any());
     }
     return(this == other);
 }
Exemple #5
0
        private ImportableWorkScheduleUnitModel MergeCrew(List <ImportableWorkScheduleUnitModel> workScheduleList)
        {
            //string message = "Linhas {0} e {1} apresentam confilto de equipe ao ser realizado o ";
            int        conflictedColumn = -1;
            List <int> conflictedRows   = new List <int>();
            ImportableWorkScheduleUnitModel mergedWorkSchedule = (ImportableWorkScheduleUnitModel)workScheduleList.First().Clone();


            foreach (ImportableWorkScheduleUnitModel ws in workScheduleList
                     .Except(new List <ImportableWorkScheduleUnitModel>()
            {
                mergedWorkSchedule
            }))
            {
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.Doctor, PersonType.MEDIC))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.DOCTOR_COL_NUM;
                }
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.Nurse, PersonType.NURSE))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.NURSE_COL_NUM;
                }
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.Driver, PersonType.DRIVER))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.DRIVER_COL_NUM;
                }
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.FirstAuxiliar, PersonType.AUX))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.FIRST_AUXILIAR_COL_NUM;
                }
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.SecondAuxiliar, PersonType.AUX))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.SECOND_AUXILIAR_COL_NUM;
                }
                if (!mergedWorkSchedule.AddCrewMemberIfOtherNotAlreadyIncluded(ws.ThirdAuxiliar, PersonType.AUX))
                {
                    conflictedColumn = ImportableWorkScheduleUnitModel.THIRD_AUXILIAR_COL_NUM;
                }
                conflictedRows.Add(ws.Row);

                if (conflictedColumn > -1)
                {
                    throw new Exception(
                              GetExceptionMessageToDateConflicted(mergedWorkSchedule, ws, conflictedColumn, conflictedRows));
                }
            }
            return(mergedWorkSchedule);
        }
Exemple #6
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 #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
         });
     }
 }