Ver a proveniência

pipeline-previwe2

1.完善并测试对应的功能
2.升级core版本和库版本
tags/pipeline-1.1.0
SmallChi(Koike) há 4 anos
ascendente
cometimento
6f4ae0c9dc
34 ficheiros alterados com 208 adições e 562 eliminações
  1. +0
    -18
      src/JT808.Gateway.Abstractions/Enums/JT808UseType.cs
  2. +4
    -4
      src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj
  3. +8
    -0
      src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml
  4. +0
    -307
      src/JT808.Gateway.Abstractions/JT808QueueReplyMessageHandler.cs
  5. +4
    -4
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/JT808.Gateway.CleintBenchmark.csproj
  6. +2
    -2
      src/JT808.Gateway.Benchmark/JT808.Gateway.ServerBenchmark/JT808.Gateway.ServerBenchmark.csproj
  7. +6
    -6
      src/JT808.Gateway.Client/JT808.Gateway.Client.csproj
  8. +7
    -12
      src/JT808.Gateway.Client/JT808TcpClient.cs
  9. +1
    -1
      src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj
  10. +1
    -1
      src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj
  11. +1
    -1
      src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj
  12. +1
    -1
      src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj
  13. +0
    -2
      src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeHostedService.cs
  14. +1
    -5
      src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs
  15. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Configs/nlog.Unix.config
  16. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Configs/nlog.Win32NT.config
  17. +8
    -9
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs
  18. +3
    -6
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj
  19. +0
    -76
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs
  20. +54
    -0
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallHttpClientJob.cs
  21. +10
    -9
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs
  22. +5
    -0
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json
  23. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Configs/nlog.Unix.config
  24. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Configs/nlog.Win32NT.config
  25. +3
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj
  26. +0
    -69
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/CallGrpcClientJob.cs
  27. +54
    -0
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/CallHttpClientJob.cs
  28. +14
    -16
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs
  29. +6
    -0
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/appsettings.json
  30. +4
    -4
      src/JT808.Gateway.Tests/JT808.Gateway.Test/JT808.Gateway.Test.csproj
  31. +1
    -1
      src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj
  32. +1
    -1
      src/JT808.Gateway/JT808.Gateway.csproj
  33. +4
    -0
      src/JT808.Gateway/JT808UdpServer.cs
  34. +1
    -1
      src/Version.props

+ 0
- 18
src/JT808.Gateway.Abstractions/Enums/JT808UseType.cs Ver ficheiro

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Enums
{
public enum JT808UseType : byte
{
/// <summary>
/// 使用正常方式
/// </summary>
Normal = 1,
/// <summary>
/// 使用队列方式
/// </summary>
Queue = 2
}
}

+ 4
- 4
src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj Ver ficheiro

@@ -32,10 +32,10 @@
<Compile Remove="JT808QueueReplyMessageHandler.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JT808" Version="2.2.12" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="JT808" Version="2.2.13" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />


+ 8
- 0
src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.xml Ver ficheiro

@@ -106,6 +106,14 @@
<param name="terminalNo">设备终端号</param>
<param name="data">808 hex data</param>
</member>
<member name="M:JT808.Gateway.Abstractions.IJT808ReplyMessageHandler.Processor(System.String,System.Byte[])">
<summary>
</summary>
<param name="TerminalNo">请求数据</param>
<param name="Data">当前会话</param>
<returns>应答消息数据</returns>
</member>
<member name="P:JT808.Gateway.Abstractions.IJT808Session.TerminalPhoneNo">
<summary>
终端手机号


+ 0
- 307
src/JT808.Gateway.Abstractions/JT808QueueReplyMessageHandler.cs Ver ficheiro

