diff --git a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj index 36e590b..bb0554b 100644 --- a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj +++ b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj @@ -1,18 +1,6 @@  - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - false - false - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - LICENSE - true 基于Pipeline实现的JT808Gateway的抽象库 基于Pipeline实现的JT808Gateway的抽象库 JT808.Gateway.Abstractions @@ -29,7 +17,7 @@ - + diff --git a/src/JT808.Gateway.Abstractions/JT808MessageHandler.cs b/src/JT808.Gateway.Abstractions/JT808MessageHandler.cs index 65fe306..c8e0e53 100644 --- a/src/JT808.Gateway.Abstractions/JT808MessageHandler.cs +++ b/src/JT808.Gateway.Abstractions/JT808MessageHandler.cs @@ -41,25 +41,25 @@ namespace JT808.Gateway.Abstractions this.JT808Config = jT808Config; this.JT808Serializer = jT808Config.GetSerializer(); HandlerDict = new Dictionary { - {JT808MsgId.终端通用应答.ToUInt16Value(), Msg0x0001}, - {JT808MsgId.终端鉴权.ToUInt16Value(), Msg0x0102}, - {JT808MsgId.终端心跳.ToUInt16Value(), Msg0x0002}, - {JT808MsgId.终端注销.ToUInt16Value(), Msg0x0003}, - {JT808MsgId.终端注册.ToUInt16Value(), Msg0x0100}, - {JT808MsgId.位置信息汇报.ToUInt16Value(),Msg0x0200 }, - {JT808MsgId.定位数据批量上传.ToUInt16Value(),Msg0x0704 }, - {JT808MsgId.数据上行透传.ToUInt16Value(),Msg0x0900 }, - {JT808MsgId.查询服务器时间请求.ToUInt16Value(),Msg0x0004 }, - {JT808MsgId.查询终端参数应答.ToUInt16Value(),Msg0x0104 }, - {JT808MsgId.查询终端属性应答.ToUInt16Value(),Msg0x0107 }, - {JT808MsgId.终端升级结果通知.ToUInt16Value(),Msg0x0108 }, - {JT808MsgId.位置信息查询应答.ToUInt16Value(),Msg0x0201 }, - {JT808MsgId.链路检测.ToUInt16Value(),Msg0x8204 }, - {JT808MsgId.车辆控制应答.ToUInt16Value(),Msg0x0500 }, - {JT808MsgId.摄像头立即拍摄命令.ToUInt16Value(),Msg0x8801 }, - {JT808MsgId.多媒体数据上传.ToUInt16Value(),Msg0x0801 }, - {JT808MsgId.多媒体事件信息上传.ToUInt16Value(),Msg0x0800 }, - {JT808MsgId.CAN总线数据上传.ToUInt16Value(),Msg0x0705 }, + {JT808MsgId._0x0001.ToUInt16Value(), Msg0x0001}, + {JT808MsgId._0x0102.ToUInt16Value(), Msg0x0102}, + {JT808MsgId._0x0002.ToUInt16Value(), Msg0x0002}, + {JT808MsgId._0x0003.ToUInt16Value(), Msg0x0003}, + {JT808MsgId._0x0100.ToUInt16Value(), Msg0x0100}, + {JT808MsgId._0x0200.ToUInt16Value(),Msg0x0200 }, + {JT808MsgId._0x0704.ToUInt16Value(),Msg0x0704 }, + {JT808MsgId._0x0900.ToUInt16Value(),Msg0x0900 }, + {JT808MsgId._0x0004.ToUInt16Value(),Msg0x0004 }, + {JT808MsgId._0x0104.ToUInt16Value(),Msg0x0104 }, + {JT808MsgId._0x0107.ToUInt16Value(),Msg0x0107 }, + {JT808MsgId._0x0108.ToUInt16Value(),Msg0x0108 }, + {JT808MsgId._0x0201.ToUInt16Value(),Msg0x0201 }, + {JT808MsgId._0x8204.ToUInt16Value(),Msg0x8204 }, + {JT808MsgId._0x0500.ToUInt16Value(),Msg0x0500 }, + {JT808MsgId._0x8801 .ToUInt16Value(),Msg0x8801 }, + {JT808MsgId._0x0801.ToUInt16Value(),Msg0x0801 }, + {JT808MsgId._0x0800.ToUInt16Value(),Msg0x0800 }, + {JT808MsgId._0x0705.ToUInt16Value(),Msg0x0705 }, }; } @@ -99,20 +99,20 @@ namespace JT808.Gateway.Abstractions { if (request.Version == JT808Version.JTT2019) { - byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create_平台通用应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8001() + byte[] data = JT808Serializer.Serialize(JT808MsgId._0x8001.Create_平台通用应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8001() { AckMsgId = request.Header.MsgId, - JT808PlatformResult = JT808PlatformResult.成功, + JT808PlatformResult = JT808PlatformResult.succeed, MsgNum = request.Header.MsgNum })); return data; } else { - byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8001() + byte[] data = JT808Serializer.Serialize(JT808MsgId._0x8001.Create(request.Header.TerminalPhoneNo, new JT808_0x8001() { AckMsgId = request.Header.MsgId, - JT808PlatformResult = JT808PlatformResult.成功, + JT808PlatformResult = JT808PlatformResult.succeed, MsgNum = request.Header.MsgNum })); return data; @@ -135,7 +135,7 @@ namespace JT808.Gateway.Abstractions /// public virtual byte[] Msg0x0004(JT808HeaderPackage request) { - byte[] data = JT808Serializer.Serialize(JT808MsgId.查询服务器时间应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8004() + byte[] data = JT808Serializer.Serialize(JT808MsgId._0x8004.Create(request.Header.TerminalPhoneNo, new JT808_0x8004() { Time = DateTime.Now })); @@ -168,20 +168,20 @@ namespace JT808.Gateway.Abstractions { if (request.Version == JT808Version.JTT2019) { - byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create_终端注册应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8100() + byte[] data = JT808Serializer.Serialize(JT808MsgId._0x8100.Create_终端注册应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8100() { Code = "J" + request.Header.TerminalPhoneNo, - JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功, + JT808TerminalRegisterResult = JT808TerminalRegisterResult.success, AckMsgNum = request.Header.MsgNum })); return data; } else { - byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8100() + byte[] data = JT808Serializer.Serialize(JT808MsgId._0x8100.Create(request.Header.TerminalPhoneNo, new JT808_0x8100() { Code = "J" + request.Header.TerminalPhoneNo, - JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功, + JT808TerminalRegisterResult = JT808TerminalRegisterResult.success, AckMsgNum = request.Header.MsgNum })); return data; diff --git a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs index 3077c2b..a6eec5a 100644 --- a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs +++ b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Program.cs @@ -19,6 +19,17 @@ namespace JT808.Gateway.CleintBenchmark { static async Task Main(string[] args) { + //var builder = WebApplication.CreateBuilder(args); + //var app = builder.Build(); + //app.MapGet("/weatherforecast", async context => + //{ + + + + //}).WithName("GetWeatherForecast"); + + + var serverHostBuilder = new HostBuilder() .ConfigureAppConfiguration((hostingContext, config) => { @@ -29,6 +40,7 @@ namespace JT808.Gateway.CleintBenchmark { webBuilder.Configure(app => { + app.UseRouting(); app.UseCors("Domain"); app.UseStaticFiles(); diff --git a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs index 8794fe2..949db93 100644 --- a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs +++ b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs @@ -63,7 +63,7 @@ namespace JT808.Gateway.CleintBenchmark.Services int Lng = new Random(1000).Next(100000, 180000); if (client != null) { - await client.SendAsync(JT808MsgId.位置信息汇报.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() + await client.SendAsync(JT808MsgId._0x0200.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() { Lat = lat, Lng = Lng, diff --git a/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj b/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj index 1f68a8f..c5dfc08 100644 --- a/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj +++ b/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj @@ -1,20 +1,7 @@  - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.Client JT808.Gateway.Client 基于pipeline实现的JT808客户端工具 @@ -23,9 +10,9 @@ - + - + diff --git a/src/JT808.Gateway.Client/JT808TcpClient.cs b/src/JT808.Gateway.Client/JT808TcpClient.cs index b714e72..422e13e 100644 --- a/src/JT808.Gateway.Client/JT808TcpClient.cs +++ b/src/JT808.Gateway.Client/JT808TcpClient.cs @@ -71,12 +71,12 @@ namespace JT808.Gateway.Client } if(DeviceConfig.Version== Protocol.Enums.JT808Version.JTT2013 || DeviceConfig.Version == Protocol.Enums.JT808Version.JTT2011) { - var package = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create(DeviceConfig.TerminalPhoneNo); + var package = JT808.Protocol.Enums.JT808MsgId._0x0002.Create(DeviceConfig.TerminalPhoneNo); await SendAsync(new JT808ClientRequest(package)); } else { - var package = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create2019(DeviceConfig.TerminalPhoneNo); + var package = JT808.Protocol.Enums.JT808MsgId._0x0002.Create2019(DeviceConfig.TerminalPhoneNo); await SendAsync(new JT808ClientRequest(package)); } } diff --git a/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj index cc84117..076a302 100644 --- a/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj +++ b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj @@ -1,24 +1,11 @@  - - - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - false - LICENSE - true + + JT808.Gateway.Kafka JT808.Gateway.Kafka 基于Kafka的JT808消息发布与订阅 基于Kafka的JT808消息发布与订阅 JT808.Gateway.Kafka.xml - $(JT808GatewayPackageVersion) diff --git a/src/JT808.Gateway.Services/JT808.Gateway.MsgIdHandler/JT808.Gateway.MsgIdHandler.csproj b/src/JT808.Gateway.Services/JT808.Gateway.MsgIdHandler/JT808.Gateway.MsgIdHandler.csproj index f0af579..663628e 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.MsgIdHandler/JT808.Gateway.MsgIdHandler.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.MsgIdHandler/JT808.Gateway.MsgIdHandler.csproj @@ -1,20 +1,6 @@  - - + - netstandard2.1;net6.0; - 9.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.MsgIdHandler JT808.Gateway.MsgIdHandler 基于JT808消息业务处理程序服务 diff --git a/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj index 1ab7b48..da02136 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj @@ -1,20 +1,7 @@  - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.MsgLogging JT808.Gateway.MsgLogging 基于JT808消息上下行日志服务 diff --git a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj index ee4a726..c284f83 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj @@ -1,19 +1,6 @@  - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.ReplyMessage JT808.Gateway.ReplyMessage 基于JT808消息业务处理程序服务 diff --git a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj index 4a99f51..46e9ba9 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj @@ -1,20 +1,7 @@  - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.SessionNotice JT808.Gateway.SessionNotice 基于JT808会话通知服务 diff --git a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj index 76b32b3..d4624f6 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj @@ -1,20 +1,6 @@  - - + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.Transmit JT808.Gateway.Transmit 基于JT808实现的数据转发服务 diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj index 131c6d6..f87c610 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs index af3fcd7..e34bb91 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs @@ -39,7 +39,7 @@ namespace JT808.Gateway.NormalHosting.Jobs { int lat = new Random(1000).Next(100000, 180000); int Lng = new Random(1000).Next(100000, 180000); - await client.SendAsync(JT808MsgId.位置信息汇报.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() + await client.SendAsync(JT808MsgId._0x0200.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() { Lat = lat, Lng = Lng, @@ -53,7 +53,7 @@ namespace JT808.Gateway.NormalHosting.Jobs int lat1 = new Random(1000).Next(100000, 180000); int Lng1 = new Random(1000).Next(100000, 180000); - await client1.SendAsync(JT808MsgId.位置信息汇报.Create(client1.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() + await client1.SendAsync(JT808MsgId._0x0200.Create(client1.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() { Lat = lat1, Lng = Lng1, diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs index 7991612..5ebb574 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs @@ -15,62 +15,69 @@ using JT808.Gateway.SessionNotice; using JT808.Gateway.Client; using JT808.Gateway.NormalHosting.Jobs; using JT808.Gateway.WebApiClientTool; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Server; namespace JT808.Gateway.NormalHosting { class Program { - static async Task Main(string[] args) + static void Main(string[] args) { - var serverHostBuilder = new HostBuilder() - .ConfigureAppConfiguration((hostingContext, config) => - { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{ hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((context, logging) => - { - Console.WriteLine($"Environment.OSVersion.Platform:{Environment.OSVersion.Platform.ToString()}"); - NLog.LogManager.LoadConfiguration($"Configs/nlog.{Environment.OSVersion.Platform.ToString()}.config"); - logging.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true }); - logging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => - { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - //使用内存队列实现会话通知 - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - //使用内存队列实现应答生产消费 - services.AddSingleton(); - services.AddSingleton(); - services.AddJT808Configure() - //添加客户端工具 - .AddClient() - .Builder() - //方式1:客户端webapi调用 - .AddWebApiClientTool(hostContext.Configuration) - .AddGateway(hostContext.Configuration) - .AddMessageHandler() - .AddMsgReplyConsumer() - .AddMsgLogging() - .AddSessionNotice() - .AddTransmit(hostContext.Configuration) - .AddTcp() - .AddUdp() - .AddHttp(); - //方式2:客户端webapi调用 - //services.AddJT808WebApiClientTool(hostContext.Configuration); - //httpclient客户端调用 - //services.AddHostedService(); - //客户端测试 依赖AddClient()服务 - //services.AddHostedService(); - }); + var builder = WebApplication.CreateBuilder(args); + builder.Host.ConfigureAppConfiguration((hostingContext, config) => + { + + config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{ hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); + }) + .ConfigureLogging((context, logging) => + { + Console.WriteLine($"Environment.OSVersion.Platform:{Environment.OSVersion.Platform.ToString()}"); + NLog.LogManager.LoadConfiguration($"Configs/nlog.{Environment.OSVersion.Platform.ToString()}.config"); + logging.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true }); + logging.SetMinimumLevel(LogLevel.Trace); + }) + .ConfigureServices((hostContext, services) => + { + services.AddSingleton(); + services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); + //使用内存队列实现会话通知 + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + //使用内存队列实现应答生产消费 + services.AddSingleton(); + services.AddSingleton(); + services.AddJT808Configure() + //添加客户端工具 + .AddClient() + .Builder() + //方式1:客户端webapi调用 + .AddWebApiClientTool(hostContext.Configuration) + .AddGateway(hostContext.Configuration) + .AddMessageHandler() + .AddMsgReplyConsumer() + .AddMsgLogging() + .AddSessionNotice() + .AddTransmit(hostContext.Configuration) + .AddTcp() + .AddUdp() + .AddHttp(); + //方式2:客户端webapi调用 + //services.AddJT808WebApiClientTool(hostContext.Configuration); + //httpclient客户端调用 + //services.AddHostedService(); + //客户端测试 依赖AddClient()服务 + //services.AddHostedService(); + }); - await serverHostBuilder.RunConsoleAsync(); + var app = builder.Build(); + app.UseJT808MiniWebApi(); + + app.Run(); } } } diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs index 01ad297..710c172 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs @@ -39,7 +39,7 @@ namespace JT808.Gateway.QueueHosting.Jobs { int lat = new Random(1000).Next(100000, 180000); int Lng = new Random(1000).Next(100000, 180000); - await client.SendAsync(JT808MsgId.位置信息汇报.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() + await client.SendAsync(JT808MsgId._0x0200.Create(client.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() { Lat = lat, Lng = Lng, @@ -52,7 +52,7 @@ namespace JT808.Gateway.QueueHosting.Jobs })); int lat1 = new Random(1000).Next(100000, 180000); int Lng1 = new Random(1000).Next(100000, 180000); - await client1.SendAsync(JT808MsgId.位置信息汇报.Create(client1.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() + await client1.SendAsync(JT808MsgId._0x0200.Create(client1.DeviceConfig.TerminalPhoneNo, new JT808_0x0200() { Lat = lat1, Lng = Lng1, diff --git a/src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj b/src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj index 57f866a..a24d03d 100644 --- a/src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj +++ b/src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj @@ -1,19 +1,6 @@  - + - netstandard2.1;net6.0; - 9.0 - Copyright 2019. - SmallChi(Koike) - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - false - $(JT808GatewayPackageVersion) - false - LICENSE - true JT808.Gateway.WebApiClientTool JT808.Gateway.WebApiClientTool JT808WebApiClient客户端调用工具 diff --git a/src/JT808.Gateway.sln b/src/JT808.Gateway.sln index 712022c..9f3e85c 100644 --- a/src/JT808.Gateway.sln +++ b/src/JT808.Gateway.sln @@ -41,7 +41,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.MsgIdHandler" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2336747A-28A3-443E-8E23-4B25E3F2D971}" ProjectSection(SolutionItems) = preProject - Version.props = Version.props + PipelineInfo.props = PipelineInfo.props EndProjectSection EndProject Global diff --git a/src/JT808.Gateway/JT808.Gateway.csproj b/src/JT808.Gateway/JT808.Gateway.csproj index ed0326d..d02c693 100644 --- a/src/JT808.Gateway/JT808.Gateway.csproj +++ b/src/JT808.Gateway/JT808.Gateway.csproj @@ -1,24 +1,12 @@ - - + + - netstandard2.1;net6.0; - 10.0 - Copyright 2019. - SmallChi(Koike) - false - false - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE - LICENSE - true 基于Pipeline实现的JT808Gateway的网络库 基于Pipeline实现的JT808Gateway的网络库 JT808.Gateway.xml JT808.Gateway JT808.Gateway - $(JT808GatewayPackageVersion) + Library @@ -27,7 +15,7 @@ - + diff --git a/src/JT808.Gateway/JT808.Gateway.xml b/src/JT808.Gateway/JT808.Gateway.xml index b15b7aa..001106c 100644 --- a/src/JT808.Gateway/JT808.Gateway.xml +++ b/src/JT808.Gateway/JT808.Gateway.xml @@ -198,6 +198,18 @@ + + + + + + + + + + + + 808 tcp服务器 diff --git a/src/JT808.Gateway/JT808MiniWebApi.cs b/src/JT808.Gateway/JT808MiniWebApi.cs new file mode 100644 index 0000000..4fbe9bd --- /dev/null +++ b/src/JT808.Gateway/JT808MiniWebApi.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Http; +using JT808.Gateway.Abstractions; +using JT808.Gateway.Abstractions.Dtos; +using System.Text.Json; +using Microsoft.Extensions.DependencyInjection; +using JT808.Gateway.Session; +using JT808.Gateway.Services; +using System; + +namespace JT808.Gateway +{ + /// + /// + /// + public static class JT808MiniWebApi + { + /// + /// + /// + /// + /// + public static void UseJT808MiniWebApi(this WebApplication app) + { + //CreateRoute(JT808GatewayConstants.JT808WebApiRouteTable.UnificationSend, UnificationSend); + //CreateRoute(JT808GatewayConstants.JT808WebApiRouteTable.BlacklistAdd, BlacklistAdd); + //CreateRoute(JT808GatewayConstants.JT808WebApiRouteTable.BlacklistRemove, BlacklistRemove); + //CreateRoute(JT808GatewayConstants.JT808WebApiRouteTable.BlacklistGet, QueryBlacklist); + app.MapPost(JT808GatewayConstants.JT808WebApiRouteTable.UnificationSend,async context => + { + JT808ResultDto resultDto = new JT808ResultDto(); + JT808SessionManager SessionManager = context.RequestServices.GetRequiredService(); + JT808BlacklistManager BlacklistManager = context.RequestServices.GetRequiredService(); + try + { + JT808UnificationSendRequestDto jT808UnificationSendRequestDto = JsonSerializer.Deserialize(context.Request.Body); + resultDto.Data = await SessionManager.TrySendByTerminalPhoneNoAsync(jT808UnificationSendRequestDto.TerminalPhoneNo,Convert.FromHexString(jT808UnificationSendRequestDto.HexData)); + resultDto.Code = JT808ResultCode.Ok; + } + catch (Exception ex) + { + resultDto.Data = false; + resultDto.Code = JT808ResultCode.Error; + resultDto.Message = ex.StackTrace; + } + await context.Response.WriteAsJsonAsync(resultDto); + }); + } + } +} diff --git a/src/PipelineInfo.props b/src/PipelineInfo.props new file mode 100644 index 0000000..7e623a8 --- /dev/null +++ b/src/PipelineInfo.props @@ -0,0 +1,33 @@ + + + net6.0 + 10.0 + Copyright 2019. + SmallChi(Koike) + https://github.com/SmallChi/JT808Gateway + https://github.com/SmallChi/JT808Gateway + https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE + https://github.com/SmallChi/JT808Gateway/blob/master/LICENSE + 1.1.8-preview1 + LICENSE + true + latest + true + true + false + README.md + true + true + embedded + + + + true + true + true + + + + + + \ No newline at end of file diff --git a/src/Version.props b/src/Version.props index 77f6f84..cfc6d11 100644 --- a/src/Version.props +++ b/src/Version.props @@ -1,6 +1,5 @@  2.3.6 - 1.1.7 \ No newline at end of file