From f31176cfc9b076328e6c513e02822c7cda84f68b Mon Sep 17 00:00:00 2001 From: zzdrojewskipaw Date: Fri, 28 Nov 2025 15:11:56 +0100 Subject: [PATCH] add job invoice --- BimAI.API/Program.cs | 18 +++++++++++++++--- BimAI.API/appsettings.Development.json | 3 +++ .../Sync/InvoiceSyncService.cs | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/BimAI.API/Program.cs b/BimAI.API/Program.cs index c9ffe1d..1a343bc 100644 --- a/BimAI.API/Program.cs +++ b/BimAI.API/Program.cs @@ -131,9 +131,21 @@ RecurringJob.AddOrUpdate( new RecurringJobOptions { TimeZone = TimeZoneInfo.Local, - MisfireHandling = app.Environment.IsDevelopment() - ? MisfireHandlingMode.Relaxed - : MisfireHandlingMode.Strict + MisfireHandling = app.Environment.IsDevelopment() + ? MisfireHandlingMode.Relaxed + : MisfireHandlingMode.Strict + }); + +RecurringJob.AddOrUpdate( + "invoice-sync", + job => job.ExecuteAsync(), + Cron.Daily(2, 30), // Every day at 2:30 AM + new RecurringJobOptions + { + TimeZone = TimeZoneInfo.Local, + MisfireHandling = app.Environment.IsDevelopment() + ? MisfireHandlingMode.Relaxed + : MisfireHandlingMode.Strict }); app.Run(); \ No newline at end of file diff --git a/BimAI.API/appsettings.Development.json b/BimAI.API/appsettings.Development.json index 2044b0a..f43bf16 100644 --- a/BimAI.API/appsettings.Development.json +++ b/BimAI.API/appsettings.Development.json @@ -6,6 +6,9 @@ "E5_CRM": { "ApiKey": "7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5" }, + "TWINPOL_CRM": { + "ApiKey": "d68dac4c-f784-4e1b-8267-9ffcfa0eda4c" + }, "GoogleAuth": { "ClientId": "896226687615-rhmqk06t1hvll1hh2gtje2u6nbadtras.apps.googleusercontent.com" }, diff --git a/BimAI.Infrastructure/Sync/InvoiceSyncService.cs b/BimAI.Infrastructure/Sync/InvoiceSyncService.cs index f44e6dc..bf7fb11 100644 --- a/BimAI.Infrastructure/Sync/InvoiceSyncService.cs +++ b/BimAI.Infrastructure/Sync/InvoiceSyncService.cs @@ -18,7 +18,7 @@ public class InvoiceSyncService(HttpClient httpClient, BimAIDbContext db, IConfi public async Task RunAsync() { - var apiKey = configuration["E5_CRM:ApiKey"]; + var apiKey = configuration["TWINPOL_CRM:ApiKey"]; var syncState = db.SyncStates.FirstOrDefault(x => x.Entity == "Invoice") ?? new SyncState { Entity = "Invoice", LastSynced = 0 }; var url = $"https://crm.twinpol.com/REST/index.php?key={apiKey}&action=bimai.export.ecommerce&since=0";