From a9b397cbf2e52fc92701bd51510f0e60800df829 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 26 Mar 2025 09:44:57 -0700 Subject: [PATCH 1/5] CU-868d85dv8 .Net 9 upgrade --- Core/Resgrid.Config/Resgrid.Config.csproj | 2 +- Core/Resgrid.Framework/Resgrid.Framework.csproj | 2 +- Core/Resgrid.Localization/Resgrid.Localization.csproj | 2 +- Core/Resgrid.Model/Resgrid.Model.csproj | 2 +- Core/Resgrid.Services/Resgrid.Services.csproj | 2 +- .../Resgrid.Providers.AddressVerification.csproj | 2 +- .../Resgrid.Providers.Bus.Rabbit.csproj | 2 +- Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj | 2 +- .../Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj | 4 ++-- .../Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj | 2 +- .../Resgrid.Providers.Email/Resgrid.Providers.Email.csproj | 2 +- .../Resgrid.Providers.Firebase.csproj | 2 +- Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj | 2 +- .../Resgrid.Providers.Marketing.csproj | 2 +- .../Resgrid.Providers.Messaging.csproj | 2 +- .../Resgrid.Providers.Migrations.csproj | 2 +- .../Resgrid.Providers.MigrationsPg.csproj | 2 +- .../Resgrid.Providers.Number/Resgrid.Providers.Number.csproj | 2 +- Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj | 2 +- .../Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj | 2 +- .../Resgrid.Repositories.DataRepository.csproj | 3 +-- .../Resgrid.Repositories.NoSqlRepository.csproj | 2 +- .../Resgrid.Intergration.Tests.csproj | 2 +- Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj | 2 +- Tests/Resgrid.Tests/Resgrid.Tests.csproj | 2 +- Tools/Resgrid.Console/Resgrid.Console.csproj | 2 +- Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj | 2 +- Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj | 2 +- Web/Resgrid.Web/Resgrid.Web.csproj | 2 +- .../Resgrid.Workers.Console/Resgrid.Workers.Console.csproj | 2 +- .../Resgrid.Workers.Framework.csproj | 2 +- 31 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Core/Resgrid.Config/Resgrid.Config.csproj b/Core/Resgrid.Config/Resgrid.Config.csproj index 20915db6..0ba4ca4b 100644 --- a/Core/Resgrid.Config/Resgrid.Config.csproj +++ b/Core/Resgrid.Config/Resgrid.Config.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Core/Resgrid.Framework/Resgrid.Framework.csproj b/Core/Resgrid.Framework/Resgrid.Framework.csproj index b16b5eae..064ca67c 100644 --- a/Core/Resgrid.Framework/Resgrid.Framework.csproj +++ b/Core/Resgrid.Framework/Resgrid.Framework.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Resgrid.Framework Resgrid, LLC Resgrid OSS CAD diff --git a/Core/Resgrid.Localization/Resgrid.Localization.csproj b/Core/Resgrid.Localization/Resgrid.Localization.csproj index 17955591..6acbe5a2 100644 --- a/Core/Resgrid.Localization/Resgrid.Localization.csproj +++ b/Core/Resgrid.Localization/Resgrid.Localization.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 enable diff --git a/Core/Resgrid.Model/Resgrid.Model.csproj b/Core/Resgrid.Model/Resgrid.Model.csproj index cff27a58..ae477f2f 100644 --- a/Core/Resgrid.Model/Resgrid.Model.csproj +++ b/Core/Resgrid.Model/Resgrid.Model.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Core/Resgrid.Services/Resgrid.Services.csproj b/Core/Resgrid.Services/Resgrid.Services.csproj index ab00c895..5c8fb534 100644 --- a/Core/Resgrid.Services/Resgrid.Services.csproj +++ b/Core/Resgrid.Services/Resgrid.Services.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj b/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj index 7efc8da8..a1b58f4e 100644 --- a/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj +++ b/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj b/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj index 83162117..4ceb4c63 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj +++ b/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj b/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj index 7c148d5a..017db87b 100644 --- a/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj +++ b/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj b/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj index d9f20e4d..cef0df72 100644 --- a/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj +++ b/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj @@ -1,11 +1,11 @@  - net8.0 + net9.0 Debug;Release;Docker - + diff --git a/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj b/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj index 28ed2d2d..cab39160 100644 --- a/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj +++ b/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj b/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj index 94755008..25b0c1cc 100644 --- a/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj +++ b/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj b/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj index e82b994d..3ac37b82 100644 --- a/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj +++ b/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj b/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj index 6a167e4e..cfc78a1b 100644 --- a/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj +++ b/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj b/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj index 62db398b..53462b19 100644 --- a/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj +++ b/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj b/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj index c284dcb1..b7bc6d57 100644 --- a/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj +++ b/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj b/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj index f518ee09..8b5b50b9 100644 --- a/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj +++ b/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj index 2160d81e..c684d2d5 100644 --- a/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj +++ b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable diff --git a/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj b/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj index f5cc7e20..13ba23c4 100644 --- a/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj +++ b/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj b/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj index 3e4265d6..a4b3c94c 100644 --- a/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj +++ b/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 Debug;Release;Docker diff --git a/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj b/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj index 5034eed8..8f44f1ca 100644 --- a/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj +++ b/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj index ae338af3..fe75ad46 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj +++ b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker @@ -11,7 +11,6 @@ - diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj index a863fc25..b752b6bb 100644 --- a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 enable diff --git a/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj b/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj index ade6ea08..0a740a87 100644 --- a/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj +++ b/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj b/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj index f3b6a52e..cdc2c115 100644 --- a/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj +++ b/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Tests/Resgrid.Tests/Resgrid.Tests.csproj b/Tests/Resgrid.Tests/Resgrid.Tests.csproj index e5f24017..c0be48d6 100644 --- a/Tests/Resgrid.Tests/Resgrid.Tests.csproj +++ b/Tests/Resgrid.Tests/Resgrid.Tests.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker diff --git a/Tools/Resgrid.Console/Resgrid.Console.csproj b/Tools/Resgrid.Console/Resgrid.Console.csproj index 42c841e5..b4c70d44 100644 --- a/Tools/Resgrid.Console/Resgrid.Console.csproj +++ b/Tools/Resgrid.Console/Resgrid.Console.csproj @@ -1,7 +1,7 @@  Exe - net8.0 + net9.0 Resgrid.Console.Program Debug;Release;Docker diff --git a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj index d2420846..50fa419f 100644 --- a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj +++ b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 ea3d8c28-8f81-4777-a7d5-3ffe5fd66f69 Linux ..\.. diff --git a/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj b/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj index 437f5733..82db959f 100644 --- a/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj +++ b/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj @@ -3,7 +3,7 @@ Cloud system for First Responders 3.0.0 Resgrid, LLC. - net8.0 + net9.0 Resgrid.Web.Services Resgrid.Web.Services e5e5edd9-c59d-4c0f-b765-477c9c5350f8 diff --git a/Web/Resgrid.Web/Resgrid.Web.csproj b/Web/Resgrid.Web/Resgrid.Web.csproj index 242c58ed..32c53cb3 100644 --- a/Web/Resgrid.Web/Resgrid.Web.csproj +++ b/Web/Resgrid.Web/Resgrid.Web.csproj @@ -3,7 +3,7 @@ Cloud system for First Responders 3.0.0 Resgrid, LLC. - net8.0 + net9.0 Resgrid.Web aspnet-Resgrid.WebCore-6372c5f2-c359-4243-b5a9-1fc7a5aaeb3b Debug;Release;Azure;Docker diff --git a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj index 8cc723b0..468fcd81 100644 --- a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj +++ b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj @@ -1,7 +1,7 @@  Exe - net8.0 + net9.0 Linux ..\.. Debug;Release;Docker diff --git a/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj b/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj index adf489df..75f5db20 100644 --- a/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj +++ b/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj @@ -1,6 +1,6 @@  - net8.0 + net9.0 Debug;Release;Docker From 39cb4ddbb47bc5821da3f426f00eae61c80b4489 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 26 Mar 2025 14:50:04 -0700 Subject: [PATCH 2/5] CU-868d85dv8 Updated deps --- .../Resgrid.Framework.csproj | 14 +- .../Providers/IRabbitOutboundQueueProvider.cs | 21 +-- .../Repositories/IMongoRepository.cs | 2 +- Core/Resgrid.Model/Resgrid.Model.csproj | 12 +- Core/Resgrid.Model/Services/IHealthService.cs | 2 +- Core/Resgrid.Services/HealthService.cs | 4 +- Core/Resgrid.Services/Resgrid.Services.csproj | 8 +- ...sgrid.Providers.AddressVerification.csproj | 4 +- .../RabbitConnection.cs | 100 ++++++----- .../RabbitInboundEventProvider.cs | 23 +-- .../RabbitInboundQueueProvider.cs | 161 +++++++++--------- .../RabbitOutboundQueueProvider.cs | 62 +++---- .../RabbitTopicProvider.cs | 53 +++--- .../Resgrid.Providers.Bus.Rabbit.csproj | 4 +- .../OutboundQueueProvider.cs | 14 +- .../Resgrid.Providers.Bus.csproj | 6 +- .../Resgrid.Providers.Cache.csproj | 2 +- .../Resgrid.Providers.Claims.csproj | 6 +- .../Resgrid.Providers.Email.csproj | 8 +- .../Resgrid.Providers.Firebase.csproj | 4 +- .../Resgrid.Providers.Geo.csproj | 6 +- .../Resgrid.Providers.Marketing.csproj | 4 +- .../Resgrid.Providers.Messaging.csproj | 4 +- .../Resgrid.Providers.Migrations.csproj | 6 +- .../Resgrid.Providers.MigrationsPg.csproj | 10 +- .../Resgrid.Providers.Number.csproj | 8 +- .../Resgrid.Providers.Pdf.csproj | 4 +- .../Resgrid.Providers.Voip.csproj | 12 +- ...Resgrid.Repositories.DataRepository.csproj | 10 +- .../MongoRepository.cs | 2 +- ...esgrid.Repositories.NoSqlRepository.csproj | 6 +- .../Resgrid.Intergration.Tests.csproj | 4 +- .../Resgrid.SmokeTests.csproj | 4 +- .../Framework/RandomGeneratorTests.cs | 4 +- Tests/Resgrid.Tests/Resgrid.Tests.csproj | 8 +- Tools/Resgrid.Console/Resgrid.Console.csproj | 28 +-- Web/Resgrid.Web.Eventing/Dockerfile | 4 +- Web/Resgrid.Web.Eventing/Program.cs | 4 +- .../Resgrid.Web.Eventing.csproj | 48 +++--- Web/Resgrid.Web.Services/Dockerfile | 4 +- .../Middleware/SentryEventProcessor.cs | 2 +- Web/Resgrid.Web.Services/Program.cs | 4 +- .../Resgrid.Web.Services.csproj | 133 ++++++++------- Web/Resgrid.Web/Dockerfile | 4 +- .../Middleware/SentryEventProcessor.cs | 2 +- Web/Resgrid.Web/Program.cs | 4 +- Web/Resgrid.Web/Resgrid.Web.csproj | 115 ++++++------- Workers/Resgrid.Workers.Console/Dockerfile | 4 +- .../Resgrid.Workers.Console.csproj | 20 +-- .../Helpers/TraceHelper.cs | 60 +++---- .../Resgrid.Workers.Framework.csproj | 2 +- .../Quidjibo.Postgres.csproj | 2 +- 52 files changed, 534 insertions(+), 508 deletions(-) diff --git a/Core/Resgrid.Framework/Resgrid.Framework.csproj b/Core/Resgrid.Framework/Resgrid.Framework.csproj index 064ca67c..d738df3e 100644 --- a/Core/Resgrid.Framework/Resgrid.Framework.csproj +++ b/Core/Resgrid.Framework/Resgrid.Framework.csproj @@ -12,14 +12,14 @@ - - - - - - + + + + + + - + diff --git a/Core/Resgrid.Model/Providers/IRabbitOutboundQueueProvider.cs b/Core/Resgrid.Model/Providers/IRabbitOutboundQueueProvider.cs index a89f1677..4361e294 100644 --- a/Core/Resgrid.Model/Providers/IRabbitOutboundQueueProvider.cs +++ b/Core/Resgrid.Model/Providers/IRabbitOutboundQueueProvider.cs @@ -1,19 +1,20 @@ using Resgrid.Model.Events; using Resgrid.Model.Queue; +using System.Threading.Tasks; namespace Resgrid.Model.Providers { public interface IRabbitOutboundQueueProvider { - bool EnqueueCall(CallQueueItem callQueue); - bool EnqueueMessage(MessageQueueItem messageQueue); - bool EnqueueDistributionList(DistributionListQueueItem distributionListQueue); - bool EnqueueNotification(NotificationItem notificationQueue); - bool EnqueueShiftNotification(ShiftQueueItem shiftQueueItem); - bool EnqueueCqrsEvent(CqrsEvent cqrsEvent); - bool EnqueueAuditEvent(AuditEvent auditEvent); - bool EnqueueUnitLocationEvent(UnitLocationEvent unitLocationEvent); - bool EnqueuePersonnelLocationEvent(PersonnelLocationEvent personnelLocationEvent); - bool VerifyAndCreateClients(); + Task EnqueueCall(CallQueueItem callQueue); + Task EnqueueMessage(MessageQueueItem messageQueue); + Task EnqueueDistributionList(DistributionListQueueItem distributionListQueue); + Task EnqueueNotification(NotificationItem notificationQueue); + Task EnqueueShiftNotification(ShiftQueueItem shiftQueueItem); + Task EnqueueCqrsEvent(CqrsEvent cqrsEvent); + Task EnqueueAuditEvent(AuditEvent auditEvent); + Task EnqueueUnitLocationEvent(UnitLocationEvent unitLocationEvent); + Task EnqueuePersonnelLocationEvent(PersonnelLocationEvent personnelLocationEvent); + Task VerifyAndCreateClients(); } } diff --git a/Core/Resgrid.Model/Repositories/IMongoRepository.cs b/Core/Resgrid.Model/Repositories/IMongoRepository.cs index 870da80b..241b031b 100644 --- a/Core/Resgrid.Model/Repositories/IMongoRepository.cs +++ b/Core/Resgrid.Model/Repositories/IMongoRepository.cs @@ -13,7 +13,7 @@ public interface IMongoRepository where TDocument : INoSqlDocument { IMongoCollection GetCollection(); - IMongoQueryable AsQueryable(); + IQueryable AsQueryable(); IEnumerable FilterBy( Expression> filterExpression); diff --git a/Core/Resgrid.Model/Resgrid.Model.csproj b/Core/Resgrid.Model/Resgrid.Model.csproj index ae477f2f..c5432d59 100644 --- a/Core/Resgrid.Model/Resgrid.Model.csproj +++ b/Core/Resgrid.Model/Resgrid.Model.csproj @@ -79,12 +79,12 @@ - - - - - - + + + + + + diff --git a/Core/Resgrid.Model/Services/IHealthService.cs b/Core/Resgrid.Model/Services/IHealthService.cs index 2e8faa76..fc028645 100644 --- a/Core/Resgrid.Model/Services/IHealthService.cs +++ b/Core/Resgrid.Model/Services/IHealthService.cs @@ -7,6 +7,6 @@ public interface IHealthService Task GetDatabaseTimestamp(); bool IsCacheProviderConnected(); - bool IsServiceBusProviderConnected(); + Task IsServiceBusProviderConnected(); } } diff --git a/Core/Resgrid.Services/HealthService.cs b/Core/Resgrid.Services/HealthService.cs index 75bfae27..4ea36de3 100644 --- a/Core/Resgrid.Services/HealthService.cs +++ b/Core/Resgrid.Services/HealthService.cs @@ -28,9 +28,9 @@ public bool IsCacheProviderConnected() return _cacheProvider.IsConnected(); } - public bool IsServiceBusProviderConnected() + public async Task IsServiceBusProviderConnected() { - return _rabbitOutboundQueueProvider.VerifyAndCreateClients(); + return await _rabbitOutboundQueueProvider.VerifyAndCreateClients(); } } } diff --git a/Core/Resgrid.Services/Resgrid.Services.csproj b/Core/Resgrid.Services/Resgrid.Services.csproj index 5c8fb534..8173d1f4 100644 --- a/Core/Resgrid.Services/Resgrid.Services.csproj +++ b/Core/Resgrid.Services/Resgrid.Services.csproj @@ -7,11 +7,11 @@ - + - - - + + + diff --git a/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj b/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj index a1b58f4e..587cd513 100644 --- a/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj +++ b/Providers/Resgrid.Providers.AddressVerification/Resgrid.Providers.AddressVerification.csproj @@ -4,8 +4,8 @@ Debug;Release;Docker - - + + diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs index 1e8d7f71..63b64d76 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs @@ -2,6 +2,8 @@ using Resgrid.Config; using Resgrid.Framework; using System; +using System.Threading; +using System.Threading.Tasks; namespace Resgrid.Providers.Bus.Rabbit { @@ -9,10 +11,10 @@ internal class RabbitConnection { private static IConnection _connection { get; set; } private static ConnectionFactory _factory { get; set; } - private readonly static object LOCK = new object(); + private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); - public static bool VerifyAndCreateClients(string clientName) + public static async Task VerifyAndCreateClients(string clientName) { if (_connection != null && !_connection.IsOpen) { @@ -20,122 +22,130 @@ public static bool VerifyAndCreateClients(string clientName) _connection = null; _factory = null; } - + if (_connection == null) { - lock (LOCK) + await _semaphore.WaitAsync(); + + try { - try - { - _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; - _connection = _factory.CreateConnection(clientName); - } - catch (Exception ex) - { - Logging.LogException(ex); + _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; + _connection = await _factory.CreateConnectionAsync(clientName); + } + catch (Exception ex) + { + Logging.LogException(ex); - if (!String.IsNullOrWhiteSpace(ServiceBusConfig.RabbitHostname2)) + if (!String.IsNullOrWhiteSpace(ServiceBusConfig.RabbitHostname2)) + { + try { - try - { - _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname2, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; - _connection = _factory.CreateConnection(clientName); - } - catch (Exception ex2) - { - Logging.LogException(ex2); + _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname2, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; + _connection = await _factory.CreateConnectionAsync(clientName); + } + catch (Exception ex2) + { + Logging.LogException(ex2); - if (!String.IsNullOrWhiteSpace(ServiceBusConfig.RabbitHostname3)) + if (!String.IsNullOrWhiteSpace(ServiceBusConfig.RabbitHostname3)) + { + try + { + _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname3, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; + _connection = await _factory.CreateConnectionAsync(clientName); + } + catch (Exception ex3) { - try - { - _factory = new ConnectionFactory() { HostName = ServiceBusConfig.RabbitHostname3, UserName = ServiceBusConfig.RabbitUsername, Password = ServiceBusConfig.RabbbitPassword }; - _connection = _factory.CreateConnection(clientName); - } - catch (Exception ex3) - { - Logging.LogException(ex3); - throw; - } + Logging.LogException(ex3); + throw; } } } + finally + { + _semaphore.Release(); + } } } + finally + { + _semaphore.Release(); + } + if (_connection != null) { try { - var channel = _connection.CreateModel(); + var channel = await _connection.CreateChannelAsync(); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.SystemQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.SystemQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.CallBroadcastQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.CallBroadcastQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.MessageBroadcastQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.MessageBroadcastQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.EmailBroadcastQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.EmailBroadcastQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.NotificaitonBroadcastQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.NotificaitonBroadcastQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.ShiftNotificationsQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.ShiftNotificationsQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.PaymentQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.PaymentQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.AuditQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.AuditQueueName), durable: true, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.UnitLoactionQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.UnitLoactionQueueName), durable: false, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.PersonnelLoactionQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.PersonnelLoactionQueueName), durable: false, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(Topics.EventingTopic), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(Topics.EventingTopic), durable: false, exclusive: false, autoDelete: false, arguments: null); - channel.QueueDeclare(queue: SetQueueNameForEnv(ServiceBusConfig.SecurityRefreshQueueName), + await channel.QueueDeclareAsync(queue: SetQueueNameForEnv(ServiceBusConfig.SecurityRefreshQueueName), durable: false, exclusive: false, autoDelete: false, diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundEventProvider.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundEventProvider.cs index d099bf8c..8ad1ea6a 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundEventProvider.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundEventProvider.cs @@ -17,7 +17,7 @@ namespace Resgrid.Providers.Bus.Rabbit public class RabbitInboundEventProvider : IRabbitInboundEventProvider { private IConnection _connection; - private IModel _channel; + private IChannel _channel; public Func ProcessPersonnelStatusChanged; public Func ProcessUnitStatusChanged; @@ -30,11 +30,11 @@ public class RabbitInboundEventProvider : IRabbitInboundEventProvider public async Task Start(string clientName, string queueName) { - VerifyAndCreateClients(clientName); + await VerifyAndCreateClients(clientName); await StartMonitoring(queueName); } - private void VerifyAndCreateClients(string clientName) + private async Task VerifyAndCreateClients(string clientName) { try { @@ -42,33 +42,36 @@ private void VerifyAndCreateClients(string clientName) if (_connection != null) { - _channel = _connection.CreateModel(); + _channel = await _connection.CreateChannelAsync(); if (_channel != null) { - _channel.ExchangeDeclare(RabbitConnection.SetQueueNameForEnv(Topics.EventingTopic), "fanout"); + await _channel.ExchangeDeclareAsync(RabbitConnection.SetQueueNameForEnv(Topics.EventingTopic), "fanout"); } } } catch (Exception ex) { Framework.Logging.LogException(ex); + return false; } + + return true; } private async Task StartMonitoring(string queueName) { //var queueName = _channel.QueueDeclare().QueueName; - var queue = _channel.QueueDeclare(RabbitConnection.SetQueueNameForEnv(queueName), durable: true, + var queue = await _channel.QueueDeclareAsync(RabbitConnection.SetQueueNameForEnv(queueName), durable: true, autoDelete: false, exclusive: false); - _channel.QueueBind(queue: queue.QueueName, + await _channel.QueueBindAsync(queue: queue.QueueName, exchange: RabbitConnection.SetQueueNameForEnv(Topics.EventingTopic), routingKey: ""); - var consumer = new EventingBasicConsumer(_channel); - consumer.Received += async (model, ea) => + var consumer = new AsyncEventingBasicConsumer(_channel); + consumer.ReceivedAsync += async (model, ea) => { var body = ea.Body.ToArray(); var message = Encoding.UTF8.GetString(body); @@ -116,7 +119,7 @@ private async Task StartMonitoring(string queueName) } } }; - _channel.BasicConsume(queue: queue.QueueName, + await _channel.BasicConsumeAsync(queue: queue.QueueName, autoAck: true, consumer: consumer); } diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs index 719a3635..bbff8f4c 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitInboundQueueProvider.cs @@ -15,7 +15,7 @@ namespace Resgrid.Providers.Bus.Rabbit public class RabbitInboundQueueProvider { private string _clientName; - private IModel _channel; + private IChannel _channel; public Func CallQueueReceived; public Func MessageQueueReceived; public Func DistributionListQueueReceived; @@ -40,7 +40,7 @@ public async Task Start(string clientName) if (connection != null) { - _channel = connection.CreateModel(); + _channel = await connection.CreateChannelAsync(); await StartMonitoring(); } } @@ -51,8 +51,8 @@ private async Task StartMonitoring() { if (CallQueueReceived != null) { - var callQueueReceivedConsumer = new EventingBasicConsumer(_channel); - callQueueReceivedConsumer.Received += async (model, ea) => + var callQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + callQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -65,7 +65,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -76,22 +76,22 @@ private async Task StartMonitoring() if (CallQueueReceived != null) { await CallQueueReceived.Invoke(cqi); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicNack(ea.DeliveryTag, false, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String callQueueReceivedConsumerTag = _channel.BasicConsume( + String callQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.CallBroadcastQueueName), autoAck: false, consumer: callQueueReceivedConsumer); @@ -99,8 +99,8 @@ private async Task StartMonitoring() if (MessageQueueReceived != null) { - var messageQueueReceivedConsumer = new EventingBasicConsumer(_channel); - messageQueueReceivedConsumer.Received += async (model, ea) => + var messageQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + messageQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -113,7 +113,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -124,22 +124,22 @@ private async Task StartMonitoring() if (MessageQueueReceived != null) { await MessageQueueReceived.Invoke(mqi); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String messageQueueReceivedConsumerTag = _channel.BasicConsume( + String messageQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.MessageBroadcastQueueName), autoAck: false, consumer: messageQueueReceivedConsumer); @@ -147,8 +147,8 @@ private async Task StartMonitoring() if (DistributionListQueueReceived != null) { - var distributionListQueueReceivedConsumer = new EventingBasicConsumer(_channel); - distributionListQueueReceivedConsumer.Received += async (model, ea) => + var distributionListQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + distributionListQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -161,7 +161,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -172,22 +172,22 @@ private async Task StartMonitoring() if (DistributionListQueueReceived != null) { await DistributionListQueueReceived.Invoke(dlqi); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String distributionListQueueReceivedConsumerTag = _channel.BasicConsume( + String distributionListQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.EmailBroadcastQueueName), autoAck: false, consumer: distributionListQueueReceivedConsumer); @@ -195,8 +195,8 @@ private async Task StartMonitoring() if (NotificationQueueReceived != null) { - var notificationQueueReceivedConsumer = new EventingBasicConsumer(_channel); - notificationQueueReceivedConsumer.Received += async (model, ea) => + var notificationQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + notificationQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -209,7 +209,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -220,22 +220,22 @@ private async Task StartMonitoring() if (NotificationQueueReceived != null) { await NotificationQueueReceived.Invoke(ni); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String notificationQueueReceivedConsumerTag = _channel.BasicConsume( + String notificationQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.NotificaitonBroadcastQueueName), autoAck: false, consumer: notificationQueueReceivedConsumer); @@ -243,8 +243,8 @@ private async Task StartMonitoring() if (ShiftNotificationQueueReceived != null) { - var shiftNotificationQueueReceivedConsumer = new EventingBasicConsumer(_channel); - shiftNotificationQueueReceivedConsumer.Received += async (model, ea) => + var shiftNotificationQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + shiftNotificationQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -257,7 +257,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -269,22 +269,22 @@ private async Task StartMonitoring() if (ShiftNotificationQueueReceived != null) { await ShiftNotificationQueueReceived.Invoke(sqi); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String shiftNotificationQueueReceivedConsumerTag = _channel.BasicConsume( + String shiftNotificationQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.ShiftNotificationsQueueName), autoAck: false, consumer: shiftNotificationQueueReceivedConsumer); @@ -292,8 +292,8 @@ private async Task StartMonitoring() if (CqrsEventQueueReceived != null) { - var cqrsEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); - cqrsEventQueueReceivedConsumer.Received += async (model, ea) => + var cqrsEventQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + cqrsEventQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -306,7 +306,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -317,22 +317,22 @@ private async Task StartMonitoring() if (CqrsEventQueueReceived != null) { await CqrsEventQueueReceived.Invoke(cqrs); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String cqrsEventQueueReceivedConsumerTag = _channel.BasicConsume( + String cqrsEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.SystemQueueName), autoAck: false, consumer: cqrsEventQueueReceivedConsumer); @@ -340,8 +340,8 @@ private async Task StartMonitoring() if (PaymentEventQueueReceived != null) { - var paymentEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); - paymentEventQueueReceivedConsumer.Received += async (model, ea) => + var paymentEventQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + paymentEventQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -354,7 +354,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -365,22 +365,22 @@ private async Task StartMonitoring() if (PaymentEventQueueReceived != null) { await PaymentEventQueueReceived.Invoke(cqrs); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String paymentEventQueueReceivedConsumerTag = _channel.BasicConsume( + String paymentEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.PaymentQueueName), autoAck: false, consumer: paymentEventQueueReceivedConsumer); @@ -388,8 +388,8 @@ private async Task StartMonitoring() if (AuditEventQueueReceived != null) { - var auditEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); - auditEventQueueReceivedConsumer.Received += async (model, ea) => + var auditEventQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + auditEventQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -402,7 +402,7 @@ private async Task StartMonitoring() } catch (Exception ex) { - _channel.BasicNack(ea.DeliveryTag, false, false); + await _channel.BasicNackAsync(ea.DeliveryTag, false, false); Logging.LogException(ex, Encoding.UTF8.GetString(ea.Body.ToArray())); } @@ -413,22 +413,22 @@ private async Task StartMonitoring() if (AuditEventQueueReceived != null) { await AuditEventQueueReceived.Invoke(audit); - _channel.BasicAck(ea.DeliveryTag, false); + await _channel.BasicAckAsync(ea.DeliveryTag, false); } } } catch (Exception ex) { Logging.LogException(ex); - if (RetryQueueItem(ea, ex)) - _channel.BasicAck(ea.DeliveryTag, false); + if (await RetryQueueItem(ea, ex)) + await _channel.BasicAckAsync(ea.DeliveryTag, false); else - _channel.BasicNack(ea.DeliveryTag, false, true); + await _channel.BasicNackAsync(ea.DeliveryTag, false, true); } } }; - String auditEventQueueReceivedConsumerTag = _channel.BasicConsume( + String auditEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.AuditQueueName), autoAck: false, consumer: auditEventQueueReceivedConsumer); @@ -436,8 +436,8 @@ private async Task StartMonitoring() if (UnitLocationEventQueueReceived != null) { - var unitLocationQueueReceivedConsumer = new EventingBasicConsumer(_channel); - unitLocationQueueReceivedConsumer.Received += async (model, ea) => + var unitLocationQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + unitLocationQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -470,7 +470,7 @@ private async Task StartMonitoring() } }; - String unitLocationEventQueueReceivedConsumerTag = _channel.BasicConsume( + String unitLocationEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.UnitLoactionQueueName), autoAck: true, consumer: unitLocationQueueReceivedConsumer); @@ -478,8 +478,8 @@ private async Task StartMonitoring() if (PersonnelLocationEventQueueReceived != null) { - var personnelLocationQueueReceivedConsumer = new EventingBasicConsumer(_channel); - personnelLocationQueueReceivedConsumer.Received += async (model, ea) => + var personnelLocationQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + personnelLocationQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -512,7 +512,7 @@ private async Task StartMonitoring() } }; - String personnelLocationEventQueueReceivedConsumerTag = _channel.BasicConsume( + String personnelLocationEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.PersonnelLoactionQueueName), autoAck: true, consumer: personnelLocationQueueReceivedConsumer); @@ -520,8 +520,8 @@ private async Task StartMonitoring() if (SecurityRefreshEventQueueReceived != null) { - var securityRefreshEventQueueReceivedConsumer = new EventingBasicConsumer(_channel); - securityRefreshEventQueueReceivedConsumer.Received += async (model, ea) => + var securityRefreshEventQueueReceivedConsumer = new AsyncEventingBasicConsumer(_channel); + securityRefreshEventQueueReceivedConsumer.ReceivedAsync += async (model, ea) => { if (ea != null && ea.Body.Length > 0) { @@ -554,7 +554,7 @@ private async Task StartMonitoring() } }; - String securityRefreshEventQueueReceivedConsumerTag = _channel.BasicConsume( + String securityRefreshEventQueueReceivedConsumerTag = await _channel.BasicConsumeAsync( queue: RabbitConnection.SetQueueNameForEnv(ServiceBusConfig.SecurityRefreshQueueName), autoAck: true, consumer: securityRefreshEventQueueReceivedConsumer); @@ -570,7 +570,7 @@ public bool IsConnected() return _channel.IsOpen; } - private bool RetryQueueItem(BasicDeliverEventArgs ea, Exception mex) + private async Task RetryQueueItem(BasicDeliverEventArgs ea, Exception mex) { try { @@ -589,10 +589,10 @@ private bool RetryQueueItem(BasicDeliverEventArgs ea, Exception mex) var connection = RabbitConnection.CreateConnection(_clientName); if (connection != null) { - using (var channel = connection.CreateModel()) + using (var channel = await connection.CreateChannelAsync()) { - IBasicProperties props = channel.CreateBasicProperties(); - props.DeliveryMode = 2; + var props = new BasicProperties(); + props.DeliveryMode = DeliveryModes.Persistent; // I *THINK* these headers are appearing in the body when trying to deserialze and it's blowing up protobuf. -SJ //props.Expiration = "36000000"; @@ -603,8 +603,9 @@ private bool RetryQueueItem(BasicDeliverEventArgs ea, Exception mex) // https://github.com/rabbitmq/rabbitmq-delayed-message-exchange //props.Headers.Add("x-delay", 5000); - channel.BasicPublish(exchange: ea.Exchange, + await channel.BasicPublishAsync(exchange: ea.Exchange, routingKey: ea.RoutingKey, + mandatory: true, basicProperties: props, body: ea.Body); } diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitOutboundQueueProvider.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitOutboundQueueProvider.cs index 76183dc5..e589e5ac 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitOutboundQueueProvider.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitOutboundQueueProvider.cs @@ -8,6 +8,7 @@ using Resgrid.Model.Providers; using System.Collections.Generic; using Resgrid.Model.Events; +using System.Threading.Tasks; namespace Resgrid.Providers.Bus.Rabbit { @@ -15,91 +16,91 @@ public class RabbitOutboundQueueProvider : IRabbitOutboundQueueProvider { private readonly string _clientName = "Resgrid-Outbound"; - public bool EnqueueCall(CallQueueItem callQueue) + public async Task EnqueueCall(CallQueueItem callQueue) { string serializedObject = ObjectSerialization.Serialize(callQueue); - return SendMessage(ServiceBusConfig.CallBroadcastQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.CallBroadcastQueueName, serializedObject); } - public bool EnqueueMessage(MessageQueueItem messageQueue) + public async Task EnqueueMessage(MessageQueueItem messageQueue) { string serializedObject = ObjectSerialization.Serialize(messageQueue); if (messageQueue != null && messageQueue.Message != null && messageQueue.MessageId == 0 && messageQueue.Message.MessageId != 0) messageQueue.MessageId = messageQueue.Message.MessageId; - return SendMessage(ServiceBusConfig.MessageBroadcastQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.MessageBroadcastQueueName, serializedObject); } - public bool EnqueueDistributionList(DistributionListQueueItem distributionListQueue) + public async Task EnqueueDistributionList(DistributionListQueueItem distributionListQueue) { string serializedObject = ObjectSerialization.Serialize(distributionListQueue); - return SendMessage(ServiceBusConfig.EmailBroadcastQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.EmailBroadcastQueueName, serializedObject); } - public bool EnqueueNotification(NotificationItem notificationQueue) + public async Task EnqueueNotification(NotificationItem notificationQueue) { string serializedObject = String.Empty; serializedObject = ObjectSerialization.Serialize(notificationQueue); - return SendMessage(ServiceBusConfig.NotificaitonBroadcastQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.NotificaitonBroadcastQueueName, serializedObject); } - public bool EnqueueShiftNotification(ShiftQueueItem shiftQueueItem) + public async Task EnqueueShiftNotification(ShiftQueueItem shiftQueueItem) { string serializedObject = String.Empty; serializedObject = ObjectSerialization.Serialize(shiftQueueItem); - return SendMessage(ServiceBusConfig.ShiftNotificationsQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.ShiftNotificationsQueueName, serializedObject); } - public bool EnqueueCqrsEvent(CqrsEvent cqrsEvent) + public async Task EnqueueCqrsEvent(CqrsEvent cqrsEvent) { var serializedObject = ObjectSerialization.Serialize(cqrsEvent); - return SendMessage(ServiceBusConfig.SystemQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.SystemQueueName, serializedObject); } - public bool EnqueuePaymentEvent(CqrsEvent cqrsEvent) + public async Task EnqueuePaymentEvent(CqrsEvent cqrsEvent) { var serializedObject = ObjectSerialization.Serialize(cqrsEvent); - return SendMessage(ServiceBusConfig.PaymentQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.PaymentQueueName, serializedObject); } - public bool EnqueueAuditEvent(AuditEvent auditEvent) + public async Task EnqueueAuditEvent(AuditEvent auditEvent) { var serializedObject = ObjectSerialization.Serialize(auditEvent); - return SendMessage(ServiceBusConfig.AuditQueueName, serializedObject); + return await SendMessage(ServiceBusConfig.AuditQueueName, serializedObject); } - public bool EnqueueUnitLocationEvent(UnitLocationEvent unitLocationEvent) + public async Task EnqueueUnitLocationEvent(UnitLocationEvent unitLocationEvent) { var serializedObject = ObjectSerialization.Serialize(unitLocationEvent); - return SendMessage(ServiceBusConfig.UnitLoactionQueueName, serializedObject, false, "300000"); + return await SendMessage(ServiceBusConfig.UnitLoactionQueueName, serializedObject, false, "300000"); } - public bool EnqueuePersonnelLocationEvent(PersonnelLocationEvent personnelLocationEvent) + public async Task EnqueuePersonnelLocationEvent(PersonnelLocationEvent personnelLocationEvent) { var serializedObject = ObjectSerialization.Serialize(personnelLocationEvent); - return SendMessage(ServiceBusConfig.PersonnelLoactionQueueName, serializedObject, false, "300000"); + return await SendMessage(ServiceBusConfig.PersonnelLoactionQueueName, serializedObject, false, "300000"); } - public bool EnqueueSecurityRefreshEvent(SecurityRefreshEvent securityRefreshEvent) + public async Task EnqueueSecurityRefreshEvent(SecurityRefreshEvent securityRefreshEvent) { var serializedObject = ObjectSerialization.Serialize(securityRefreshEvent); - return SendMessage(ServiceBusConfig.SecurityRefreshQueueName, serializedObject, false, "300000"); + return await SendMessage(ServiceBusConfig.SecurityRefreshQueueName, serializedObject, false, "300000"); } - private bool SendMessage(string queueName, string message, bool durable = true, string expiration = "36000000") + private async Task SendMessage(string queueName, string message, bool durable = true, string expiration = "36000000") { if (String.IsNullOrWhiteSpace(queueName)) throw new ArgumentNullException("queueName"); @@ -112,25 +113,26 @@ private bool SendMessage(string queueName, string message, bool durable = true, var connection = RabbitConnection.CreateConnection(_clientName); if (connection != null) { - using (var channel = connection.CreateModel()) + using (var channel = await connection.CreateChannelAsync()) { if (channel != null) { - IBasicProperties props = channel.CreateBasicProperties(); + var props = new BasicProperties(); props.Headers = new Dictionary(); if (durable) { - props.DeliveryMode = 2; + props.DeliveryMode = DeliveryModes.Persistent; props.Headers.Add("x-redelivered-count", 0); } else - props.DeliveryMode = 1; + props.DeliveryMode = DeliveryModes.Transient; props.Expiration = expiration; - channel.BasicPublish(exchange: ServiceBusConfig.RabbbitExchange, + await channel.BasicPublishAsync(exchange: ServiceBusConfig.RabbbitExchange, routingKey: RabbitConnection.SetQueueNameForEnv(queueName), + mandatory: true, basicProperties: props, body: Encoding.ASCII.GetBytes(message)); @@ -156,9 +158,9 @@ private bool SendMessage(string queueName, string message, bool durable = true, } } - bool IRabbitOutboundQueueProvider.VerifyAndCreateClients() + public async Task VerifyAndCreateClients() { - return RabbitConnection.VerifyAndCreateClients(_clientName); + return await RabbitConnection.VerifyAndCreateClients(_clientName); } } } diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.cs b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.cs index ea27f96c..f8281eea 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.cs +++ b/Providers/Resgrid.Providers.Bus.Rabbit/RabbitTopicProvider.cs @@ -7,6 +7,7 @@ using System; using System.Text; using System.Threading; +using System.Threading.Tasks; namespace Resgrid.Providers.Bus.Rabbit { @@ -14,9 +15,9 @@ public class RabbitTopicProvider { private readonly string _clientName = "Resgrid-Topic"; - public bool PersonnelStatusChanged(UserStatusEvent message) + public async Task PersonnelStatusChanged(UserStatusEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.PersonnelStatusUpdated, @@ -26,9 +27,9 @@ public bool PersonnelStatusChanged(UserStatusEvent message) }.SerializeJson()); } - public bool PersonnelStaffingChanged(UserStaffingEvent message) + public async Task PersonnelStaffingChanged(UserStaffingEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.PersonnelStaffingUpdated, @@ -38,9 +39,9 @@ public bool PersonnelStaffingChanged(UserStaffingEvent message) }.SerializeJson()); } - public bool UnitStatusChanged(UnitStatusEvent message) + public async Task UnitStatusChanged(UnitStatusEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.UnitStatusUpdated, @@ -50,9 +51,9 @@ public bool UnitStatusChanged(UnitStatusEvent message) }.SerializeJson()); } - public bool CallAdded(CallAddedEvent message) + public async Task CallAdded(CallAddedEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.CallAdded, @@ -62,9 +63,9 @@ public bool CallAdded(CallAddedEvent message) }.SerializeJson()); } - public bool CallUpdated(CallUpdatedEvent message) + public async Task CallUpdated(CallUpdatedEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.CallsUpdated, @@ -74,9 +75,9 @@ public bool CallUpdated(CallUpdatedEvent message) }.SerializeJson()); } - public bool CallClosed(CallClosedEvent message) + public async Task CallClosed(CallClosedEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.CallClosed, @@ -86,9 +87,9 @@ public bool CallClosed(CallClosedEvent message) }.SerializeJson()); } - public bool PersonnelLocationUnidatedChanged(PersonnelLocationUpdatedEvent message) + public async Task PersonnelLocationUnidatedChanged(PersonnelLocationUpdatedEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.PersonnelLocationUpdated, @@ -99,9 +100,9 @@ public bool PersonnelLocationUnidatedChanged(PersonnelLocationUpdatedEvent messa }.SerializeJson()); } - public bool UnitLocationUpdatedChanged(UnitLocationUpdatedEvent message) + public async Task UnitLocationUpdatedChanged(UnitLocationUpdatedEvent message) { - return SendMessage(Topics.EventingTopic, new EventingMessage + return await SendMessage(Topics.EventingTopic, new EventingMessage { Id = Guid.NewGuid(), Type = (int)EventingTypes.UnitLocationUpdated, @@ -112,7 +113,7 @@ public bool UnitLocationUpdatedChanged(UnitLocationUpdatedEvent message) }.SerializeJson()); } - private static void VerifyAndCreateClients(string clientName) + private static async Task VerifyAndCreateClients(string clientName) { try { @@ -120,32 +121,36 @@ private static void VerifyAndCreateClients(string clientName) if (connection != null) { - using (var channel = connection.CreateModel()) + using (var channel = await connection.CreateChannelAsync()) { - channel.ExchangeDeclare(RabbitConnection.SetQueueNameForEnv(Topics.EventingTopic), "fanout"); + await channel.ExchangeDeclareAsync(RabbitConnection.SetQueueNameForEnv(Topics.EventingTopic), "fanout"); } } } catch (Exception ex) { Framework.Logging.LogException(ex); + return false; } + + return true; } - private bool SendMessage(string topicName, string message) + private async Task SendMessage(string topicName, string message) { - VerifyAndCreateClients(_clientName); + await VerifyAndCreateClients(_clientName); try { var connection = RabbitConnection.CreateConnection(_clientName); if (connection != null) { - using (var channel = connection.CreateModel()) + using (var channel = await connection.CreateChannelAsync()) { - channel.BasicPublish(exchange: RabbitConnection.SetQueueNameForEnv(topicName), + await channel.BasicPublishAsync(exchange: RabbitConnection.SetQueueNameForEnv(topicName), routingKey: "", - basicProperties: null, + //mandatory: false, //TODO: Not sure here. -SJ + //basicProperties: null, body: Encoding.ASCII.GetBytes(message)); } } diff --git a/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj b/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj index 4ceb4c63..5d0a38dc 100644 --- a/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj +++ b/Providers/Resgrid.Providers.Bus.Rabbit/Resgrid.Providers.Bus.Rabbit.csproj @@ -4,8 +4,8 @@ Debug;Release;Docker - - + + diff --git a/Providers/Resgrid.Providers.Bus/OutboundQueueProvider.cs b/Providers/Resgrid.Providers.Bus/OutboundQueueProvider.cs index 75fb457f..76daee8d 100644 --- a/Providers/Resgrid.Providers.Bus/OutboundQueueProvider.cs +++ b/Providers/Resgrid.Providers.Bus/OutboundQueueProvider.cs @@ -19,7 +19,7 @@ public OutboundQueueProvider() public async Task EnqueueCall(CallQueueItem callQueue) { if (SystemBehaviorConfig.ServiceBusType == ServiceBusTypes.Rabbit) - return _rabbitOutboundQueueProvider.EnqueueCall(callQueue); + return await _rabbitOutboundQueueProvider.EnqueueCall(callQueue); return false; } @@ -27,7 +27,7 @@ public async Task EnqueueCall(CallQueueItem callQueue) public async Task EnqueueMessage(MessageQueueItem messageQueue) { if (SystemBehaviorConfig.ServiceBusType == ServiceBusTypes.Rabbit) - return _rabbitOutboundQueueProvider.EnqueueMessage(messageQueue); + return await _rabbitOutboundQueueProvider.EnqueueMessage(messageQueue); return false; } @@ -35,7 +35,7 @@ public async Task EnqueueMessage(MessageQueueItem messageQueue) public async Task EnqueueDistributionList(DistributionListQueueItem distributionListQueue) { if (SystemBehaviorConfig.ServiceBusType == ServiceBusTypes.Rabbit) - return _rabbitOutboundQueueProvider.EnqueueDistributionList(distributionListQueue); + return await _rabbitOutboundQueueProvider.EnqueueDistributionList(distributionListQueue); return false; } @@ -43,7 +43,7 @@ public async Task EnqueueDistributionList(DistributionListQueueItem distri public async Task EnqueueNotification(NotificationItem notificationQueue) { if (SystemBehaviorConfig.ServiceBusType == ServiceBusTypes.Rabbit) - return _rabbitOutboundQueueProvider.EnqueueNotification(notificationQueue); + return await _rabbitOutboundQueueProvider.EnqueueNotification(notificationQueue); return false; } @@ -51,19 +51,19 @@ public async Task EnqueueNotification(NotificationItem notificationQueue) public async Task EnqueueShiftNotification(ShiftQueueItem shiftQueueItem) { if (SystemBehaviorConfig.ServiceBusType == ServiceBusTypes.Rabbit) - return _rabbitOutboundQueueProvider.EnqueueShiftNotification(shiftQueueItem); + return await _rabbitOutboundQueueProvider.EnqueueShiftNotification(shiftQueueItem); return false; } public async Task EnqueueAuditEvent(AuditEvent auditEvent) { - return _rabbitOutboundQueueProvider.EnqueueAuditEvent(auditEvent); + return await _rabbitOutboundQueueProvider.EnqueueAuditEvent(auditEvent); } public async Task EnqueueSecurityRefreshEvent(SecurityRefreshEvent securityRefreshEvent) { - return _rabbitOutboundQueueProvider.EnqueueSecurityRefreshEvent(securityRefreshEvent); + return await _rabbitOutboundQueueProvider.EnqueueSecurityRefreshEvent(securityRefreshEvent); } } } diff --git a/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj b/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj index 017db87b..17cab82d 100644 --- a/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj +++ b/Providers/Resgrid.Providers.Bus/Resgrid.Providers.Bus.csproj @@ -7,10 +7,10 @@ - - + + - + diff --git a/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj b/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj index cef0df72..49bf9476 100644 --- a/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj +++ b/Providers/Resgrid.Providers.Cache/Resgrid.Providers.Cache.csproj @@ -4,7 +4,7 @@ Debug;Release;Docker - + diff --git a/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj b/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj index cab39160..dad2945d 100644 --- a/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj +++ b/Providers/Resgrid.Providers.Claims/Resgrid.Providers.Claims.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj b/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj index 25b0c1cc..8982cde6 100644 --- a/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj +++ b/Providers/Resgrid.Providers.Email/Resgrid.Providers.Email.csproj @@ -31,11 +31,11 @@ - - - + + + - + diff --git a/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj b/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj index 3ac37b82..c2f749c9 100644 --- a/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj +++ b/Providers/Resgrid.Providers.Firebase/Resgrid.Providers.Firebase.csproj @@ -4,8 +4,8 @@ Debug;Release;Docker - - + + diff --git a/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj b/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj index cfc78a1b..1b3eba76 100644 --- a/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj +++ b/Providers/Resgrid.Providers.Geo/Resgrid.Providers.Geo.csproj @@ -4,12 +4,12 @@ Debug;Release;Docker - + - - + + diff --git a/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj b/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj index 53462b19..4e22772b 100644 --- a/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj +++ b/Providers/Resgrid.Providers.Marketing/Resgrid.Providers.Marketing.csproj @@ -4,8 +4,8 @@ Debug;Release;Docker - - + + diff --git a/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj b/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj index b7bc6d57..4edfc501 100644 --- a/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj +++ b/Providers/Resgrid.Providers.Messaging/Resgrid.Providers.Messaging.csproj @@ -7,9 +7,9 @@ - + - + diff --git a/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj b/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj index 8b5b50b9..307593be 100644 --- a/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj +++ b/Providers/Resgrid.Providers.Migrations/Resgrid.Providers.Migrations.csproj @@ -18,8 +18,8 @@ - - - + + + \ No newline at end of file diff --git a/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj index c684d2d5..191b58a6 100644 --- a/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj +++ b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj @@ -21,11 +21,11 @@ - - - - - + + + + + diff --git a/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj b/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj index 13ba23c4..84cd870a 100644 --- a/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj +++ b/Providers/Resgrid.Providers.Number/Resgrid.Providers.Number.csproj @@ -10,11 +10,11 @@ - - + + - - + + diff --git a/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj b/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj index a4b3c94c..0db59603 100644 --- a/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj +++ b/Providers/Resgrid.Providers.Pdf/Resgrid.Providers.Pdf.csproj @@ -4,9 +4,9 @@ Debug;Release;Docker - + - + diff --git a/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj b/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj index 8f44f1ca..a71e99e6 100644 --- a/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj +++ b/Providers/Resgrid.Providers.Voip/Resgrid.Providers.Voip.csproj @@ -4,15 +4,15 @@ Debug;Release;Docker - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj index fe75ad46..992c0251 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj +++ b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj @@ -4,14 +4,14 @@ Debug;Release;Docker - + - + - - - + + + diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/MongoRepository.cs b/Repositories/Resgrid.Repositories.NoSqlRepository/MongoRepository.cs index aa33b88e..fffcd204 100644 --- a/Repositories/Resgrid.Repositories.NoSqlRepository/MongoRepository.cs +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/MongoRepository.cs @@ -29,7 +29,7 @@ private protected string GetCollectionName(Type documentType) return ((BsonCollectionAttribute)documentType.GetCustomAttributes(typeof(BsonCollectionAttribute), true).FirstOrDefault())?.CollectionName; } - public virtual IMongoQueryable AsQueryable() + public virtual IQueryable AsQueryable() { return _collection.AsQueryable(); } diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj index b752b6bb..3d970600 100644 --- a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj @@ -4,10 +4,10 @@ enable - - + + - + diff --git a/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj b/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj index 0a740a87..d0c98784 100644 --- a/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj +++ b/Tests/Resgrid.Intergration.Tests/Resgrid.Intergration.Tests.csproj @@ -9,9 +9,9 @@ - + - + diff --git a/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj b/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj index cdc2c115..7fbb56fa 100644 --- a/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj +++ b/Tests/Resgrid.SmokeTests/Resgrid.SmokeTests.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Tests/Resgrid.Tests/Framework/RandomGeneratorTests.cs b/Tests/Resgrid.Tests/Framework/RandomGeneratorTests.cs index 6ffe8e60..05ebafb5 100644 --- a/Tests/Resgrid.Tests/Framework/RandomGeneratorTests.cs +++ b/Tests/Resgrid.Tests/Framework/RandomGeneratorTests.cs @@ -11,8 +11,8 @@ public class RandomGeneratorTests public void TestRandomNumberGeneration() { var number = RandomGenerator.GetRandomNumber(1, 100); - number.Should().BeGreaterOrEqualTo(1); - number.Should().BeLessOrEqualTo(100); + number.Should().BeGreaterThanOrEqualTo(1); + number.Should().BeLessThanOrEqualTo(100); } [Test] diff --git a/Tests/Resgrid.Tests/Resgrid.Tests.csproj b/Tests/Resgrid.Tests/Resgrid.Tests.csproj index c0be48d6..868dba0e 100644 --- a/Tests/Resgrid.Tests/Resgrid.Tests.csproj +++ b/Tests/Resgrid.Tests/Resgrid.Tests.csproj @@ -28,10 +28,10 @@ - - - - + + + + diff --git a/Tools/Resgrid.Console/Resgrid.Console.csproj b/Tools/Resgrid.Console/Resgrid.Console.csproj index b4c70d44..63986e50 100644 --- a/Tools/Resgrid.Console/Resgrid.Console.csproj +++ b/Tools/Resgrid.Console/Resgrid.Console.csproj @@ -20,22 +20,22 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + - + diff --git a/Web/Resgrid.Web.Eventing/Dockerfile b/Web/Resgrid.Web.Eventing/Dockerfile index 54b5a904..5f4bdbd2 100644 --- a/Web/Resgrid.Web.Eventing/Dockerfile +++ b/Web/Resgrid.Web.Eventing/Dockerfile @@ -1,12 +1,12 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. ARG BUILD_VERSION=3.5.0 -FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-jammy-amd64 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base ARG BUILD_VERSION WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:8.0.203-jammy-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build ARG BUILD_VERSION WORKDIR /src COPY ["Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj", "Web/Resgrid.Web.Eventing/"] diff --git a/Web/Resgrid.Web.Eventing/Program.cs b/Web/Resgrid.Web.Eventing/Program.cs index c3137a8c..85dd75b6 100644 --- a/Web/Resgrid.Web.Eventing/Program.cs +++ b/Web/Resgrid.Web.Eventing/Program.cs @@ -48,8 +48,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) => options.AttachStacktrace = true; options.SendDefaultPii = true; - if (ExternalErrorConfig.SentryPerfSampleRate > 0) - options.EnableTracing = true; + //if (ExternalErrorConfig.SentryPerfSampleRate > 0) + // options.EnableTracing = true; options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; options.Environment = ExternalErrorConfig.Environment; diff --git a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj index 50fa419f..5bce7527 100644 --- a/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj +++ b/Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj @@ -19,37 +19,37 @@ - + - - + + NU1605 - - + + NU1605 - + NU1605 - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/Web/Resgrid.Web.Services/Dockerfile b/Web/Resgrid.Web.Services/Dockerfile index 95dd5082..42ce3f33 100644 --- a/Web/Resgrid.Web.Services/Dockerfile +++ b/Web/Resgrid.Web.Services/Dockerfile @@ -2,12 +2,12 @@ ARG BUILD_VERSION=3.5.0 -FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-jammy-amd64 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base ARG BUILD_VERSION WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:8.0.203-jammy-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build ARG BUILD_VERSION WORKDIR /src COPY ["Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj", "Web/Resgrid.Web.Services/"] diff --git a/Web/Resgrid.Web.Services/Middleware/SentryEventProcessor.cs b/Web/Resgrid.Web.Services/Middleware/SentryEventProcessor.cs index 7e6ec5c4..122fb21d 100644 --- a/Web/Resgrid.Web.Services/Middleware/SentryEventProcessor.cs +++ b/Web/Resgrid.Web.Services/Middleware/SentryEventProcessor.cs @@ -22,10 +22,10 @@ public SentryEvent Process(SentryEvent @event) var user = new SentryUser(); user.Username = ClaimsAuthorizationHelper.GetUsername(); user.Id = ClaimsAuthorizationHelper.GetUserId(); - user.Segment = ClaimsAuthorizationHelper.GetDepartmentId().ToString(); user.IpAddress = IpAddressHelper.GetRequestIP(_httpContext.HttpContext?.Request, true); user.Other.Add("Name", ClaimsAuthorizationHelper.GetFullName()); user.Other.Add("Department", ClaimsAuthorizationHelper.GetDepartmentName()); + user.Other.Add("DepartmentId", ClaimsAuthorizationHelper.GetDepartmentId().ToString()); @event.User = user; } catch (Exception ex) { } diff --git a/Web/Resgrid.Web.Services/Program.cs b/Web/Resgrid.Web.Services/Program.cs index 763b7df7..ef2b40df 100644 --- a/Web/Resgrid.Web.Services/Program.cs +++ b/Web/Resgrid.Web.Services/Program.cs @@ -50,8 +50,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) => options.SendDefaultPii = true; options.AutoSessionTracking = true; - if (ExternalErrorConfig.SentryPerfSampleRate > 0) - options.EnableTracing = true; + //if (ExternalErrorConfig.SentryPerfSampleRate > 0) + // options.EnableTracing = true; options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; options.Environment = ExternalErrorConfig.Environment; diff --git a/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj b/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj index 82db959f..a1f9787c 100644 --- a/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj +++ b/Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj @@ -39,77 +39,80 @@ - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + - - - - - + + + + + diff --git a/Web/Resgrid.Web/Dockerfile b/Web/Resgrid.Web/Dockerfile index fb991d6f..db75938d 100644 --- a/Web/Resgrid.Web/Dockerfile +++ b/Web/Resgrid.Web/Dockerfile @@ -1,13 +1,13 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. ARG BUILD_VERSION=3.5.0 -FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-jammy-amd64 AS base +FROM mcr.microsoft.com/dotnet/aspnet:aspnet:9.0.3-noble-amd64 AS base ARG BUILD_VERSION WORKDIR /app EXPOSE 80 #FROM node:18.19-alpine3.19 AS node_base -FROM mcr.microsoft.com/dotnet/sdk:8.0.203-jammy-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build #RUN apt-get update && apt-get install nodejs #COPY --from=node_base . . #COPY --from=node_base /usr/lib /usr/lib diff --git a/Web/Resgrid.Web/Middleware/SentryEventProcessor.cs b/Web/Resgrid.Web/Middleware/SentryEventProcessor.cs index 3322b5dd..0449cca2 100644 --- a/Web/Resgrid.Web/Middleware/SentryEventProcessor.cs +++ b/Web/Resgrid.Web/Middleware/SentryEventProcessor.cs @@ -21,10 +21,10 @@ public SentryEvent Process(SentryEvent @event) var user = new SentryUser(); user.Username = ClaimsAuthorizationHelper.GetUsername(); user.Id = ClaimsAuthorizationHelper.GetUserId(); - user.Segment = ClaimsAuthorizationHelper.GetDepartmentId().ToString(); user.IpAddress = IpAddressHelper.GetRequestIP(_httpContext.HttpContext?.Request, true); user.Other.Add("Name", ClaimsAuthorizationHelper.GetFullName()); user.Other.Add("Department", ClaimsAuthorizationHelper.GetDepartmentName()); + user.Other.Add("DepartmentId", ClaimsAuthorizationHelper.GetDepartmentId().ToString()); @event.User = user; } catch (Exception ex) { } diff --git a/Web/Resgrid.Web/Program.cs b/Web/Resgrid.Web/Program.cs index a56368b6..4f296dea 100644 --- a/Web/Resgrid.Web/Program.cs +++ b/Web/Resgrid.Web/Program.cs @@ -49,8 +49,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) => options.AttachStacktrace = true; options.SendDefaultPii = true; - if (ExternalErrorConfig.SentryPerfSampleRate > 0) - options.EnableTracing = true; + //if (ExternalErrorConfig.SentryPerfSampleRate > 0) + // options.EnableTracing = true; options.TracesSampleRate = ExternalErrorConfig.SentryPerfSampleRate; options.Environment = ExternalErrorConfig.Environment; diff --git a/Web/Resgrid.Web/Resgrid.Web.csproj b/Web/Resgrid.Web/Resgrid.Web.csproj index 32c53cb3..bab4c9e3 100644 --- a/Web/Resgrid.Web/Resgrid.Web.csproj +++ b/Web/Resgrid.Web/Resgrid.Web.csproj @@ -36,71 +36,72 @@ - - - - + + + + - + - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/Workers/Resgrid.Workers.Console/Dockerfile b/Workers/Resgrid.Workers.Console/Dockerfile index 66f432f1..0912b0b0 100644 --- a/Workers/Resgrid.Workers.Console/Dockerfile +++ b/Workers/Resgrid.Workers.Console/Dockerfile @@ -1,11 +1,11 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. ARG BUILD_VERSION=3.5.0 -FROM mcr.microsoft.com/dotnet/runtime:8.0.3-jammy-amd64 AS base +FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base ARG BUILD_VERSION WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:8.0.203-jammy-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build ARG BUILD_VERSION WORKDIR /src diff --git a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj index 468fcd81..bd1bcd36 100644 --- a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj +++ b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj @@ -19,23 +19,23 @@ - + - - + + - + - - - - - - + + + + + + diff --git a/Workers/Resgrid.Workers.Framework/Helpers/TraceHelper.cs b/Workers/Resgrid.Workers.Framework/Helpers/TraceHelper.cs index 6cf6f494..7823345c 100644 --- a/Workers/Resgrid.Workers.Framework/Helpers/TraceHelper.cs +++ b/Workers/Resgrid.Workers.Framework/Helpers/TraceHelper.cs @@ -3,39 +3,39 @@ namespace Resgrid.Workers.Framework.Helpers { - public class TraceHelper - { - private static readonly TraceSource Trace; + //public class TraceHelper + //{ + // private static readonly TraceSource Trace; - static TraceHelper() - { - Trace = new TraceSource("TraceSource", SourceLevels.Information); - } + // static TraceHelper() + // { + // Trace = new TraceSource("TraceSource", SourceLevels.Information); + // } - [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)] - public static void Configure(SourceLevels sourceLevels) - { - Trace.Switch.Level = sourceLevels; - } + // [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)] + // public static void Configure(SourceLevels sourceLevels) + // { + // Trace.Switch.Level = sourceLevels; + // } - public static void TraceVerbose(string format, params object[] args) - { - Trace.TraceEvent(TraceEventType.Verbose, 0, format, args); - } + // public static void TraceVerbose(string format, params object[] args) + // { + // Trace.TraceEvent(TraceEventType.Verbose, 0, format, args); + // } - public static void TraceInformation(string format, params object[] args) - { - Trace.TraceEvent(TraceEventType.Information, 0, format, args); - } + // public static void TraceInformation(string format, params object[] args) + // { + // Trace.TraceEvent(TraceEventType.Information, 0, format, args); + // } - public static void TraceWarning(string format, params object[] args) - { - Trace.TraceEvent(TraceEventType.Warning, 0, format, args); - } + // public static void TraceWarning(string format, params object[] args) + // { + // Trace.TraceEvent(TraceEventType.Warning, 0, format, args); + // } - public static void TraceError(string format, params object[] args) - { - Trace.TraceEvent(TraceEventType.Error, 0, format, args); - } - } -} \ No newline at end of file + // public static void TraceError(string format, params object[] args) + // { + // Trace.TraceEvent(TraceEventType.Error, 0, format, args); + // } + //} +} diff --git a/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj b/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj index 75f5db20..5b0e3e9f 100644 --- a/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj +++ b/Workers/Resgrid.Workers.Framework/Resgrid.Workers.Framework.csproj @@ -7,7 +7,7 @@ - + diff --git a/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj b/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj index 9997666d..c6f9f035 100644 --- a/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj +++ b/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj @@ -60,7 +60,7 @@ - + From 384fbd0b9b1d717929a062c676f250c728af6e8e Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 26 Mar 2025 22:46:06 -0700 Subject: [PATCH 3/5] CU-868d85dv8 Fixing connection strings --- .../ClaimsRepository.cs | 49 ++++++++++--- .../DeleteRepository.cs | 21 +++--- .../DepartmentGroupsRepository.cs | 71 ++++++++++++++----- .../IdentityRepository.cs | 36 +++++----- .../ScheduledTaskLogsRepository.cs | 34 +++++++-- .../ScheduledTasksRepository.cs | 31 ++++++-- 6 files changed, 180 insertions(+), 62 deletions(-) diff --git a/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs index f6c098f9..d9ebf40e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ClaimsRepository.cs @@ -5,8 +5,11 @@ using System.Linq; using System.Threading.Tasks; using Dapper; +using Npgsql; +using Resgrid.Config; using Resgrid.Model.Identity; using Resgrid.Model.Repositories; +using static Resgrid.Framework.Testing.TestData; namespace Resgrid.Repositories.DataRepository { @@ -14,27 +17,55 @@ public class ClaimsRepository : IClaimsRepository { public async Task> GetRolesAsync(IdentityUser user) { - var query = $@"SELECT anr.Name FROM AspNetUserRoles anur + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + var query = $@"SELECT anr.name FROM aspnetuserroles anur + INNER JOIN aspnetroles anr ON anur.roleid = anr.id + WHERE anur.userid = @userId"; + + + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return (await db.QueryAsync(query, new { userId = user.Id })).ToList(); + } + } + else + { + var query = $@"SELECT anr.Name FROM AspNetUserRoles anur INNER JOIN AspNetRoles anr ON anur.RoleId = anr.Id WHERE anur.UserId = @userId"; - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) - { - var results = await db.QueryAsync(query, new { userId = user.Id }); + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + var results = await db.QueryAsync(query, new { userId = user.Id }); - return results.ToList(); + return results.ToList(); + } } + } public async Task FindByIdAsync(string userId) { - var query = $@"SELECT * FROM AspNetUsers WHERE Id = @userId"; + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + var query = $@"SELECT * FROM aspnetusers WHERE id = @userId"; - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return (await db.QueryAsync(query, new { userId = userId })).FirstOrDefault(); + } + } + else { - var results = await db.QueryAsync(query, new { id = userId }); + var query = $@"SELECT * FROM AspNetUsers WHERE Id = @userId"; + + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + var results = await db.QueryAsync(query, new { id = userId }); - return results.FirstOrDefault(); + return results.FirstOrDefault(); + } } } } diff --git a/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs index 62669347..4d809a5d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs @@ -14,17 +14,21 @@ namespace Resgrid.Repositories.DataRepository { - public class DeleteRepository: IDeleteRepository + public class DeleteRepository : IDeleteRepository { public async Task DeleteDepartmentAndUsersAsync(int departmentId) { Dapper.SqlMapper.Settings.CommandTimeout = 300; - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + // TODO: Ok this needs to be revisited and also made compatible with PgSql. -SJ 3-26-2025 + + if (Config.DataConfig.DatabaseType == DatabaseTypes.SqlServer) { - using (var transaction = db.BeginTransaction()) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { - var result = await db.ExecuteAsync(@" + using (var transaction = db.BeginTransaction()) + { + var result = await db.ExecuteAsync(@" DECLARE @UserId NVARCHAR(128) DECLARE @UnitId INT DECLARE @ManagingUserId NVARCHAR(128) @@ -167,13 +171,14 @@ DELETE FROM [dbo].[MessageRecipients] WHERE MessageId IN (SELECT MessageId FROM DELETE FROM [dbo].[AspNetUsersExt] WHERE UserId = @ManagingUserId DELETE FROM [dbo].[AspNetUsers] WHERE Id = @ManagingUserId ", - new { DepartmentId = departmentId }); + new { DepartmentId = departmentId }); - transaction.Commit(); + transaction.Commit(); + } } - } - return false; + return false; + } } } } diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs index cc956eca..1990886c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs @@ -7,8 +7,11 @@ using System.Linq; using System.Threading.Tasks; using Dapper; +using Npgsql; +using Resgrid.Config; using Resgrid.Framework; using Resgrid.Model; +using Resgrid.Model.Identity; using Resgrid.Model.Repositories; using Resgrid.Model.Repositories.Connection; using Resgrid.Model.Repositories.Queries; @@ -37,34 +40,66 @@ public DepartmentGroupsRepository(IConnectionProvider connectionProvider, SqlCon public async Task> GetAllStationGroupsForDepartmentAsync(int departmentId) { Dictionary lookup = new Dictionary(); + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var query = @"SELECT * FROM departmentgroups dg + LEFT OUTER JOIN addresses a ON dg.addressid = a.addressid + WHERE dg.departmentid = @departmentId AND dg.type = 2"; + + await db.QueryAsync(query, (dg, a) => + { + DepartmentGroup group; + + if (!lookup.TryGetValue(dg.DepartmentGroupId, out group)) + { + lookup.Add(dg.DepartmentGroupId, dg); + group = dg; + } - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (a != null && dg.Address == null) + { + group.Address = a; + } + + return dg; + + }, new { departmentId = departmentId }, splitOn: "AddressId"); + } + + return lookup.Values.ToList(); + } + else { - var query = @"SELECT * FROM DepartmentGroups dg + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + var query = @"SELECT * FROM DepartmentGroups dg LEFT OUTER JOIN Addresses a ON dg.AddressId = a.AddressId WHERE dg.DepartmentId = @departmentId AND dg.Type = 2"; - await db.QueryAsync(query, (dg, a) => - { - DepartmentGroup group; - - if (!lookup.TryGetValue(dg.DepartmentGroupId, out group)) + await db.QueryAsync(query, (dg, a) => { - lookup.Add(dg.DepartmentGroupId, dg); - group = dg; - } + DepartmentGroup group; - if (a != null && dg.Address == null) - { - group.Address = a; - } + if (!lookup.TryGetValue(dg.DepartmentGroupId, out group)) + { + lookup.Add(dg.DepartmentGroupId, dg); + group = dg; + } - return dg; + if (a != null && dg.Address == null) + { + group.Address = a; + } - }, new { departmentId = departmentId }, splitOn: "AddressId"); - } + return dg; - return lookup.Values.ToList(); + }, new { departmentId = departmentId }, splitOn: "AddressId"); + } + + return lookup.Values.ToList(); + } } public async Task> GetAllGroupsByDepartmentIdAsync(int departmentId) diff --git a/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs index 803e8736..f616f314 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs @@ -28,7 +28,7 @@ public List GetAll() } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query($"SELECT * FROM AspNetUsers").ToList(); } @@ -48,7 +48,7 @@ public IdentityUser GetUserById(string userId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query($"SELECT * FROM AspNetUsers WHERE Id = @userId", new { userId = userId }).FirstOrDefault(); } @@ -70,7 +70,7 @@ public async Task GetUserByUserNameAsync(string userName) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { var result = await db.QueryAsync($"SELECT * FROM AspNetUsers WHERE UserName = @userName", new { userName = userName }); @@ -92,7 +92,7 @@ public IdentityUser GetUserByEmail(string email) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query($"SELECT * FROM AspNetUsers WHERE Email = @email", new { email = email }).FirstOrDefault(); } @@ -112,7 +112,7 @@ public void UpdateUsername(string oldUsername, string newUsername) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { db.Execute($"UPDATE [AspNetUsers] SET [UserName] = @newUsername, [NormalizedUserName] = @newUsernameUpper WHERE UserName = @oldUsername", new { newUsername = newUsername, newUsernameUpper = newUsername.ToUpper(), oldUsername = oldUsername }); } @@ -130,7 +130,7 @@ public void UpdateEmail(string userId, string newEmail) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { db.Execute($"UPDATE [AspNetUsers] SET [Email] = @newEmail, [NormalizedEmail] = @newEmailUpper WHERE Id = @userId", new { userId = userId, newEmail = newEmail, newEmailUpper = newEmail.ToUpper() }); } @@ -148,7 +148,7 @@ public void AddUserToRole(string userId, string roleId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { db.Execute($"INSERT INTO AspNetUserRoles ([UserId] ,[RoleId]) VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId }); } @@ -167,7 +167,7 @@ public void InitUserExtInfo(string userId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { db.Execute($"INSERT INTO AspNetUsersExt ([UserId] ,[CreateDate] ,[LastActivityDate]) VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow }); db.Execute($"UPDATE [dbo].[AspNetUsers] SET [EmailConfirmed] = 1 WHERE Id = @userId", new { userId = userId }); @@ -186,7 +186,7 @@ public IdentityUserRole GetRoleForUserRole(string userId, string roleId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query($"SELECT * FROM AspNetUserRoles WHERE UserId = @userId AND RoleId = @roleId", new { userId = userId, roleId = roleId }).FirstOrDefault(); } @@ -207,7 +207,7 @@ public IdentityUser Update(IdentityUser user) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { db.Update(user); } @@ -230,7 +230,7 @@ public List GetAllMembershipsForDepartment(int departmentId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query(@"SELECT m.* FROM AspNetUsers m INNER JOIN DepartmentMembers dm ON dm.UserId = m.Id @@ -254,7 +254,7 @@ public List GetAllUsersForDepartment(int departmentId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id @@ -281,7 +281,7 @@ FROM aspnetusers u } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query(@"SELECT u.* FROM AspNetUsers u @@ -308,7 +308,7 @@ public List GetAllUsersForDepartmentWithinLimits(int departmentId, } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id @@ -336,7 +336,7 @@ public async Task> GetAllUsersForDepartmentWithinLimitsAsync( } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { var result = await db.QueryAsync(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id @@ -364,7 +364,7 @@ public List GetAllUsersCreatedAfterTimestamp(DateTime timestamp) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { return db.Query(@"SELECT u.*, ue.* FROM AspNetUsers u INNER JOIN AspNetUsersExt ue ON u.Id = ue.UserId @@ -401,7 +401,7 @@ FROM public.departmentmembers dm } } else - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { var query = await db.QueryAsync(@"SELECT dgm.DepartmentGroupId, u.Id as 'UserId', (SELECT STUFF(( @@ -468,7 +468,7 @@ public async Task ClearOutUserLoginAsync(string userId) } else { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) { var result = await db.ExecuteAsync(@"UPDATE AspNetUsers SET UserName = @deleteid, diff --git a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs index ae594465..4ed6ae89 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTaskLogsRepository.cs @@ -11,6 +11,9 @@ using Resgrid.Model.Repositories.Connection; using Resgrid.Model.Repositories.Queries; using Resgrid.Repositories.DataRepository.Configs; +using Npgsql; +using Resgrid.Config; +using static Resgrid.Framework.Testing.TestData; namespace Resgrid.Repositories.DataRepository { @@ -52,18 +55,39 @@ public List GetAllLogsForTask(int scheduledTaskId) public async Task> GetAllLogForDateAsync(DateTime timeStamp) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) { - return await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp }); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return (await db.QueryAsync($"SELECT * FROM scheduledtasklogs WHERE CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp })).ToList(); + } + } + else + { + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + return await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { timeStamp = timeStamp }); + } } } public async Task GetLogForTaskAndDateAsync(int scheduledTaskId, DateTime timeStamp) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var items = await db.QueryAsync($"SELECT * FROM scheduledtasklogs WHERE scheduledtaskid = @scheduledTaskId AND CAST(rundate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); + return items.FirstOrDefault(); + } + } + else { - var items = await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE ScheduledTaskId = @scheduledTaskId AND CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); - return items.FirstOrDefault(); + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + var items = await db.QueryAsync($"SELECT * FROM ScheduledTaskLogs WHERE ScheduledTaskId = @scheduledTaskId AND CAST(RunDate AS DATE) = CAST(@timeStamp AS DATE)", new { scheduledTaskId = scheduledTaskId, timeStamp = timeStamp }); + return items.FirstOrDefault(); + } } } } diff --git a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs index 51d4ecd5..e3def58d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs @@ -17,6 +17,8 @@ using Resgrid.Repositories.DataRepository.Queries.ResourceOrders; using Resgrid.Repositories.DataRepository.Queries.ScheduledTasks; using Resgrid.Config; +using Npgsql; +using ProtoBuf.WellKnownTypes; namespace Resgrid.Repositories.DataRepository { @@ -48,20 +50,41 @@ public List GetAllTasks() public async Task> GetAllActiveTasksForTypesAsync(List types) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) { - var knownDepartments = await db.QueryAsync($@"SELECT st.*, d.DepartmentId as 'DepartmentId', d.TimeZone as 'DepartmentTimeZone' + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var knownDepartments = await db.QueryAsync($@"SELECT st.*, d.departmentid as 'DepartmentId', d.timezone as 'DepartmentTimeZone' + FROM scheduledtasks st + INNER JOIN departments d ON d.departmentid = st.departmentid + WHERE st.departmentid > 0 AND st.active = 1 AND st.tasktype IN @types", new { types = types }); + + var unknownDepartments = await db.QueryAsync($@"SELECT st.*, d.departmentid as 'DepartmentId', d.timezone as 'DepartmentTimeZone' + FROM scheduledtasks st + INNER JOIN departmentmembers dm ON dm.userid = st.userid + INNER JOIN departments d ON d.departmentid = dm.departmentid + WHERE st.departmentid = 0 AND st.active = 1 AND st.tasktype IN @types", new { types = types }); + + return knownDepartments.Concat(unknownDepartments); + } + } + else + { + using (IDbConnection db = new SqlConnection(DataConfig.CoreConnectionString)) + { + var knownDepartments = await db.QueryAsync($@"SELECT st.*, d.DepartmentId as 'DepartmentId', d.TimeZone as 'DepartmentTimeZone' FROM ScheduledTasks st INNER JOIN Departments d ON d.DepartmentId = st.DepartmentId WHERE st.DepartmentId > 0 AND st.Active = 1 AND st.TaskType IN @types", new { types = types }); - var unknownDepartments = await db.QueryAsync($@"SELECT st.*, d.DepartmentId as 'DepartmentId', d.TimeZone as 'DepartmentTimeZone' + var unknownDepartments = await db.QueryAsync($@"SELECT st.*, d.DepartmentId as 'DepartmentId', d.TimeZone as 'DepartmentTimeZone' FROM ScheduledTasks st INNER JOIN DepartmentMembers dm ON dm.UserId = st.UserId INNER JOIN Departments d ON d.DepartmentId = dm.DepartmentId WHERE st.DepartmentId = 0 AND st.Active = 1 AND st.TaskType IN @types", new { types = types }); - return knownDepartments.Concat(unknownDepartments); + return knownDepartments.Concat(unknownDepartments); + } } } From 87633255969cc4d5451a46ee467dd28726585655 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 26 Mar 2025 22:51:28 -0700 Subject: [PATCH 4/5] CU-868d85dv8 Fixing build issue. --- .../Resgrid.Repositories.DataRepository/DeleteRepository.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs index 4d809a5d..b0983d7c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DeleteRepository.cs @@ -179,6 +179,8 @@ DELETE FROM [dbo].[MessageRecipients] WHERE MessageId IN (SELECT MessageId FROM return false; } + + return false; } } } From e374a53103e979e5c4388deaaeb17d9f4844a486 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 26 Mar 2025 22:54:41 -0700 Subject: [PATCH 5/5] CU-868d85dv8 Fixing github build --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5839c089..a0d2dfc0 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build