diff --git a/LeanderShiftPlannerV2/FileIO/TimesheetIO.cs b/LeanderShiftPlannerV2/FileIO/TimesheetIO.cs index 283502f..c7287e2 100644 --- a/LeanderShiftPlannerV2/FileIO/TimesheetIO.cs +++ b/LeanderShiftPlannerV2/FileIO/TimesheetIO.cs @@ -86,9 +86,9 @@ public static class TimesheetIO foreach ((DateTime, DateTime, bool) tuple in timesheet.Value) { - worksheet.Cells[17 + tuple.Item1.Day, 2].Value = tuple.Item1.Hour + ":" + (tuple.Item1.Minute == 0 ? "00" : tuple.Item1.Minute.ToString()); - worksheet.Cells[17 + tuple.Item1.Day, 3].Value = tuple.Item2.Hour + ":" + (tuple.Item2.Minute == 0 ? "00" : tuple.Item1.Minute.ToString()); - if (tuple.Item3) worksheet.Cells[17 + tuple.Item1.Day, 5].Value = "1:00"; + worksheet.Cells[16 + tuple.Item1.Day, 2].Value = tuple.Item1.Hour + ":" + (tuple.Item1.Minute == 0 ? "00" : tuple.Item1.Minute.ToString()); + worksheet.Cells[16 + tuple.Item1.Day, 3].Value = tuple.Item2.Hour + ":" + (tuple.Item2.Minute == 0 ? "00" : tuple.Item1.Minute.ToString()); + if (tuple.Item3) worksheet.Cells[16 + tuple.Item1.Day, 5].Value = "1:00"; } for (int i = 17; i <= 47; i++) @@ -98,7 +98,7 @@ public static class TimesheetIO } worksheet.Cells[48, 6].Formula = "SUM(F17:F47)"; - package.SaveAs(new FileInfo(@$"{filePath}/{month}.xlsx")); + package.SaveAs(new FileInfo(@$"{filePath}/{Constants.MonthsGerman.IndexOf(month):D2} - {month}.xlsx")); } } } diff --git a/LeanderShiftPlannerV2/Service/TimesheetService.cs b/LeanderShiftPlannerV2/Service/TimesheetService.cs index 26942aa..482f027 100644 --- a/LeanderShiftPlannerV2/Service/TimesheetService.cs +++ b/LeanderShiftPlannerV2/Service/TimesheetService.cs @@ -45,21 +45,21 @@ public class TimesheetService ApplicationName = applicationName, }); - foreach (string month in Constants.Months) + foreach (Person person in persons) { - if (month == Constants.Months[0]) continue; - List<(DateTime, DateTime, bool)> timesheetValue = new List<(DateTime, DateTime, bool)>(); - - // Aktuelles Datum - DateTime now = DateTime.Now; - // Erster Tag des aktuellen Monats (00:00:00 Uhr) - DateTime firstDayOfMonth = new DateTime(now.Year, Constants.Months.IndexOf(month), 1, 0, 0, 0); - // Letzter Tag des aktuellen Monats (23:59:59 Uhr) - DateTime lastDayOfMonth = new DateTime(now.Year, Constants.Months.IndexOf(month), DateTime.DaysInMonth(now.Year, Constants.Months.IndexOf(month)), - 23, 59, 59); - - foreach (Person person in persons) + foreach (string month in Constants.Months) { + if (month == Constants.Months[0]) continue; + List<(DateTime, DateTime, bool)> timesheetValue = new List<(DateTime, DateTime, bool)>(); + + // Aktuelles Datum + DateTime now = DateTime.Now; + // Erster Tag des aktuellen Monats (00:00:00 Uhr) + DateTime firstDayOfMonth = new DateTime(now.Year, Constants.Months.IndexOf(month), 1, 0, 0, 0); + // Letzter Tag des aktuellen Monats (23:59:59 Uhr) + DateTime lastDayOfMonth = new DateTime(now.Year, Constants.Months.IndexOf(month), DateTime.DaysInMonth(now.Year, Constants.Months.IndexOf(month)), + 23, 59, 59); + // Beispiel: Liste die nächsten 10 Ereignisse im ITM Kalender auf var requestItm = service.Events.List("on089es7kq4ugi3rqvslkn7720@group.calendar.google.com"); requestItm.TimeMinDateTimeOffset = firstDayOfMonth; @@ -81,7 +81,7 @@ public class TimesheetService { DateTime dayStart = (DateTime) eventItem.Start.DateTime; DateTime dayEnd = (DateTime) eventItem.End.DateTime; - timesheetValue.Add((dayStart, dayEnd, false)); + timesheetValue.Add((dayStart, dayEnd, (dayEnd.Hour > 13))); } } diff --git a/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs b/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs index dc1c72b..779a867 100644 --- a/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs +++ b/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs @@ -131,6 +131,7 @@ public partial class LeanderShiftPlannerMainWindow : Window { ProgressbarCalculaion.IsIndeterminate = true; await _appService.TimesheetService.GenerateGoogleTimeSheets(_appService.PersonService.GetGoogleTimeSheetList()); + await _appService.TimesheetService.GenerateRandomTimeSheets(_appService.PersonService.GetRandomTimeSheetList()); ProgressbarCalculaion.IsIndeterminate = false; int error = TimesheetIO.ExportTimesheets(_appService.PersonService.GetPersonList().ToList());