From 39327b07db05050a2f923d8e475e61cb668d6d4a Mon Sep 17 00:00:00 2001 From: "bryce.coon" Date: Thu, 15 Feb 2024 15:12:36 -0700 Subject: [PATCH] settings and offline works --- MauiTickets/Components/Pages/MauiTicket.razor | 2 +- MauiTickets/Components/Pages/Settings.razor | 2 +- MauiTickets/Services/MauiTicketService.cs | 4 +++- TicketLibrary/Services/generateQRCode.cs | 21 ++++++++++--------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/MauiTickets/Components/Pages/MauiTicket.razor b/MauiTickets/Components/Pages/MauiTicket.razor index 88ab847..9e3bed5 100644 --- a/MauiTickets/Components/Pages/MauiTicket.razor +++ b/MauiTickets/Components/Pages/MauiTicket.razor @@ -22,7 +22,7 @@ //await service.ResetLocalTicketsDB(); - await service.SyncDatabases(); + //await service.SyncDatabases(); StateHasChanged(); } diff --git a/MauiTickets/Components/Pages/Settings.razor b/MauiTickets/Components/Pages/Settings.razor index eedb24b..0ab1641 100644 --- a/MauiTickets/Components/Pages/Settings.razor +++ b/MauiTickets/Components/Pages/Settings.razor @@ -53,7 +53,7 @@ Please input the api that the data should pull from @code { - public bool isOnline; + public bool isOnline = true; public int sFrequency = 15; public string setAPI = ""; public string errorMessage = ""; diff --git a/MauiTickets/Services/MauiTicketService.cs b/MauiTickets/Services/MauiTicketService.cs index 7e349d8..5b88c45 100644 --- a/MauiTickets/Services/MauiTicketService.cs +++ b/MauiTickets/Services/MauiTicketService.cs @@ -116,7 +116,9 @@ private async Task SyncLocalToOnline(List onlineTickets, List lo if ((onlineTickets.FirstOrDefault(q => q.Ticketnumber == ticket.Ticketnumber).IsScanned) != ticket.IsScanned) { //set the online ticket equal to local - await client.PutAsJsonAsync("/api/Ticket/updateticket", ticket); + Ticket tem = ticket; + tem.Id = onlineTickets.FirstOrDefault(q => q.Ticketnumber == ticket.Ticketnumber).Id; + await client.PutAsJsonAsync("/api/Ticket/updateticket", tem); } } } diff --git a/TicketLibrary/Services/generateQRCode.cs b/TicketLibrary/Services/generateQRCode.cs index a409172..e0fb471 100644 --- a/TicketLibrary/Services/generateQRCode.cs +++ b/TicketLibrary/Services/generateQRCode.cs @@ -13,19 +13,20 @@ public static string GenerateQRCodeBase64(string qrCodeText) try { - QRCodeGenerator qrCodeGenerate = new QRCodeGenerator(); - QRCodeData qrCodeData = qrCodeGenerate.CreateQrCode(qrCodeText, QRCodeGenerator.ECCLevel.Q); - QRCode qrCode = new QRCode(qrCodeData); + QRCodeGenerator qrCodeGenerate = new QRCodeGenerator(); + QRCodeData qrCodeData = qrCodeGenerate.CreateQrCode(qrCodeText, QRCodeGenerator.ECCLevel.Q); + QRCode qrCode = new QRCode(qrCodeData); - string appDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - string filePath = Path.Combine(appDataDirectory, "QREmail.png"); + string appDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + string filePath = Path.Combine(appDataDirectory, "QREmail.png"); - using (Bitmap qrBitMap = qrCode.GetGraphic(20)) - { - qrBitMap.Save(filePath, ImageFormat.Png); - } + using (Bitmap qrBitMap = qrCode.GetGraphic(20)) + { + qrBitMap.Save(filePath, ImageFormat.Png); + qrBitMap.Dispose(); + } - return filePath; + return filePath; } catch (Exception ex) {