Beispiel #1
0
        public void SaveWorkScheduleTemplate_DoWork(object sender, DoWorkEventArgs e)
        {
            if (IsLoading)
            {
                return;
            }

            try{
                string file = (string)e.Argument;
                EnableLoadingProgress(Properties.Resources.DIALOG_MESSAGE_GENERATING_FILE);
                ImportableWorkScheduleBusiness.SaveWorkScheduleTemplate(file);
                MessageBox.Show(Properties.Resources.ALERT_MESSAGE_SUCCESS_GENERATING_FILE);
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    String.Format("{0}: {1}", Properties.Resources.ALERT_MESSAGE_ERROR_GENERATING_FILE, exception.Message));
            }
            finally
            {
                DisableLoadingProgress();
            }
        }
Beispiel #2
0
        public void LoadValidation_DoWork(object sender, DoWorkEventArgs e)
        {
            if (IsLoading)
            {
                return;
            }

            try
            {
                EnableLoadingProgress(Properties.Resources.DIALOG_MESSAGE_VALIDATING_WORK_SCHEDULE);
                WorkScheduleImported = new WorkScheduleImportTemplateModel();
                RevortValidationList = new ObservableCollection <ReportValidationItemModel>();

                if (this.IsPeriodicWorkSchedule)
                {
                    if (!ValidatePeriodicWorkScheduleFilter())
                    {
                        DisableLoadingProgress();
                        return;
                    }
                }

                List <ImportableWorkScheduleUnitModel> workScheduleList = ImportableWorkScheduleBusiness.ExtractWorkSchedule(this.FullPathFile).ToList <ImportableWorkScheduleUnitModel>();

                if (this.IsPeriodicWorkSchedule)
                {
                    bool hasError = false;

                    if (workScheduleList.Where(ws => String.IsNullOrEmpty(ws.DateFrequence)).Count() > 0)
                    {
                        DisableLoadingProgress();
                        MessageBox.Show(Properties.Resources.ALERT_MESSAGE_MISSED_DATE_FREQUENCE);
                        return;
                    }

                    CompleteWithPeriodicWorkSchedule(workScheduleList, ref hasError);

                    if (hasError || (IsUpdatingWorkSchedule && !ValidateUpdatingWorkSchedule()))
                    {
                        DisableLoadingProgress();
                        return;
                    }
                }
                else
                {
                    WorkScheduleImported.WorkScheduleForUnitList = workScheduleList;
                }

                ReportValidation = new ReportValidationModel();
                ReportValidationBusiness.UpdateReportValidation(WorkScheduleImported, _workShiftList, Properties.Settings.Default.AGENCY_ID, ReportValidation);



                if (IsUpdatingWorkSchedule)
                {
                    this.ReportValidation.ReportValidationItemList.RemoveAll(
                        r => r.WorkScheduleValidationType == WorkScheduleValidationType.CONFLICT_WITH_PREVIOUS_DATA ||
                        r.WorkScheduleValidationType == WorkScheduleValidationType.DATA_SHOULD_BE_FILLED ||
                        r.WorkScheduleValidationType == WorkScheduleValidationType.INVALID_CREW_FORMATION);
                }



                EnableImporting = !ReportValidationBusiness.AreThereErrorMessages(this.ReportValidation);
            }
            catch (SheetNotFoundException exception)
            {
                WorkScheduleImported.WorkScheduleForUnitList = new List <ImportableWorkScheduleUnitModel>();
                ReportValidation = new ReportValidationModel();
                EnableImporting  = false;

                ReportValidation.AddReportItem(WorkScheduleValidationType.SHEET_NAME_NOT_FOUND, ImportableWorkScheduleBusiness.GetWorkScheduleSheetName().ToUpper());
            }
            catch (Exception exception)
            {
                WorkScheduleImported.WorkScheduleForUnitList = new List <ImportableWorkScheduleUnitModel>();
                ReportValidation = new ReportValidationModel();
                EnableImporting  = false;

                MessageBox.Show(String.Format("{0}: {1}", Properties.Resources.ALERT_MESSAGE_ERROR_FILE_VALIDATING, exception.Message));
                return;
            }
            finally
            {
                DisableLoadingProgress();
            }
        }