public async void ExecuteGenerateReport() { if (ReportEndDateTime == null || ReportStartDateTime == null) { return; } var reportFilePath = FilePath; MaterialDesignMessageQueue.Enqueue("Generating your report...", true); IsLoading = true; switch (SelectedReportType) { case Doctor _: await _reportService.GeneratePersonalDoctorReport(Doctor, ReportStartDateTime.Value, ReportEndDateTime.Value, FilePath, SelectedFileFormat); break; case Patient _: await _reportService.GenerateRoomReport(ReportStartDateTime.Value, ReportEndDateTime.Value, FilePath, SelectedFileFormat); break; } IsLoading = false; MaterialDesignMessageQueue.Enqueue("Your report has been generated successfully", "Open file location", message => { var startInfo = new ProcessStartInfo { Arguments = reportFilePath, FileName = "explorer.exe" }; Process.Start(startInfo); }, null, false, true, TimeSpan.FromSeconds(6));; }
private async void ExecuteScheduleAppointment() { await Task.Run(async() => { RoomAlreadyInUse = InvalidTimeFrame = false; var appointmentStart = AppointmentStartDate + AppointmentStartTime?.TimeOfDay; var appointmentEnd = AppointmentEndDate + AppointmentEndTime?.TimeOfDay; CalendarEntry created = null; if (appointmentEnd <= appointmentStart || appointmentEnd == null || appointmentStart == null) { InvalidTimeFrame = true; } // Trying to save some RAM else if ((await _calendarEntryService.GetAllByRoomAndTimeFrame(SelectedRoom, appointmentStart.Value, appointmentEnd.Value)).ToList().Count != 0) { //var res = await _calendarEntryService.GetAllByRoomAndTimeFrame(SelectedRoom, appointmentStart.Value, appointmentEnd.Value); RoomAlreadyInUse = true; } else { switch (SelectedAppointmentType) { case RoomType.CheckUp: if (ScheduleAppointmentAtSpecialist) { await _calendarEntryService.CreateAppointmentRequest(appointmentStart.Value, appointmentEnd.Value, SelectedPatient, Doctor, SelectedSpecialist, DateTime.Now, SelectedRoom); MaterialDesignMessageQueue.Enqueue("All managers have been notified of this appointment."); } else { created = await _calendarEntryService.CreateAppointment(appointmentStart.Value, appointmentEnd.Value, Doctor, SelectedPatient, SelectedRoom); } Clean(); break; case RoomType.Surgery: if (ScheduleAppointmentAtSpecialist) { await _calendarEntryService.CreateSurgeryRequest(appointmentStart.Value, appointmentEnd.Value, SelectedPatient, Doctor, SelectedSpecialist, IsUrgent, DateTime.Now, SelectedRoom); MaterialDesignMessageQueue.Enqueue("All managers have been notified of this surgery."); } else { created = await _calendarEntryService.CreateSurgery(appointmentStart.Value, appointmentEnd.Value, Doctor, SelectedPatient, SelectedRoom, IsUrgent); if (IsUrgent) { MaterialDesignMessageQueue.Enqueue("All managers have been notified of this surgery"); } } Clean(); break; } } if (created != null) { Application.Current.Dispatcher.Invoke(() => Calendar.AddEvent(created)); } }); }