Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Core/Resgrid.Config/Resgrid.Config.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Configurations>Debug;Release;Docker</Configurations>
</PropertyGroup>
<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions Core/Resgrid.Framework/Resgrid.Framework.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>Resgrid.Framework</AssemblyName>
<Company>Resgrid, LLC</Company>
<Product>Resgrid OSS CAD</Product>
Expand All @@ -12,14 +12,14 @@
<None Include="..\..\Common\Resgrid-PubPriv-KeyFile.snk" Link="Resgrid-PubPriv-KeyFile.snk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Sentry" Version="4.10.2" />
<PackageReference Include="Sentry.Serilog" Version="4.10.2" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.0" />
<PackageReference Include="NodaTime" Version="3.2.2" />
<PackageReference Include="protobuf-net" Version="3.2.46" />
<PackageReference Include="Sentry" Version="5.4.0" />
<PackageReference Include="Sentry.Serilog" Version="5.4.0" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="TimeZoneConverter" Version="6.1.0" />
<PackageReference Include="TimeZoneConverter" Version="7.0.0" />
<PackageReference Include="Vereyon.Web.HtmlSanitizer" Version="1.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Core/Resgrid.Localization/Resgrid.Localization.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
Expand Down
21 changes: 11 additions & 10 deletions Core/Resgrid.Model/Providers/IRabbitOutboundQueueProvider.cs
Original file line number Diff line number Diff line change
@@ -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<bool> EnqueueCall(CallQueueItem callQueue);
Task<bool> EnqueueMessage(MessageQueueItem messageQueue);
Task<bool> EnqueueDistributionList(DistributionListQueueItem distributionListQueue);
Task<bool> EnqueueNotification(NotificationItem notificationQueue);
Task<bool> EnqueueShiftNotification(ShiftQueueItem shiftQueueItem);
Task<bool> EnqueueCqrsEvent(CqrsEvent cqrsEvent);
Task<bool> EnqueueAuditEvent(AuditEvent auditEvent);
Task<bool> EnqueueUnitLocationEvent(UnitLocationEvent unitLocationEvent);
Task<bool> EnqueuePersonnelLocationEvent(PersonnelLocationEvent personnelLocationEvent);
Task<bool> VerifyAndCreateClients();
}
}
2 changes: 1 addition & 1 deletion Core/Resgrid.Model/Repositories/IMongoRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IMongoRepository<TDocument> where TDocument : INoSqlDocument
{
IMongoCollection<TDocument> GetCollection();

IMongoQueryable<TDocument> AsQueryable();
IQueryable<TDocument> AsQueryable();

IEnumerable<TDocument> FilterBy(
Expression<Func<TDocument, bool>> filterExpression);
Expand Down
14 changes: 7 additions & 7 deletions Core/Resgrid.Model/Resgrid.Model.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Configurations>Debug;Release;Docker</Configurations>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -79,12 +79,12 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="GeoCoordinate.NetCore" Version="1.0.0.1" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="MimeKit" Version="4.7.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
<PackageReference Include="Stripe.net" Version="45.1.0" />
<PackageReference Include="GeoJSON.Net" Version="1.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.3.1" />
<PackageReference Include="MimeKit" Version="4.11.0" />
<PackageReference Include="MongoDB.Driver" Version="3.2.1" />
<PackageReference Include="protobuf-net" Version="3.2.46" />
<PackageReference Include="Stripe.net" Version="47.4.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Core/Resgrid.Model/Services/IHealthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public interface IHealthService
Task<string> GetDatabaseTimestamp();
bool IsCacheProviderConnected();

bool IsServiceBusProviderConnected();
Task<bool> IsServiceBusProviderConnected();
}
}
4 changes: 2 additions & 2 deletions Core/Resgrid.Services/HealthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public bool IsCacheProviderConnected()
return _cacheProvider.IsConnected();
}

public bool IsServiceBusProviderConnected()
public async Task<bool> IsServiceBusProviderConnected()
{
return _rabbitOutboundQueueProvider.VerifyAndCreateClients();
return await _rabbitOutboundQueueProvider.VerifyAndCreateClients();
}
}
}
10 changes: 5 additions & 5 deletions Core/Resgrid.Services/Resgrid.Services.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Configurations>Debug;Release;Docker</Configurations>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\Common\Resgrid-PubPriv-KeyFile.snk" Link="Resgrid-PubPriv-KeyFile.snk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Autofac" Version="8.2.0" />
<PackageReference Include="CommonServiceLocator" Version="2.0.7" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
<PackageReference Include="Stripe.net" Version="45.1.0" />
<PackageReference Include="GeoJSON.Net" Version="1.4.1" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="112.1.0" />
<PackageReference Include="Stripe.net" Version="47.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Configurations>Debug;Release;Docker</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Autofac" Version="8.2.0" />
<PackageReference Include="RestSharp" Version="112.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Resgrid.Model\Resgrid.Model.csproj" />
Expand Down
100 changes: 55 additions & 45 deletions Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,140 +2,150 @@
using Resgrid.Config;
using Resgrid.Framework;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Resgrid.Providers.Bus.Rabbit
{
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<bool> VerifyAndCreateClients(string clientName)
{
if (_connection != null && !_connection.IsOpen)
{
_connection.Dispose();
_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,
Expand Down
Loading
Loading