private void Exporting(SelectExportBookingParameters selectedExportParameters) { if (selectedExportParameters == null) { return; } if (selectedExportParameters.Employee == null) { MessageBox.Show(CaptionHelper.GetLocalizedText("Texts", "NO_EMPLOYEE_SELECTED"), CaptionHelper.GetLocalizedText("Texts", "Error"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var firstDayOfMonth = selectedExportParameters.ExportStart.ToShortDateString(); var lastDayOfMonth = selectedExportParameters.ExportEnd.ToShortDateString(); var bookingCriteria = GroupOperator.And( new BinaryOperator("Employee", selectedExportParameters.Employee), new BinaryOperator("Date", firstDayOfMonth, BinaryOperatorType.GreaterOrEqual), new BinaryOperator("Date", lastDayOfMonth, BinaryOperatorType.LessOrEqual)); var bookings = new List <IBooking>(); if (selectedExportParameters.WithVacation) { bookings = _objectSpace.GetObjects <IBooking>(bookingCriteria) .ToList(); } else { bookings = _objectSpace.GetObjects <IBooking>(bookingCriteria) .Where(b => !b.IsVacation && !b.IsPublicHoliday) .ToList(); } if (!bookings.Any()) { return; } var saveFolder = SelectFolderToSaveBookingExport(); if (saveFolder != null) { BookingExporter.ExportJdcBookings(_objectSpace, saveFolder, bookings); } }
/// <summary> /// Start Dialog to select export parameters /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void exportEmployeeBookings_Execute(object sender, SimpleActionExecuteEventArgs e) { _objectSpace = ObjectSpace.CreateNestedObjectSpace(); var currentUser = _objectSpace.GetObject(SecuritySystem.CurrentUser); var exportParameters = new SelectExportBookingParameters(); exportParameters.Employee = _objectSpace.FindObject <IEmployee>(CriteriaOperator.Parse("User = ?", currentUser)); var detailView = Application.CreateDetailView(_objectSpace, exportParameters); Application.ShowViewStrategy.ShowViewInPopupWindow(detailView, () => { Exporting(exportParameters); Application.ShowViewStrategy.ShowMessage("Daten wurden exportiert", InformationType.Success, 3000, InformationPosition.Right); }, () => { DialogCanceled(); }, "Exportieren", "Abbrechen" ); }