Beispiel #1
0
 public void CompleteWithPeriodicWorkSchedule(List <ImportableWorkScheduleUnitModel> workScheduleList, ref bool hasError)
 {
     hasError = false;
     try
     {
         List <DateTime> UramDayOffDates = WorkScheduleBusiness.GetDayOffList(StartDate.Value, EndDate.Value, null);
         this.WorkScheduleImported.CompleteWithPeriodicWorkSchedule
             (workScheduleList, StartDate.Value, EndDate.Value, UramDayOffDates, this.IsMergingWorkSchedule);
     }
     catch (Exception ex)
     {
         hasError = true;
         MessageBox.Show(String.Format("{0}: {1}",
                                       Properties.Resources.ALERT_MESSAGE_ERROR_GENERATING_PERIODIC_WORK_SCHEDULE, ex.Message));
     }
 }
Beispiel #2
0
        public static void UpdateReportValidation(WorkScheduleImportTemplateModel workScheduleTemplate, List <WorkShiftModel> availableWorkshiftList, string currentAgencyId, ReportValidationModel repotValidationModel)
        {
            string        returnMessage;
            List <string> validUnitList          = new List <string>();
            List <string> validStationIdList     = new List <string>();
            List <int>    validEmployeeIdNumList = new List <int>();
            List <string> validEmployeeIdList    = new List <string>();

            List <WorkScheduleUnitModel> workScheduleUnitList = new List <WorkScheduleUnitModel>();

            validUnitList          = UnitBusiness.GetActiveUnitsId(currentAgencyId);
            validStationIdList     = CadBusiness.GetCadStationList(currentAgencyId).Select(cs => cs.StationId).ToList <string>();
            validEmployeeIdNumList = GetEmployeeIds(currentAgencyId);

            foreach (int emp in validEmployeeIdNumList)
            {
                validEmployeeIdList.Add(emp.ToString());
            }

            List <DateTime> dateTimeListFromWorkSchedule      = workScheduleTemplate.WorkScheduleForUnitList.Where(ws => ws.ShiftDate.HasValue).Select(ws => ws.ShiftDate.Value).Distinct().ToList <DateTime>();
            List <string>   workshifLabelListfromWorkSchedule = workScheduleTemplate.WorkScheduleForUnitList.Select(ws => ws.WorkshiftLabel).Distinct().ToList <string>();

            workScheduleTemplate.UpdateReportValidationBasedOnNewData(ref repotValidationModel, validStationIdList, validEmployeeIdList, validUnitList, availableWorkshiftList);

            foreach (DateTime date in dateTimeListFromWorkSchedule)
            {
                foreach (WorkShiftModel workShift in availableWorkshiftList.Where(ws => workshifLabelListfromWorkSchedule.Contains(ws.Label)))
                {
                    workScheduleUnitList = WorkScheduleBusiness.GetWorkScheduleList(null, date, workShift, WorkShiftModel.ShiftTime.Forward, (int)FilterTypeEnum.ALL, out returnMessage)
                                           .Where(uf => uf.Driver != null || uf.Doctor != null || uf.Nurse != null || uf.FirstAuxiliar != null || uf.SecondAuxiliar != null || uf.ThirdAuxiliar != null)
                                           .ToList <WorkScheduleUnitModel>();
                    workScheduleTemplate.UpdateReportValidationBasedOnOldData(ref repotValidationModel, availableWorkshiftList, workScheduleUnitList);
                }
            }

            repotValidationModel.JoinIdsOfReportValidationList();

            UpdateWorkScheduleWithErrors(repotValidationModel, workScheduleTemplate);

            if (repotValidationModel.ReportValidationItemList.Count == 0)
            {
                repotValidationModel.AddReportItem(WorkScheduleValidationType.VALIDATED, Properties.Resources.ALERT_MESSAGE_WHEN_NO_ERRORS);
            }
        }
Beispiel #3
0
        public bool ValidateUpdatingWorkSchedule()
        {
            bool isValid = true;

            foreach (ImportableWorkScheduleUnitModel ws in WorkScheduleImported.WorkScheduleForUnitList)
            {
                if (!WorkScheduleBusiness.ExistsWorkSchedule(ws.UnitId, ws.ShiftDate.Value, ws.WorkshiftLabel))
                {
                    MessageBox.Show(String.Format("{0} {1} {2} {3} {4}",
                                                  Properties.Resources.ALERT_MESSAGE_ERROR_WORK_SCHEDULE_NOT_EXISTS_TO_DATE,
                                                  String.Format(Properties.Settings.Default.DATE_FORMAT, ws.ShiftDate.Value),
                                                  Properties.Resources.ALERT_MESSAGE_ERROR_WORK_SCHEDULE_NOT_EXISTS_TO_UNIT,
                                                  ws.WorkshiftLabel, ws.UnitId));
                    isValid = false;
                    break;
                }
            }

            return(isValid);
        }
Beispiel #4
0
        public void ImportWorkSchedule_DoWork(object sender, DoWorkEventArgs e)
        {
            List <WorkScheduleUnitModel> workScheduleUnitList = new List <WorkScheduleUnitModel>();

            if (IsLoading)
            {
                return;
            }

            try
            {
                EnableLoadingProgress(Properties.Resources.DIALOG_MESSAGE_IMPORTING_WORK_SCHEDULE);

                workScheduleUnitList.AddRange(WorkScheduleImported.WorkScheduleForUnitList.Select(ws => ws.ToWorkScheduleUnitModel(_workShiftList)));

                if (workScheduleUnitList.Where(uf => uf == null).Count() > 0)
                {
                    throw new Exception(Properties.Resources.ALERT_MESSAGE_ERROR_WORK_SCHEDULE_UNIT_CONVERSION);
                }

                foreach (WorkScheduleUnitModel uf in workScheduleUnitList)
                {
                    WorkScheduleBusiness.UpdateFutureUnitForceMap(uf, isCrewUpdating: IsUpdatingWorkSchedule);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(String.Format("{0}: {1}", Properties.Resources.ALERT_MESSAGE_ERROR_IMPORTING, exception.Message));
                return;
            }
            finally
            {
                DisableLoadingProgress();
            }

            MessageBox.Show(Properties.Resources.ALERT_MESSAGE_SUCCESS_IMPORTING);

            CleanFields();

            //ShowMessage("Importação finalizada com sucesso.");
        }
Beispiel #5
0
        private static void UpdateWorkScheduleWithCrewCategoryFromUnitType(ref IEnumerable <ImportableWorkScheduleUnitModel> workScheduleList)
        {
            try
            {
                Dictionary <string, string> unitTypeByUnitIdList = WorkScheduleBusiness.GetUnitTypeByUnitIdDictionary();

                foreach (ImportableWorkScheduleUnitModel workScheduleForUnit in workScheduleList)
                {
                    if (!unitTypeByUnitIdList.ContainsKey(workScheduleForUnit.UnitId))
                    {
                        continue;
                    }

                    workScheduleForUnit.UnitType = unitTypeByUnitIdList[workScheduleForUnit.UnitId];
                }
            }
            catch
            {
                throw;
            };
        }
Beispiel #6
0
 public static void SaveWorkScheduleTemplate(string targetFullPathFile)
 {
     try
     {
         WorkScheduleData.SaveWorkScheduleTemplate(targetFullPathFile);
         Data.WorkSchedule.ImportableWorkScheduleData.UpdateWorkScheduleSheets(targetFullPathFile, WorkScheduleBusiness.GetParameter(Properties.Settings.Default.PASSWORD_KEY_NAME));
     }
     catch (Exception exception)
     {
         logger.Error(exception);
         throw exception;
     }
 }