Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/IoTSharp/IoTSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
maikebing committed Dec 7, 2023
2 parents 79e644b + 0970c9b commit f50a8c7
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 0 deletions.
36 changes: 36 additions & 0 deletions IoTSharp.EventBus.NServiceBus/DependencyInjection.cs
@@ -0,0 +1,36 @@

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IoTSharp.Contracts;

namespace IoTSharp.EventBus.NServiceBus
{
public static class DependencyInjection
{

public static IApplicationBuilder UseNServiceBusEventBus(this IApplicationBuilder app)
{
var provider = app.ApplicationServices;
var options = provider.GetService<EventBusOption>();
return app;
}

public static void UseNServiceBus(this EventBusOption opt)
{
var settings = opt.AppSettings;
var healthChecks = opt.HealthChecks;
var _EventBusStore = opt.EventBusStore;
var _EventBusMQ = opt.EventBusMQ;
var services = opt.services;
services.AddTransient<ISubscriber, NSBusSubscriber>();
services.AddTransient<IPublisher, NSBusPublisher>();
}


}
}
17 changes: 17 additions & 0 deletions IoTSharp.EventBus.NServiceBus/IoTSharp.EventBus.NServiceBus.csproj
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="8.1.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\IoTSharp.EventBus\IoTSharp.EventBus.csproj" />
</ItemGroup>

</Project>
55 changes: 55 additions & 0 deletions IoTSharp.EventBus.NServiceBus/NSBusPublisher.cs
@@ -0,0 +1,55 @@

using IoTSharp.Contracts;
using IoTSharp.Data;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

namespace IoTSharp.EventBus.NServiceBus
{
public class NSBusPublisher : IPublisher
{
public Task<EventBusMetrics> GetMetrics()
{
throw new NotImplementedException();
}

public Task PublishActive(Guid devid, ActivityStatus activity)
{
throw new NotImplementedException();
}

public Task PublishAttributeData(PlayloadData msg)
{
throw new NotImplementedException();
}

public Task PublishConnect(Guid devid, ConnectStatus devicestatus)
{
throw new NotImplementedException();
}

public Task PublishCreateDevice(Guid devid)
{
throw new NotImplementedException();
}

public Task PublishDeleteDevice(Guid devid)
{
throw new NotImplementedException();
}

public Task PublishDeviceAlarm(CreateAlarmDto alarmDto)
{
throw new NotImplementedException();
}

public Task PublishTelemetryData(PlayloadData msg)
{
throw new NotImplementedException();
}
}
}
30 changes: 30 additions & 0 deletions IoTSharp.EventBus.NServiceBus/NSBusSubscriber.cs
@@ -0,0 +1,30 @@

using EasyCaching.Core;
using IoTSharp.Contracts;
using IoTSharp.Data;
using IoTSharp.Data.Extensions;
using IoTSharp.Extensions;
using IoTSharp.Storage;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Threading.Tasks;

namespace IoTSharp.EventBus.NServiceBus
{

public class NSBusSubscriber : EventBusSubscriber, ISubscriber
{
public NSBusSubscriber(ILogger<EventBusSubscriber> logger, IServiceScopeFactory scopeFactor
, IStorage storage, IEasyCachingProviderFactory factory, EventBusOption eventBusOption
) : base(logger, scopeFactor, storage, factory, eventBusOption)
{

}

}
}
6 changes: 6 additions & 0 deletions IoTSharp.sln
Expand Up @@ -109,6 +109,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions.QuartzJ
EndProject
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "ClientApp", "ClientApp\ClientApp.esproj", "{1C9D84A1-5B92-4B53-86D6-61613B70257C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharp.EventBus.NServiceBus", "IoTSharp.EventBus.NServiceBus\IoTSharp.EventBus.NServiceBus.csproj", "{10E377A8-6060-44AA-9678-9F175BE6E24F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -238,6 +240,10 @@ Global
{1C9D84A1-5B92-4B53-86D6-61613B70257C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C9D84A1-5B92-4B53-86D6-61613B70257C}.Release|Any CPU.Build.0 = Release|Any CPU
{1C9D84A1-5B92-4B53-86D6-61613B70257C}.Release|Any CPU.Deploy.0 = Release|Any CPU
{10E377A8-6060-44AA-9678-9F175BE6E24F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10E377A8-6060-44AA-9678-9F175BE6E24F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10E377A8-6060-44AA-9678-9F175BE6E24F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10E377A8-6060-44AA-9678-9F175BE6E24F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit f50a8c7

Please sign in to comment.