@@ -1,307 +0,0 @@
using JT808.Protocol;
using JT808.Protocol.Enums;
using JT808.Protocol.Extensions;
using JT808.Protocol.MessageBody;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Abstractions
{
public class JT808QueueReplyMessageHandler
{
protected Dictionary<ushort, MsgIdMethodDelegate> HandlerDict { get; }

protected delegate byte[] MsgIdMethodDelegate(JT808HeaderPackage package);
protected JT808Serializer JT808Serializer { get; }
protected IJT808MsgReplyProducer JT808MsgReplyProducer { get; }
public JT808QueueReplyMessageHandler(
IJT808Config jT808Config,
IJT808MsgReplyProducer jT808MsgReplyProducer)
{
this.JT808Serializer = jT808Config.GetSerializer();
this.JT808MsgReplyProducer = jT808MsgReplyProducer;
HandlerDict = new Dictionary<ushort, MsgIdMethodDelegate> {
{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 },
};
}

public virtual void Processor((string TerminalNo, byte[] Data) parameter)
{
var request = JT808Serializer.HeaderDeserialize(parameter.Data);
if (HandlerDict.TryGetValue(request.Header.MsgId, out var func))
{
var buffer = func(request);
if (buffer != null)
{
JT808MsgReplyProducer.ProduceAsync(parameter.TerminalNo, buffer);
}
}
}

/// <summary>
/// 终端通用应答
/// 平台无需回复
/// 实现自己的业务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0001(JT808HeaderPackage request)
{
return default;
}
/// <summary>
/// 平台通用应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
public virtual byte[] CommonReply(JT808HeaderPackage request)
{
if (request.Version == JT808Version.JTT2019)
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create_平台通用应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8001()
{
AckMsgId = request.Header.MsgId,
JT808PlatformResult = JT808PlatformResult.成功,
MsgNum = request.Header.MsgNum
}));
return data;
}
else
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8001()
{
AckMsgId = request.Header.MsgId,
JT808PlatformResult = JT808PlatformResult.成功,
MsgNum = request.Header.MsgNum
}));
return data;
}
}
/// <summary>
/// 终端心跳
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0002(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 查询服务器时间
/// 2019版本
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0004(JT808HeaderPackage request)
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.查询服务器时间应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8004()
{
Time = DateTime.Now
}));
return data;
}
/// <summary>
/// 服务器补传分包请求
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x8003(JT808HeaderPackage request)
{
throw new NotImplementedException("0x8003-服务器补传分包请求");
}
/// <summary>
/// 终端补传分包请求
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0005(JT808HeaderPackage request)
{
throw new NotImplementedException("0x0005-终端补传分包请求");
}
/// <summary>
/// 终端注册
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0100(JT808HeaderPackage request)
{
if (request.Version == JT808Version.JTT2019)
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create_终端注册应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8100()
{
Code = "J" + request.Header.TerminalPhoneNo,
JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功,
AckMsgNum = request.Header.MsgNum
}));
return data;
}
else
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8100()
{
Code = "J" + request.Header.TerminalPhoneNo,
JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功,
AckMsgNum = request.Header.MsgNum
}));
return data;
}
}
/// <summary>
/// 终端注销
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0003(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 终端鉴权
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0102(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 查询终端参数应答
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0104(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 查询终端属性应答
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0107(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 终端升级结果应答
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0108(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 位置信息汇报
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0200(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 位置信息查询应答
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0201(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 链路检测
/// 2019版本
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x8204(JT808HeaderPackage request)
{
return default;
}
/// <summary>
/// 车辆控制应答
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0500(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 定位数据批量上传
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0704(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// CAN总线数据上传
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0705(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 多媒体事件信息上传
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0800(JT808HeaderPackage request)
{
return CommonReply(request);
}
/// <summary>
/// 多媒体数据上传
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0801(JT808HeaderPackage request)
{
throw new NotImplementedException("0x8800多媒体数据上传应答");
}
/// <summary>
/// 摄像头立即拍摄命令
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x8801(JT808HeaderPackage request)
{
throw new NotImplementedException("0x0805摄像头立即拍摄命令应答");
}
/// <summary>
/// 数据上行透传
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0900(JT808HeaderPackage request)
{
return CommonReply(request);
}
}
}

+ 4
- 4
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/JT808.Gateway.CleintBenchmark.csproj Ver ficheiro

@@ -12,10 +12,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
</ItemGroup>



+ 2
- 2
src/JT808.Gateway.Benchmark/JT808.Gateway.ServerBenchmark/JT808.Gateway.ServerBenchmark.csproj Ver ficheiro

@@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
</ItemGroup>


+ 6
- 6
src/JT808.Gateway.Client/JT808.Gateway.Client.csproj Ver ficheiro

@@ -22,12 +22,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JT808" Version="2.2.12" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.7" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="JT808" Version="2.2.13" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.9" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />


+ 7
- 12
src/JT808.Gateway.Client/JT808TcpClient.cs Ver ficheiro

@@ -225,20 +225,15 @@ namespace JT808.Gateway.Client
public void Close()
{
if (disposed) return;
var socket = clientSocket;
if (socket == null)
return;
if (Interlocked.CompareExchange(ref clientSocket, null, socket) == socket)
if (clientSocket == null) return;
try
{
try
{
clientSocket.Shutdown(SocketShutdown.Both);
}
finally
{
clientSocket.Close();
}
clientSocket?.Shutdown(SocketShutdown.Both);
}
finally
{
clientSocket?.Close();
}
}

private void Dispose(bool disposing)


+ 1
- 1
src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj Ver ficheiro

@@ -26,7 +26,7 @@
<DocumentationFile>JT808.Gateway.Kafka.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="1.5.1" />
<PackageReference Include="Confluent.Kafka" Version="1.5.2" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808.Gateway.MsgLogging.csproj Ver ficheiro

@@ -22,7 +22,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />


+ 1
- 1
src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808.Gateway.ReplyMessage.csproj Ver ficheiro

@@ -21,7 +21,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />


+ 1
- 1
src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808.Gateway.SessionNotice.csproj Ver ficheiro

@@ -22,7 +22,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />


+ 0
- 2
src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeHostedService.cs Ver ficheiro

@@ -1,6 +1,4 @@
using System.Threading.Tasks;
using JT808.Protocol;
using JT808.Protocol.Interfaces;
using Microsoft.Extensions.Hosting;
using System.Threading;
using JT808.Gateway.Abstractions;


+ 1
- 5
src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs Ver ficheiro

@@ -1,8 +1,4 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Logging;

namespace JT808.Gateway.SessionNotice
{


+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Configs/nlog.Unix.config Ver ficheiro

@@ -31,6 +31,6 @@
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" maxlevel="Fatal" writeTo="Gateway"/>
<logger name="JT808.*" minlevel="Info" maxlevel="Fatal" writeTo="Gateway"/>
</rules>
</nlog>

+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Configs/nlog.Win32NT.config Ver ficheiro

@@ -31,6 +31,6 @@
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="Gateway,console"/>
<logger name="JT808.*" minlevel="Trace" maxlevel="Fatal" writeTo="Gateway,console"/>
</rules>
</nlog>

+ 8
- 9
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs Ver ficheiro

@@ -14,7 +14,7 @@ namespace JT808.Gateway.NormalHosting.Impl
public class JT808CustomMessageHandlerImpl : JT808MessageHandler
{
private readonly ILogger logger;
//private readonly JT808TransmitService jT808TransmitService;
private readonly JT808TransmitService jT808TransmitService;
private readonly IJT808MsgLogging jT808MsgLogging;
private readonly IJT808MsgReplyProducer MsgReplyProducer;

@@ -25,13 +25,14 @@ namespace JT808.Gateway.NormalHosting.Impl
IOptionsMonitor<JT808Configuration> jT808ConfigurationOptionsMonitor,
IJT808MsgProducer msgProducer,
IJT808MsgReplyLoggingProducer msgReplyLoggingProducer,
JT808TransmitService jT808TransmitService,
IJT808Config jT808Config) : base(jT808ConfigurationOptionsMonitor,
msgProducer,
msgReplyLoggingProducer,
jT808Config)
{
MsgReplyProducer = msgReplyProducer;
//this.jT808TransmitService = jT808TransmitService;
this.jT808TransmitService = jT808TransmitService;
this.jT808MsgLogging = jT808MsgLogging;
logger = loggerFactory.CreateLogger<JT808CustomMessageHandlerImpl>();
//添加自定义消息
@@ -53,15 +54,13 @@ namespace JT808.Gateway.NormalHosting.Impl
{
//AOP 可以自定义添加一些东西:上下行日志、
logger.LogDebug("可以自定义添加一些东西:上下行日志、数据转发");
//流量
//jT808Traffic.Increment(request.Header.TerminalPhoneNo, DateTime.Now.ToString("yyyyMMdd"), request.OriginalData.Length);
var parameter = (request.Header.TerminalPhoneNo, request.OriginalData.ToArray());
////上行日志(可同步也可以使用队列进行异步)
//jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up);
////下行日志(可同步也可以使用队列进行异步)
//上行日志(可同步也可以使用队列进行异步)
jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up);
//下行日志(可同步也可以使用队列进行异步)
jT808MsgLogging.Processor((request.Header.TerminalPhoneNo, down), JT808MsgLoggingType.down);
////转发数据(可同步也可以使用队列进行异步)
//jT808TransmitService.SendAsync(parameter);
//转发数据(可同步也可以使用队列进行异步)
jT808TransmitService.SendAsync(parameter);
}
catch (Exception)
{


+ 3
- 6
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj Ver ficheiro

@@ -5,14 +5,10 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Jobs\CallGrpcClientJob.cs" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
</ItemGroup>
@@ -22,6 +18,7 @@
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.MsgLogging\JT808.Gateway.MsgLogging.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.SessionNotice\JT808.Gateway.SessionNotice.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.Transmit\JT808.Gateway.Transmit.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj" />
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" />
</ItemGroup>



+ 0
- 76
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs Ver ficheiro

@@ -1,76 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
using JT808.Gateway.Configurations;
using JT808.Gateway.GrpcService;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Text.Json;
using JT808.Protocol.Extensions;
using Microsoft.Extensions.Options;

namespace JT808.Gateway.NormalHosting.Jobs
{
public class CallGrpcClientJob :IHostedService
{
private Channel channel;
private readonly ILogger Logger;
private Grpc.Core.Metadata AuthMetadata;
public CallGrpcClientJob(
ILoggerFactory loggerFactory,
IOptions<JT808Configuration> configurationAccessor)
{
Logger = loggerFactory.CreateLogger("CallGrpcClientJob");
channel = new Channel($"{configurationAccessor.Value.WebApiHost}:{configurationAccessor.Value.WebApiPort}",
ChannelCredentials.Insecure);
AuthMetadata = new Grpc.Core.Metadata();
AuthMetadata.Add("token", configurationAccessor.Value.WebApiToken);
}

public Task StartAsync(CancellationToken cancellationToken)
{
Task.Run(() =>
{
while (!cancellationToken.IsCancellationRequested)
{
JT808Gateway.JT808GatewayClient jT808GatewayClient = new JT808Gateway.JT808GatewayClient(channel);
try
{
var result1 = jT808GatewayClient.GetTcpAtomicCounter(new Empty(), AuthMetadata);
var result2 = jT808GatewayClient.GetTcpSessionAll(new Empty(), AuthMetadata);
var result3 = jT808GatewayClient.UnificationSend(new UnificationSendRequest
{
TerminalPhoneNo= "123456789012",
Data=Google.Protobuf.ByteString.CopyFrom("7E02000026123456789012007D02000000010000000200BA7F0E07E4F11C0028003C00001810151010100104000000640202007D01137E".ToHexBytes())
}, AuthMetadata);
Logger.LogInformation($"[GetTcpAtomicCounter]:{JsonSerializer.Serialize(result1)}");
Logger.LogInformation($"[GetTcpSessionAll]:{JsonSerializer.Serialize(result2)}");
}
catch (Exception ex)
{
Logger.LogError(ex, "Call Grpc Error");
}
try
{
var result1 = jT808GatewayClient.GetTcpAtomicCounter(new Empty());
}
catch (RpcException ex)
{
Logger.LogError($"{ex.StatusCode.ToString()}-{ex.Message}");
}
Thread.Sleep(3000);
}
}, cancellationToken);
return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
channel.ShutdownAsync();
return Task.CompletedTask;
}
}
}

+ 54
- 0
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallHttpClientJob.cs Ver ficheiro

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Text.Json;
using JT808.Protocol.Extensions;
using Microsoft.Extensions.Options;
using JT808.Gateway.Abstractions.Configurations;
using JT808.Gateway.WebApiClientTool;

namespace JT808.Gateway.NormalHosting.Jobs
{
public class CallHttpClientJob :IHostedService
{

private readonly ILogger Logger;
private JT808HttpClient jT808HttpClient;
public CallHttpClientJob(
ILoggerFactory loggerFactory,
JT808HttpClient jT808HttpClient)
{
Logger = loggerFactory.CreateLogger<CallHttpClientJob>();
this.jT808HttpClient = jT808HttpClient;
}

public Task StartAsync(CancellationToken cancellationToken)
{
Task.Run(async() =>
{
while (!cancellationToken.IsCancellationRequested)
{
var result2 = await jT808HttpClient.GetTcpSessionAll();
var result3 = await jT808HttpClient.UnificationSend(new Abstractions.Dtos.JT808UnificationSendRequestDto
{
TerminalPhoneNo= "123456789012",
HexData= "7E02000026123456789012007D02000000010000000200BA7F0E07E4F11C0028003C00001810151010100104000000640202007D01137E"
});
Logger.LogInformation($"[GetTcpAtomicCounter]:{JsonSerializer.Serialize(result2)}");
Logger.LogInformation($"[GetTcpSessionAll]:{JsonSerializer.Serialize(result3)}");
Thread.Sleep(3000);
}
}, cancellationToken);
return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}

+ 10
- 9
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs Ver ficheiro

@@ -14,6 +14,7 @@ using JT808.Gateway.Abstractions;
using JT808.Gateway.SessionNotice;
using JT808.Gateway.Client;
using JT808.Gateway.NormalHosting.Jobs;
using JT808.Gateway.WebApiClientTool;

namespace JT808.Gateway.NormalHosting
{
@@ -48,23 +49,23 @@ namespace JT808.Gateway.NormalHosting
services.AddSingleton<IJT808MsgReplyProducer, JT808MsgReplyProducer>();
services.AddJT808Configure()
//添加客户端工具
//.AddClient()
.AddClient()
.Builder()
.AddGateway(hostContext.Configuration)
.AddMessageHandler<JT808CustomMessageHandlerImpl>()
.AddMsgReplyConsumer<JT808MsgReplyConsumer>()
.AddMsgLogging<JT808MsgLogging>()
//.AddSessionNotice()
//.AddTransmit(hostContext.Configuration)
.AddSessionNotice()
.AddTransmit(hostContext.Configuration)
.AddTcp()
//.AddUdp()
.AddUdp()
.AddHttp()
.Register();//必须注册的
//流量统计
//services.AddHostedService<TrafficJob>();
//grpc客户端调用
//services.AddHostedService<CallGrpcClientJob>();
services.AddJT808WebApiClientTool(hostContext.Configuration);
//httpclient客户端调用
services.AddHostedService<CallHttpClientJob>();
//客户端测试 依赖AddClient()服务
//services.AddHostedService<UpJob>();
services.AddHostedService<UpJob>();
});

await serverHostBuilder.RunConsoleAsync();


+ 5
- 0
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/appsettings.json Ver ficheiro

@@ -3,9 +3,14 @@
"TcpPort": 808,
"UdpPort": 808,
"WebApiPort": 828,
"Token": "123456",
"MiniNumBufferSize": 51200,
"SoBacklog": 65535
},
"JT808WebApiClientToolConfig": {
"Token": "123456",
"Uri": "http://127.0.0.1:828/"
},
"RemoteServerOptions": {
"DataTransfer": [
{


+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Configs/nlog.Unix.config Ver ficheiro

@@ -31,6 +31,6 @@
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" maxlevel="Fatal" writeTo="Gateway"/>
<logger name="JT808.*" minlevel="Info" maxlevel="Fatal" writeTo="Gateway"/>
</rules>
</nlog>

+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Configs/nlog.Win32NT.config Ver ficheiro

@@ -31,6 +31,6 @@
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="Gateway,console"/>
<logger name="JT808.*" minlevel="Trace" maxlevel="Fatal" writeTo="Gateway,console"/>
</rules>
</nlog>

+ 3
- 2
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj Ver ficheiro

@@ -10,8 +10,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
</ItemGroup>
@@ -23,6 +23,7 @@
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.ReplyMessage\JT808.Gateway.ReplyMessage.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.SessionNotice\JT808.Gateway.SessionNotice.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.Transmit\JT808.Gateway.Transmit.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj" />
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" />
</ItemGroup>



+ 0
- 69
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/CallGrpcClientJob.cs Ver ficheiro

@@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
using JT808.Gateway.Configurations;
using JT808.Gateway.GrpcService;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Text.Json;

namespace JT808.Gateway.QueueHosting.Jobs
{
public class CallGrpcClientJob :IHostedService
{
private Channel channel;
private readonly ILogger Logger;
private Grpc.Core.Metadata AuthMetadata;
public CallGrpcClientJob(
ILoggerFactory loggerFactory,
JT808Configuration configuration)
{
Logger = loggerFactory.CreateLogger("CallGrpcClientJob");
channel = new Channel($"{configuration.WebApiHost}:{configuration.WebApiPort}",
ChannelCredentials.Insecure);
AuthMetadata = new Grpc.Core.Metadata();
AuthMetadata.Add("token", configuration.WebApiToken);
}

public Task StartAsync(CancellationToken cancellationToken)
{
Task.Run(() =>
{
while (!cancellationToken.IsCancellationRequested)
{
JT808Gateway.JT808GatewayClient jT808GatewayClient = new JT808Gateway.JT808GatewayClient(channel);
try
{
var result1 = jT808GatewayClient.GetTcpAtomicCounter(new Empty(), AuthMetadata);
var result2 = jT808GatewayClient.GetTcpSessionAll(new Empty(), AuthMetadata);
Logger.LogInformation($"[GetTcpAtomicCounter]:{JsonSerializer.Serialize(result1)}");
Logger.LogInformation($"[GetTcpSessionAll]:{JsonSerializer.Serialize(result2)}");
}
catch (Exception ex)
{
Logger.LogError(ex, "Call Grpc Error");
}
try
{
var result1 = jT808GatewayClient.GetTcpAtomicCounter(new Empty());
}
catch (RpcException ex)
{
Logger.LogError($"{ex.StatusCode.ToString()}-{ex.Message}");
}
Thread.Sleep(3000);
}
}, cancellationToken);
return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
channel.ShutdownAsync();
return Task.CompletedTask;
}
}
}

+ 54
- 0
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/CallHttpClientJob.cs Ver ficheiro

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Text.Json;
using JT808.Gateway.Abstractions.Configurations;
using JT808.Gateway.WebApiClientTool;

namespace JT808.Gateway.QueueHosting.Jobs
{
public class CallHttpClientJob : IHostedService
{

private readonly ILogger Logger;
private JT808HttpClient jT808HttpClient;
public CallHttpClientJob(
ILoggerFactory loggerFactory,
JT808HttpClient jT808HttpClient)
{
Logger = loggerFactory.CreateLogger<CallHttpClientJob>();
this.jT808HttpClient = jT808HttpClient;
}

public Task StartAsync(CancellationToken cancellationToken)
{
Task.Run(async() =>
{
while (!cancellationToken.IsCancellationRequested)
{

try
{
var result2 = await jT808HttpClient.GetTcpSessionAll();
Logger.LogInformation($"[GetTcpSessionAll]:{JsonSerializer.Serialize(result2)}");
}
catch (Exception ex)
{
Logger.LogError(ex, "Call HttpClient Error");
}
Thread.Sleep(3000);
}
}, cancellationToken);
return Task.CompletedTask;
}

public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}

+ 14
- 16
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs Ver ficheiro

@@ -14,6 +14,7 @@ using JT808.Gateway.SessionNotice;
using JT808.Gateway.Client;
using JT808.Gateway.QueueHosting.Jobs;
using JT808.Gateway.Kafka;
using JT808.Gateway.WebApiClientTool;

namespace JT808.Gateway.QueueHosting
{
@@ -40,18 +41,6 @@ namespace JT808.Gateway.QueueHosting
services.AddSingleton<ILoggerFactory, LoggerFactory>();
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
services.AddJT808Configure()
//.AddQueueGateway(options =>
//{
// options.TcpPort = 808;
// options.UdpPort = 808;
//})
.AddGateway(hostContext.Configuration)
.AddServerKafkaMsgProducer(hostContext.Configuration)
.AddServerKafkaSessionProducer(hostContext.Configuration)
.AddServerKafkaMsgReplyConsumer(hostContext.Configuration)
.AddTcp()
.AddUdp()
.Builder()
//添加客户端工具
.AddClient()
.AddClientReport()
@@ -61,11 +50,20 @@ namespace JT808.Gateway.QueueHosting
.AddMsgConsumer(hostContext.Configuration)
//添加消息应答服务
.AddMsgReplyProducer(hostContext.Configuration)
.Builder()
//添加消息应答处理
//.AddReplyMessage()
;
//grpc客户端调用
//services.AddHostedService<CallGrpcClientJob>();
//.AddReplyMessage();
.AddGateway(hostContext.Configuration)
.AddServerKafkaMsgProducer(hostContext.Configuration)
.AddServerKafkaSessionProducer(hostContext.Configuration)
.AddServerKafkaMsgReplyConsumer(hostContext.Configuration)
.AddTcp()
.AddUdp()
.AddHttp()
.Register();//必须注册的
services.AddJT808WebApiClientTool(hostContext.Configuration);
//httpclient客户端调用
services.AddHostedService<CallHttpClientJob>();
//客户端测试
services.AddHostedService<UpJob>();
});


+ 6
- 0
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/appsettings.json Ver ficheiro

@@ -2,9 +2,15 @@
"JT808Configuration": {
"TcpPort": 808,
"UdpPort": 808,
"WebApiPort": 828,
"Token": "123456",
"MiniNumBufferSize": 51200,
"SoBacklog": 65535
},
"JT808WebApiClientToolConfig": {
"Token": "123456",
"Uri": "http://127.0.0.1:828/"
},
"JT808MsgProducerConfig": {
"TopicName": "JT808Msg",
"BootstrapServers": "127.0.0.1:9092"


+ 4
- 4
src/JT808.Gateway.Tests/JT808.Gateway.Test/JT808.Gateway.Test.csproj Ver ficheiro

@@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>


+ 1
- 1
src/JT808.Gateway.WebApiClientTool/JT808.Gateway.WebApiClientTool.csproj Ver ficheiro

@@ -29,7 +29,7 @@
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JT808.Gateway.Abstractions\JT808.Gateway.Abstractions.csproj" />


+ 1
- 1
src/JT808.Gateway/JT808.Gateway.csproj Ver ficheiro

@@ -31,7 +31,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
<PackageReference Include="System.IO.Pipelines" Version="4.7.3" />
</ItemGroup>

<ItemGroup>


+ 4
- 0
src/JT808.Gateway/JT808UdpServer.cs Ver ficheiro

@@ -65,6 +65,10 @@ namespace JT808.Gateway
SocketReceiveMessageFromResult result = await server.ReceiveMessageFromAsync(segment, SocketFlags.None, LocalIPEndPoint);
ReaderBuffer(buffer.AsSpan(0, result.ReceivedBytes), server, result);
}
catch(System.ObjectDisposedException ex)
{
//Logger.LogInformation("Socket Received Bytes Close");
}
catch(AggregateException ex)
{
Logger.LogError(ex, "Receive MessageFrom Async");


+ 1
- 1
src/Version.props Ver ficheiro

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<JT808DotNettyPackageVersion>2.3.2</JT808DotNettyPackageVersion>
<JT808GatewayPackageVersion>1.0.2-preview1</JT808GatewayPackageVersion>
<JT808GatewayPackageVersion>1.0.2-preview2</JT808GatewayPackageVersion>
</PropertyGroup>
</Project>

Carregando…
Cancelar
Guardar