From e4d3fb2d82a259e08e0d6f6d438d229a3feb08e3 Mon Sep 17 00:00:00 2001 From: DaPi Date: Mon, 14 Oct 2024 09:54:06 +0200 Subject: [PATCH] 1.0.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keine Code-Optimierung verwenden StaticResource "TransparentColor" hinzugefügt --- Jugenddienst Stunden/App.xaml.cs | 69 +------------------ Jugenddienst Stunden/AppShell.xaml.cs | 20 ++++-- .../Converter/IntBoolConverter.cs | 27 ++++++-- .../Jugenddienst Stunden.csproj | 32 +++++++-- Jugenddienst Stunden/MauiProgram.cs | 21 ++++-- Jugenddienst Stunden/Models/Stunde.cs | 22 ++---- .../Platforms/Windows/App.xaml.cs | 10 +-- .../Platforms/Windows/Package.appxmanifest | 4 +- .../Resources/Styles/Colors.xaml | 2 + Jugenddienst Stunden/Types/DayTime.cs | 63 +++++++++++++++++ .../ViewModels/StundenViewModel.cs | 17 +++-- Jugenddienst Stunden/Views/LoginPage.xaml.cs | 1 + Jugenddienst Stunden/Views/StundenPage.xaml | 6 +- .../Views/StundenPage.xaml.cs | 21 +++--- 14 files changed, 183 insertions(+), 132 deletions(-) diff --git a/Jugenddienst Stunden/App.xaml.cs b/Jugenddienst Stunden/App.xaml.cs index a039b4c..7a10127 100644 --- a/Jugenddienst Stunden/App.xaml.cs +++ b/Jugenddienst Stunden/App.xaml.cs @@ -1,6 +1,4 @@ - - -namespace Jugenddienst_Stunden; +namespace Jugenddienst_Stunden; /// /// Die Hauptanwendungsklasse. @@ -13,72 +11,7 @@ public partial class App : Application { public App() { InitializeComponent(); - //UnhandledException: Wird gefangen, wenn eine Ausnahme in einem beliebigen nicht verwalteten Thread außerhalb des individuellen Kontexts auftritt. - AppDomain.CurrentDomain.UnhandledException += (sender, e) => { - if (e.ExceptionObject is Exception ex) { - HandleException(ex); - } - }; - - //UnobservedTaskException: Wird ausgelöst, wenn eine Ausnahme in einem asynchronen Task auftritt und nicht behandelt wird. - TaskScheduler.UnobservedTaskException += (sender, e) => { - HandleException(e.Exception); - e.SetObserved(); - }; - - //Dispatcher: Hilft bei der Handhabung von UI-bezogenen Ausnahmen innerhalb des UI-Threads. - if (Current?.Dispatcher != null) { - Current.Dispatcher.Dispatch(async () => { - try { - // Anwendungscode hier - await Task.CompletedTask; // Dummy await to avoid CS1998 - } catch (Exception ex) { - HandleException(ex); - } - }); - } - MainPage = new AppShell(); } - private void HandleException(Exception ex) { - // Fehlerbehandlungscode - Console.WriteLine($"Globale Ausnahme: {ex?.Message}"); - // Optional: Logging oder Benutzerbenachrichtigung - } - - //protected override Window CreateWindow(IActivationState activationState) => - //new Window(new AppShell()) { - // Width = 500, - // Height = 900 - //}; - - - // protected override Window CreateWindow(IActivationState activationState) { - // Window window = base.CreateWindow(activationState); - // window.Activated += Window_Activated; - // return window; - // } - - // private async void Window_Activated(object sender, EventArgs e) { - //#if WINDOWS - // const int DefaultWidth = 500; - // const int DefaultHeight = 900; - - // var window = sender as Window; - - // // change window size. - // window.Width = DefaultWidth; - // window.Height = DefaultHeight; - - // // give it some time to complete window resizing task. - // await window.Dispatcher.DispatchAsync(() => { }); - - // var disp = DeviceDisplay.Current.MainDisplayInfo; - - // // move to screen center - // //window.X = (disp.Width / disp.Density - window.Width) / 2; - // //window.Y = (disp.Height / disp.Density - window.Height) / 2; - //#endif - // } } diff --git a/Jugenddienst Stunden/AppShell.xaml.cs b/Jugenddienst Stunden/AppShell.xaml.cs index f0fcb2e..f50557b 100644 --- a/Jugenddienst Stunden/AppShell.xaml.cs +++ b/Jugenddienst Stunden/AppShell.xaml.cs @@ -1,10 +1,16 @@ -namespace Jugenddienst_Stunden { - public partial class AppShell : Shell { - public AppShell() { - InitializeComponent(); +namespace Jugenddienst_Stunden; +/// +/// AppShell.xaml.cs +/// +public partial class AppShell : Shell { + /// + /// Initialisiert eine neue Instanz der -Klasse. + /// + public AppShell() { + InitializeComponent(); - Routing.RegisterRoute(nameof(Views.NotePage), typeof(Views.NotePage)); - Routing.RegisterRoute(nameof(Views.StundePage), typeof(Views.StundePage)); - } + //Seiten, die nicht in der Appshell sichtbar sind, aber trotzdem aufgerufen werden können + Routing.RegisterRoute(nameof(Views.NotePage), typeof(Views.NotePage)); + Routing.RegisterRoute(nameof(Views.StundePage), typeof(Views.StundePage)); } } diff --git a/Jugenddienst Stunden/Converter/IntBoolConverter.cs b/Jugenddienst Stunden/Converter/IntBoolConverter.cs index b6c2bbe..7565e43 100644 --- a/Jugenddienst Stunden/Converter/IntBoolConverter.cs +++ b/Jugenddienst Stunden/Converter/IntBoolConverter.cs @@ -1,13 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Globalization; namespace Jugenddienst_Stunden.Converter; +/// +/// Falls ein int als bool dargestellt werden soll +/// public class IntBoolConverter : IValueConverter { + /// + /// Konvertiert einen int in einen bool + /// + /// + /// + /// + /// + /// public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is int) { return (int)value != 0; @@ -15,7 +21,14 @@ public class IntBoolConverter : IValueConverter { return false; } - + /// + /// Konvrertiert einen bool in einen int + /// + /// + /// + /// + /// + /// public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is bool) { return (bool)value ? 1 : 0; diff --git a/Jugenddienst Stunden/Jugenddienst Stunden.csproj b/Jugenddienst Stunden/Jugenddienst Stunden.csproj index df8a87f..5adcc5d 100644 --- a/Jugenddienst Stunden/Jugenddienst Stunden.csproj +++ b/Jugenddienst Stunden/Jugenddienst Stunden.csproj @@ -1,8 +1,7 @@  - net8.0-maccatalyst;net8.0-android - $(TargetFrameworks);net8.0-windows10.0.19041.0 + net8.0-maccatalyst;net8.0-android34.0 @@ -47,19 +46,27 @@ com.companyname.jugenddienststunden 1.0.4 5 + False + True - True + False com.companyname.jugenddienststunden 1.0.4 5 + True com.companyname.jugenddienststunden Xamarin True + False + True + 1.0.4 + 5 + False @@ -71,24 +78,35 @@ 1.0.4 5 $(DefineConstants);DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION + True com.companyname.jugenddienststunden Xamarin - True + False + False + True + 1.0.4 + 5 + False + False + False com.companyname.jugenddienststunden 1.0.4 5 + False + True - $(TargetFrameworks);net8.0-windows10.0.26100.0 True snupkg + AnyCPU + False @@ -113,6 +131,10 @@ 1.0.4 + + $(TargetFrameworks);net8.0-windows10.0.26100.0 + + diff --git a/Jugenddienst Stunden/MauiProgram.cs b/Jugenddienst Stunden/MauiProgram.cs index a31c524..3e5a750 100644 --- a/Jugenddienst Stunden/MauiProgram.cs +++ b/Jugenddienst Stunden/MauiProgram.cs @@ -1,9 +1,10 @@ -using Microsoft.Extensions.Logging; -using Microsoft.Maui.LifecycleEvents; -using ZXing.Net.Maui.Controls; +using ZXing.Net.Maui.Controls; -namespace Jugenddienst_Stunden; +namespace Jugenddienst_Stunden; +/// +/// Das Hauptprogramm. +/// public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); @@ -15,9 +16,19 @@ public static class MauiProgram { }) .UseBarcodeReader(); - + //Preferences.Default.Set("apiKey", "M3xneWlWNG85TmNIcmo1NnpxWkxVYS9JMDBFRlV8aHR0cHM6Ly9zdHVuZGVuLmpkLWxhbmEtdGlzZW5zLml0L2FwcGFwaQ=="); + //Preferences.Default.Set("name", "Default: Lea"); + //Preferences.Default.Set("surname", "Mair"); + //Preferences.Default.Set("EmployeeId", 3); + //Preferences.Default.Set("apiUrl", "https://stunden.jd-lana-tisens.it/appapi"); #if DEBUG + Preferences.Default.Set("apiKey", "M3xneWlWNG85TmNIcmo1NnpxWkxVYS9JMDBFRlV8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"); + Preferences.Default.Set("name", "Testserver: Lea"); + Preferences.Default.Set("surname", "Mair"); + Preferences.Default.Set("EmployeeId", 3); + Preferences.Default.Set("apiUrl", "http://hours.dauni.mine.nu:81/appapi"); + builder.Logging.AddDebug(); #endif diff --git a/Jugenddienst Stunden/Models/Stunde.cs b/Jugenddienst Stunden/Models/Stunde.cs index 13e6484..e3f9a1b 100644 --- a/Jugenddienst Stunden/Models/Stunde.cs +++ b/Jugenddienst Stunden/Models/Stunde.cs @@ -10,28 +10,16 @@ internal class Stunde : ObservableObject { public DateTime Date { get; set; } //Default-Werte zum Testen - public static string apiKey = Preferences.Default.Get("apiKey", "M3xraUdoSktrdGowaUZoaStJbDJLWmIyTFhYeDh8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"); - public static int EmployeeId = Preferences.Default.Get("employeeId", 3); - public static string name = Preferences.Default.Get("name", "Vorname"); - public static string surname = Preferences.Default.Get("surname", "Nachname"); - public static string apiUrl = Preferences.Default.Get("apiUrl", "http://hours.dauni.mine.nu:81/appapi"); + public static string apiKey = Preferences.Default.Get("apiKey", ""); + public static int EmployeeId = Preferences.Default.Get("employeeId", 0); + public static string name = Preferences.Default.Get("name", ""); + public static string surname = Preferences.Default.Get("surname", ""); + public static string apiUrl = Preferences.Default.Get("apiUrl", ""); public static async Task LoadData() { - ////Preferences.Default.Set("apiKey", "NXw5NDdCcEdLMVNDZTRENmphWG02MjlyeFFDenN8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"); - //Preferences.Default.Set("apiKey", "NXw5NDdCcEdLMVNDZTRENmphWG02MjlyeFFDenN8aHR0cHM6Ly9zdHVuZGVuLmpkLWxhbmEtdGlzZW5zLml0L2FwcGFwaQ==");//Online - //Preferences.Default.Set("name", "Johannes"); - //Preferences.Default.Set("surname", "Fink"); - //Preferences.Default.Set("EmployeeId", 5); - ////Preferences.Default.Set("apiUrl", "http://hours.dauni.mine.nu:81/appapi"); - //Preferences.Default.Set("apiUrl", "https://stunden.jd-lana-tisens.it/appapi"); - apiKey = Preferences.Default.Get("apiKey", "NXw5NDdCcEdLMVNDZTRENmphWG02MjlyeFFDenN8aHR0cDovL2hvdXJzLmRhdW5pLm1pbmUubnU6ODEvYXBwYXBp"); - EmployeeId = Preferences.Default.Get("employeeId", 5); - name = Preferences.Default.Get("name", "Johannes"); - surname = Preferences.Default.Get("surname", "Fink"); - apiUrl = Preferences.Default.Get("apiUrl", "http://hours.dauni.mine.nu:81/appapi"); if (string.IsNullOrEmpty(apiKey)) { diff --git a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs index 441d1a0..27a970b 100644 --- a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs +++ b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs @@ -1,8 +1,4 @@ -using Microsoft.Maui.LifecycleEvents; -using Microsoft.UI.Xaml; - - -// To learn more about WinUI, the WinUI project structure, +// To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. namespace Jugenddienst_Stunden.WinUI { @@ -18,6 +14,10 @@ namespace Jugenddienst_Stunden.WinUI { this.InitializeComponent(); } + /// + /// + /// + /// protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); diff --git a/Jugenddienst Stunden/Platforms/Windows/Package.appxmanifest b/Jugenddienst Stunden/Platforms/Windows/Package.appxmanifest index 1f2dd1f..2aca8ac 100644 --- a/Jugenddienst Stunden/Platforms/Windows/Package.appxmanifest +++ b/Jugenddienst Stunden/Platforms/Windows/Package.appxmanifest @@ -12,7 +12,7 @@ $placeholder$ - User Name + Daniel Pichler $placeholder$.png @@ -41,6 +41,8 @@ + + diff --git a/Jugenddienst Stunden/Resources/Styles/Colors.xaml b/Jugenddienst Stunden/Resources/Styles/Colors.xaml index acb22fc..4997e25 100644 --- a/Jugenddienst Stunden/Resources/Styles/Colors.xaml +++ b/Jugenddienst Stunden/Resources/Styles/Colors.xaml @@ -13,6 +13,8 @@ #9880e5 #2B0B98 + Transparent + White Black #D600AA diff --git a/Jugenddienst Stunden/Types/DayTime.cs b/Jugenddienst Stunden/Types/DayTime.cs index 46ec941..c2e20d8 100644 --- a/Jugenddienst Stunden/Types/DayTime.cs +++ b/Jugenddienst Stunden/Types/DayTime.cs @@ -6,24 +6,87 @@ namespace Jugenddienst_Stunden.Types; /// Represents a day time entry for an employee. /// public class DayTime { + /// + /// ID des Stundeneintrages + /// public int? id { get; set; } + + /// + /// Mitarbeiter-ID + /// public int EmployeeId { get; set; } + + /// + /// Der betreffende Tag + /// public DateTime day { get; set; } + + /// + /// Der Wochentag + /// public int wday { get; set; } + + /// + /// Arbeitsbeginn + /// public TimeOnly begin { get; set; } + + /// + /// Arbeitsende + /// public TimeOnly end { get; set; } + + /// + /// Beschreibung der Arbeit + /// public string description { get; set; } + + /// + /// Freistellung + /// public string? free { get; set; } + + /// + /// Freisetellung genehmigt? + /// public bool? approved { get; set; } + + /// + /// Sollte nix sein + /// public int? type { get; set; } + + /// + /// Das gewählte Projekt + /// public int? projekt { get; set; } + + /// + /// Die gewählte Gemeinde + /// public int? gemeinde { get; set; } + + /// + /// Nachtstunden + /// public TimeOnly night { get; set; } + + /// + /// Summe Arbeitszeit (inklusive Nachstunden mit Faktor) + /// public Dictionary total { get; set; } public TimeOnly end_print { get; set; } public TimeSpan TimeSpanVon { get; set; } public TimeSpan TimeSpanBis { get; set; } + + /// + /// Projekte für die Auswahlliste + /// public Collection Projekte { get; set; } + + /// + /// Gemeinden für die Auswahlliste + /// public Collection Gemeinden { get; set; } public Collection Freistellungen { get; set; } diff --git a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs index ff4c165..7d8e8ec 100644 --- a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs +++ b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs @@ -14,12 +14,13 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP public string MoreInfoUrl => "https://aka.ms/maui"; public string Message => "Hier werden deine geleisteten Arbeitsstunden aufgelistet"; public string LoadOverview => "Lade Summen für " + DateTime.Today.ToString("MMMM"); - public static DateTime GetDay = DateTime.Today; + //public static DateTime GetDay = DateTime.Today; //public string ShowDay => "Zeit an Tag " + GetDay.ToString("ddd d. MMM") + ": "; public ICommand NewEntryCommand { get; } public ICommand SelectEntryCommand { get; } public ICommand LoadDataCommand { get; private set; } + public ICommand RefreshListCommand { get; } public event EventHandler AlertEvent; public event EventHandler InfoEvent; @@ -53,14 +54,14 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP /// /// Mindest-Datum für den Datepicker /// - public static DateTime MinimumDate { + public DateTime MinimumDate { get => DateTime.Today.AddDays(-365); } /// /// Höchst-Datum für den Datepicker /// - public static DateTime MaximumDate { + public DateTime MaximumDate { get => DateTime.Today.AddDays(60); } @@ -73,7 +74,7 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP set { if (dateToday != value) { dateToday = value; - GetDay = value; + //GetDay = value; //OnPropertyChanged(); _ = LoadDay(value); } @@ -132,6 +133,8 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP NewEntryCommand = new AsyncRelayCommand(NewEntryAsync); SelectEntryCommand = new AsyncRelayCommand(SelectEntryAsync); + RefreshListCommand = new AsyncRelayCommand(RefreshList); + Task task = LoadDay(DateTime.Today); } @@ -160,6 +163,10 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP } else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten"); } + private async Task RefreshList() { + OnPropertyChanged(nameof(DayTimes)); + } + /// /// Lädt die Monatssummen für die Übersicht /// @@ -200,7 +207,7 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP InfoEvent?.Invoke(this, e.Message); } finally { OnPropertyChanged(nameof(DayTotal)); - OnPropertyChanged(nameof(DayTimes)); + //OnPropertyChanged(nameof(DayTimes)); } } diff --git a/Jugenddienst Stunden/Views/LoginPage.xaml.cs b/Jugenddienst Stunden/Views/LoginPage.xaml.cs index e1541b6..17c64f5 100644 --- a/Jugenddienst Stunden/Views/LoginPage.xaml.cs +++ b/Jugenddienst Stunden/Views/LoginPage.xaml.cs @@ -60,6 +60,7 @@ public partial class LoginPage : ContentPage { Preferences.Default.Set("EmployeeId", int.Parse(op.id)); await DisplayAlert("Login erfolgreich", op.name + " " + op.surname, "OK"); + await Navigation.PopAsync(); } catch (Exception e) { await DisplayAlert("Fehler", e.Message, "OK"); } diff --git a/Jugenddienst Stunden/Views/StundenPage.xaml b/Jugenddienst Stunden/Views/StundenPage.xaml index ebc7702..40dd133 100644 --- a/Jugenddienst Stunden/Views/StundenPage.xaml +++ b/Jugenddienst Stunden/Views/StundenPage.xaml @@ -17,7 +17,9 @@ + + @@ -51,7 +53,7 @@ - + @@ -77,7 +79,7 @@