Sfoglia il codice sorgente

1.统一日志类型

2.去掉无用的项目
tags/pipeline-1.1.0
SmallChi(Koike) 4 anni fa
parent
commit
2b3ff63acf
41 ha cambiato i file con 421 aggiunte e 515 eliminazioni
  1. +0
    -13
      src/JT808.Gateway.Abstractions/IJT808NormalGatewayBuilder.cs
  2. +0
    -13
      src/JT808.Gateway.Abstractions/IJT808QueueGatewayBuilder.cs
  3. +21
    -0
      src/JT808.Gateway.Abstractions/IJT808ReplyMessageHandler.cs
  4. +0
    -1
      src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj
  5. +0
    -331
      src/JT808.Gateway.Abstractions/JT808NormalReplyMessageHandler.cs
  6. +1
    -1
      src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs
  7. +1
    -1
      src/JT808.Gateway.Client/JT808TcpClient.cs
  8. +1
    -1
      src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs
  9. +13
    -0
      src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingConsumerConfig.cs
  10. +13
    -0
      src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingProducerConfig.cs
  11. +6
    -5
      src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj
  12. +80
    -0
      src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.xml
  13. +13
    -1
      src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs
  14. +1
    -1
      src/JT808.Gateway.Kafka/JT808MsgConsumer.cs
  15. +103
    -0
      src/JT808.Gateway.Kafka/JT808MsgReplyLoggingConsumer.cs
  16. +56
    -0
      src/JT808.Gateway.Kafka/JT808MsgReplyLoggingProducer.cs
  17. +12
    -0
      src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs
  18. +1
    -1
      src/JT808.Gateway.Kafka/JT808SessionConsumer.cs
  19. +36
    -0
      src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgDownReplyLoggingHostedService.cs
  20. +4
    -3
      src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs
  21. +12
    -24
      src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs
  22. +25
    -23
      src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs
  23. +5
    -5
      src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs
  24. +1
    -1
      src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs
  25. +4
    -4
      src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs
  26. +0
    -3
      src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj
  27. +5
    -5
      src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs
  28. +1
    -1
      src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs
  29. +0
    -3
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs
  30. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs
  31. +0
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj
  32. +0
    -48
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/TrafficJob.cs
  33. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs
  34. +0
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs
  35. +0
    -2
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj
  36. +1
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs
  37. +0
    -1
      src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs
  38. +0
    -14
      src/JT808.Gateway.sln
  39. +1
    -1
      src/JT808.Gateway/JT808TcpServer.cs
  40. +1
    -1
      src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs
  41. +1
    -1
      src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs

+ 0
- 13
src/JT808.Gateway.Abstractions/IJT808NormalGatewayBuilder.cs Vedi File

@@ -1,13 +0,0 @@
using JT808.Protocol;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Abstractions
{
public interface IJT808NormalGatewayBuilder: IJT808GatewayBuilder
{

}
}

+ 0
- 13
src/JT808.Gateway.Abstractions/IJT808QueueGatewayBuilder.cs Vedi File

@@ -1,13 +0,0 @@
using JT808.Protocol;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Abstractions
{
public interface IJT808QueueGatewayBuilder: IJT808GatewayBuilder
{

}
}

+ 21
- 0
src/JT808.Gateway.Abstractions/IJT808ReplyMessageHandler.cs Vedi File

@@ -0,0 +1,21 @@
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 interface IJT808ReplyMessageHandler
{
/// <summary>
///
/// </summary>
/// <param name="TerminalNo">请求数据</param>
/// <param name="Data">当前会话</param>
/// <returns>应答消息数据</returns>
public byte[] Processor(string TerminalNo, byte[] Data);
}
}

+ 0
- 1
src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj Vedi File

@@ -29,7 +29,6 @@
<Compile Remove="Enums\JT808UseType.cs" />
<Compile Remove="IJT808NormalGatewayBuilder.cs" />
<Compile Remove="IJT808QueueGatewayBuilder.cs" />
<Compile Remove="JT808NormalReplyMessageHandler.cs" />
<Compile Remove="JT808QueueReplyMessageHandler.cs" />
</ItemGroup>
<ItemGroup>


+ 0
- 331
src/JT808.Gateway.Abstractions/JT808NormalReplyMessageHandler.cs Vedi File

@@ -1,331 +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 JT808NormalReplyMessageHandler
{
protected Dictionary<ushort, MsgIdMethodDelegate> HandlerDict { get; }

protected delegate byte[] MsgIdMethodDelegate(JT808HeaderPackage package, IJT808Session session);
protected JT808Serializer JT808Serializer { get; }
public JT808NormalReplyMessageHandler(
IJT808Config jT808Config)
{
this.JT808Serializer = jT808Config.GetSerializer();
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 },
};
}

/// <summary>
///
/// </summary>
/// <param name="request">请求数据</param>
/// <param name="session">当前会话</param>
/// <returns>应答消息数据</returns>
public virtual byte[] Processor(JT808HeaderPackage request, IJT808Session session)
{
if (HandlerDict.TryGetValue(request.Header.MsgId, out var func))
{
return func(request, session);
}
else
{
//处理不了的消息统一回复通用应答
return CommonReply(request, session);
}
}
/// <summary>
/// 终端通用应答
/// 平台无需回复
/// 实现自己的业务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0001(JT808HeaderPackage request, IJT808Session session)
{
return default;
}
/// <summary>
/// 平台通用应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
public virtual byte[] CommonReply(JT808HeaderPackage request, IJT808Session session)
{
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
}));
session.SendAsync(data);
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
}));
session.SendAsync(data);
return data;
}
}
/// <summary>
/// 终端心跳
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public virtual byte[] Msg0x0002(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 查询服务器时间
/// 2019版本
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0004(JT808HeaderPackage request, IJT808Session session)
{
byte[] data = JT808Serializer.Serialize(JT808MsgId.查询服务器时间应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8004()
{
Time=DateTime.Now
}));
session.SendAsync(data);
return data;
}
/// <summary>
/// 服务器补传分包请求
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x8003(JT808HeaderPackage request, IJT808Session session)
{
throw new NotImplementedException("0x8003-服务器补传分包请求");
}
/// <summary>
/// 终端补传分包请求
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0005(JT808HeaderPackage request, IJT808Session session)
{
throw new NotImplementedException("0x0005-终端补传分包请求");
}
/// <summary>
/// 终端注册
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0100(JT808HeaderPackage request, IJT808Session session)
{
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
}));
session.SendAsync(data);
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
}));
session.SendAsync(data);
return data;
}
}
/// <summary>
/// 终端注销
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0003(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 终端鉴权
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0102(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 查询终端参数应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0104(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 查询终端属性应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0107(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 终端升级结果应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0108(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 位置信息汇报
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0200(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 位置信息查询应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0201(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 链路检测
/// 2019版本
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x8204(JT808HeaderPackage request, IJT808Session session)
{
return default;
}
/// <summary>
/// 车辆控制应答
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0500(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 定位数据批量上传
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0704(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// CAN总线数据上传
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0705(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 多媒体事件信息上传
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0800(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
/// <summary>
/// 多媒体数据上传
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0801(JT808HeaderPackage request, IJT808Session session)
{
throw new NotImplementedException("0x8800多媒体数据上传应答");
}
/// <summary>
/// 摄像头立即拍摄命令
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x8801(JT808HeaderPackage request, IJT808Session session)
{
throw new NotImplementedException("0x0805摄像头立即拍摄命令应答");
}
/// <summary>
/// 数据上行透传
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
/// <returns></returns>
public virtual byte[] Msg0x0900(JT808HeaderPackage request, IJT808Session session)
{
return CommonReply(request, session);
}
}
}

+ 1
- 1
src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs Vedi File

@@ -34,7 +34,7 @@ namespace JT808.Gateway.CleintBenchmark.Services
{
this.jT808TcpClientFactory = jT808TcpClientFactory;
clientBenchmarkOptions = clientBenchmarkOptionsAccessor.Value;
logger = loggerFactory.CreateLogger("CleintBenchmarkHostedService");
logger = loggerFactory.CreateLogger<CleintBenchmarkHostedService>();

}
public Task StartAsync(CancellationToken cancellationToken)


+ 1
- 1
src/JT808.Gateway.Client/JT808TcpClient.cs Vedi File

@@ -36,7 +36,7 @@ namespace JT808.Gateway.Client
SendAtomicCounterService = serviceProvider.GetRequiredService<JT808SendAtomicCounterService>();
ReceiveAtomicCounterService = serviceProvider.GetRequiredService<JT808ReceiveAtomicCounterService>();
JT808Serializer = serviceProvider.GetRequiredService<IJT808Config>().GetSerializer();
Logger = serviceProvider.GetRequiredService<ILoggerFactory>().CreateLogger("JT808TcpClient");
Logger = serviceProvider.GetRequiredService<ILoggerFactory>().CreateLogger<JT808TcpClient>();
}
public async ValueTask<bool> ConnectAsync(EndPoint remoteEndPoint)
{


+ 1
- 1
src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs Vedi File

@@ -28,7 +28,7 @@ namespace JT808.Gateway.Client.Services
JT808SendAtomicCounterService jT808SendAtomicCounterService,
IJT808TcpClientFactory jT808TcpClientFactory)
{
logger = loggerFactory.CreateLogger("JT808ReportHostedService");
logger = loggerFactory.CreateLogger<JT808ReportHostedService>();
jT808ReportOptions = jT808ReportOptionsAccessor;
jT808ReportOptions.CurrentValue.FileExistsAndCreate();
this.jT808ReceiveAtomicCounterService = jT808ReceiveAtomicCounterService;


+ 13
- 0
src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingConsumerConfig.cs Vedi File

@@ -0,0 +1,13 @@
using Confluent.Kafka;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Configs.Kafka
{
public class JT808MsgReplyLoggingConsumerConfig : JT808ConsumerConfig, IOptions<JT808MsgReplyLoggingConsumerConfig>
{
JT808MsgReplyLoggingConsumerConfig IOptions<JT808MsgReplyLoggingConsumerConfig>.Value => this;
}
}

+ 13
- 0
src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingProducerConfig.cs Vedi File

@@ -0,0 +1,13 @@
using Confluent.Kafka;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Gateway.Configs.Kafka
{
public class JT808MsgReplyLoggingProducerConfig : JT808ProducerConfig, IOptions<JT808MsgReplyLoggingProducerConfig>
{
JT808MsgReplyLoggingProducerConfig IOptions<JT808MsgReplyLoggingProducerConfig>.Value => this;
}
}

+ 6
- 5
src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj Vedi File

@@ -19,13 +19,14 @@
<PackageReleaseNotes>基于Kafka的JT808消息发布与订阅</PackageReleaseNotes>
<Version>$(JT808GatewayPackageVersion)</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>JT808.Gateway.Kafka.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>JT808.Gateway.Kafka.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="1.5.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
</ItemGroup>

<ItemGroup>


+ 80
- 0
src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.xml Vedi File

@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>JT808.Gateway.Kafka</name>
</assembly>
<members>
<member name="M:JT808.Gateway.Kafka.JT808ClientKafkaExtensions.AddMsgConsumer(JT808.Gateway.Abstractions.IJT808ClientBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="serviceDescriptors"></param>
<param name="configuration">GetSection("JT808MsgConsumerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ClientKafkaExtensions.AddMsgReplyProducer(JT808.Gateway.Abstractions.IJT808ClientBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="serviceDescriptors"></param>
<param name="configuration">GetSection("JT808MsgReplyProducerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ClientKafkaExtensions.AddMsgReplyConsumer(JT808.Gateway.Abstractions.IJT808ClientBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808ClientBuilder"></param>
<param name="configuration">GetSection("JT808MsgReplyConsumerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ClientKafkaExtensions.AddMsgReplyLoggingConsumer(JT808.Gateway.Abstractions.IJT808ClientBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808ClientBuilder"></param>
<param name="configuration">GetSection("JT808MsgReplyLoggingConsumerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ClientKafkaExtensions.AddSessionConsumer(JT808.Gateway.Abstractions.IJT808ClientBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="serviceDescriptors"></param>
<param name="configuration">GetSection("JT808SessionConsumerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ServerKafkaExtensions.AddServerKafkaMsgProducer(JT808.Gateway.Abstractions.IJT808GatewayBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808GatewayBuilder"></param>
<param name="configuration">GetSection("JT808MsgProducerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ServerKafkaExtensions.AddServerKafkaMsgReplyConsumer(JT808.Gateway.Abstractions.IJT808GatewayBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808GatewayBuilder"></param>
<param name="configuration">GetSection("JT808MsgReplyConsumerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ServerKafkaExtensions.AddServerKafkaSessionProducer(JT808.Gateway.Abstractions.IJT808GatewayBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808GatewayBuilder"></param>
<param name="configuration">GetSection("JT808SessionProducerConfig")</param>
<returns></returns>
</member>
<member name="M:JT808.Gateway.Kafka.JT808ServerKafkaExtensions.AddServerKafkaMsgReplyLoggingProducer(JT808.Gateway.Abstractions.IJT808GatewayBuilder,Microsoft.Extensions.Configuration.IConfiguration)">
<summary>
</summary>
<param name="jT808GatewayBuilder"></param>
<param name="configuration">GetSection("JT808MsgReplyLoggingProducerConfig")</param>
<returns></returns>
</member>
</members>
</doc>

+ 13
- 1
src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs Vedi File

@@ -41,7 +41,7 @@ namespace JT808.Gateway.Kafka
/// <summary>
///
/// </summary>
/// <param name="jT808NettyBuilder"></param>
/// <param name="jT808ClientBuilder"></param>
/// <param name="configuration">GetSection("JT808MsgReplyConsumerConfig")</param>
/// <returns></returns>
public static IJT808ClientBuilder AddMsgReplyConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration)
@@ -53,6 +53,18 @@ namespace JT808.Gateway.Kafka
/// <summary>
///
/// </summary>
/// <param name="jT808ClientBuilder"></param>
/// <param name="configuration">GetSection("JT808MsgReplyLoggingConsumerConfig")</param>
/// <returns></returns>
public static IJT808ClientBuilder AddMsgReplyLoggingConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration)
{
jT808ClientBuilder.JT808Builder.Services.Configure<JT808MsgReplyLoggingConsumerConfig>(configuration.GetSection("JT808MsgReplyLoggingConsumerConfig"));
jT808ClientBuilder.JT808Builder.Services.TryAddSingleton<IJT808MsgReplyLoggingConsumer, JT808MsgReplyLoggingConsumer>();
return jT808ClientBuilder;
}
/// <summary>
///
/// </summary>
/// <param name="serviceDescriptors"></param>
/// <param name="configuration">GetSection("JT808SessionConsumerConfig")</param>
/// <returns></returns>


+ 1
- 1
src/JT808.Gateway.Kafka/JT808MsgConsumer.cs Vedi File

@@ -28,7 +28,7 @@ namespace JT808.Gateway.Kafka
{
consumer = new ConsumerBuilder<string, byte[]>(consumerConfigAccessor.Value).Build();
TopicName = consumerConfigAccessor.Value.TopicName;
logger = loggerFactory.CreateLogger("JT808MsgConsumer");
logger = loggerFactory.CreateLogger<JT808MsgConsumer>();
}

public void OnMessage(Action<(string TerminalNo, byte[] Data)> callback)


+ 103
- 0
src/JT808.Gateway.Kafka/JT808MsgReplyLoggingConsumer.cs Vedi File

@@ -0,0 +1,103 @@
using Confluent.Kafka;
using JT808.Gateway.Configs.Kafka;
using JT808.Gateway.Abstractions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace JT808.Gateway.Kafka
{
public sealed class JT808MsgReplyLoggingConsumer : IJT808MsgReplyLoggingConsumer
{
private bool disposed = false;
public CancellationTokenSource Cts { get; private set; } = new CancellationTokenSource();

private readonly IConsumer<string, byte[]> consumer;

private readonly ILogger logger;

public string TopicName { get; }

public JT808MsgReplyLoggingConsumer(
IOptions<JT808MsgReplyLoggingConsumerConfig> consumerConfigAccessor,
ILoggerFactory loggerFactory)
{
consumer = new ConsumerBuilder<string, byte[]>(consumerConfigAccessor.Value).Build();
TopicName = consumerConfigAccessor.Value.TopicName;
logger = loggerFactory.CreateLogger<JT808MsgReplyLoggingConsumer>();
}

public void OnMessage(Action<(string TerminalNo, byte[] Data)> callback)
{
Task.Run(() =>
{
while (!Cts.IsCancellationRequested)
{
if (disposed) return;
try
{
//如果不指定分区,根据kafka的机制会从多个分区中拉取数据
//如果指定分区,根据kafka的机制会从相应的分区中拉取数据
var data = consumer.Consume(Cts.Token);
if (logger.IsEnabled(LogLevel.Debug))
{
logger.LogDebug($"Topic: {data.Topic} Key: {data.Message.Key} Partition: {data.Partition} Offset: {data.Offset} TopicPartitionOffset:{data.TopicPartitionOffset}");
}
callback((data.Message.Key, data.Message.Value));
}
catch (ConsumeException ex)
{
logger.LogError(ex, TopicName);
}
catch (OperationCanceledException ex)
{
logger.LogError(ex, TopicName);
}
catch (Exception ex)
{
logger.LogError(ex, TopicName);
}
}
}, Cts.Token);
}

public void Subscribe()
{
consumer.Subscribe(TopicName);
}

public void Unsubscribe()
{
if (disposed) return;
consumer.Unsubscribe();
Cts.Cancel();
}

private void Dispose(bool disposing)
{
if (disposed) return;
if (disposing)
{
consumer.Close();
consumer.Dispose();
Cts.Dispose();
}
disposed = true;
}
~JT808MsgReplyLoggingConsumer()
{
Dispose(false);
}
public void Dispose()
{
//必须为true
Dispose(true);
//通知垃圾回收机制不再调用终结器(析构器)
GC.SuppressFinalize(this);
}
}
}

+ 56
- 0
src/JT808.Gateway.Kafka/JT808MsgReplyLoggingProducer.cs Vedi File

@@ -0,0 +1,56 @@
using Confluent.Kafka;
using JT808.Gateway.Configs.Kafka;
using JT808.Gateway.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace JT808.Gateway.Kafka
{
public sealed class JT808MsgReplyLoggingProducer : IJT808MsgReplyLoggingProducer
{
private bool disposed = false;
public string TopicName { get;}

private IProducer<string, byte[]> producer;
public JT808MsgReplyLoggingProducer(
IOptions<JT808MsgReplyLoggingProducerConfig> producerConfigAccessor)
{
producer = new ProducerBuilder<string, byte[]>(producerConfigAccessor.Value).Build();
TopicName = producerConfigAccessor.Value.TopicName;
}

public async ValueTask ProduceAsync(string terminalNo, byte[] data)
{
if (disposed) return;
await producer.ProduceAsync(TopicName, new Message<string, byte[]>
{
Key = terminalNo,
Value = data
});
}

private void Dispose(bool disposing)
{
if (disposed) return;
if (disposing)
{
producer.Dispose();
}
disposed = true;
}
~JT808MsgReplyLoggingProducer()
{
Dispose(false);
}
public void Dispose()
{
//必须为true
Dispose(true);
//通知垃圾回收机制不再调用终结器(析构器)
GC.SuppressFinalize(this);
}
}
}

+ 12
- 0
src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs Vedi File

@@ -44,5 +44,17 @@ namespace JT808.Gateway.Kafka
jT808GatewayBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808SessionProducer), typeof(JT808SessionProducer), ServiceLifetime.Singleton));
return jT808GatewayBuilder;
}
/// <summary>
///
/// </summary>
/// <param name="jT808GatewayBuilder"></param>
/// <param name="configuration">GetSection("JT808MsgReplyLoggingProducerConfig")</param>
/// <returns></returns>
public static IJT808GatewayBuilder AddServerKafkaMsgReplyLoggingProducer(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration)
{
jT808GatewayBuilder.JT808Builder.Services.Configure<JT808MsgReplyLoggingProducerConfig>(configuration.GetSection("JT808MsgReplyLoggingProducerConfig"));
jT808GatewayBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808MsgReplyLoggingProducer), typeof(JT808MsgReplyLoggingProducer), ServiceLifetime.Singleton));
return jT808GatewayBuilder;
}
}
}

+ 1
- 1
src/JT808.Gateway.Kafka/JT808SessionConsumer.cs Vedi File

@@ -28,7 +28,7 @@ namespace JT808.Gateway.Kafka
{
consumer = new ConsumerBuilder<string, string>(consumerConfigAccessor.Value).Build();
TopicName = consumerConfigAccessor.Value.TopicName;
logger = loggerFactory.CreateLogger("JT808SessionConsumer");
logger = loggerFactory.CreateLogger<JT808SessionConsumer>();
}

public void OnMessage(Action<(string Notice, string TerminalNo)> callback)


+ 36
- 0
src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgDownReplyLoggingHostedService.cs Vedi File

@@ -0,0 +1,36 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using System.Threading;
using JT808.Gateway.Abstractions;

namespace JT808.Gateway.MsgLogging
{
public class JT808MsgDownReplyLoggingHostedService : IHostedService
{
private readonly IJT808MsgReplyLoggingConsumer jT808MsgReplyLoggingConsumer;
private readonly IJT808MsgLogging jT808MsgLogging;
public JT808MsgDownReplyLoggingHostedService(
IJT808MsgLogging jT808MsgLogging,
IJT808MsgReplyLoggingConsumer jT808MsgReplyLoggingConsumer)
{
this.jT808MsgReplyLoggingConsumer = jT808MsgReplyLoggingConsumer;
this.jT808MsgLogging = jT808MsgLogging;
}

public Task StartAsync(CancellationToken cancellationToken)
{
jT808MsgReplyLoggingConsumer.Subscribe();
jT808MsgReplyLoggingConsumer.OnMessage(item=>
{
jT808MsgLogging.Processor(item, JT808MsgLoggingType.down);
});
return Task.CompletedTask;
}

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

+ 4
- 3
src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs Vedi File

@@ -13,15 +13,16 @@ namespace JT808.Gateway.MsgLogging
{
jT808ClientBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging),typeof(TJT808MsgLogging));
jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808MsgDownLoggingHostedService>();
jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808MsgDownReplyLoggingHostedService>();
jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808MsgUpLoggingHostedService>();
return jT808ClientBuilder;
}

public static IJT808GatewayBuilder AddMsgLogging<TJT808MsgLogging>(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
public static IJT808GatewayBuilder AddMsgLogging<TJT808MsgLogging>(this IJT808GatewayBuilder jT808GatewayBuilder)
where TJT808MsgLogging : IJT808MsgLogging
{
jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging), typeof(TJT808MsgLogging));
return jT808NormalGatewayBuilder;
jT808GatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging), typeof(TJT808MsgLogging));
return jT808GatewayBuilder;
}
}
}

+ 12
- 24
src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs Vedi File

@@ -9,29 +9,17 @@ namespace JT808.Gateway.ReplyMessage
{
public static class JT808ReplyMessageExtensions
{
///// <summary>
///// 消息应答服务(不同的消费者实例)
///// </summary>
///// <param name="jT808ClientBuilder"></param>
///// <returns></returns>
//public static IJT808ClientBuilder AddReplyMessage(this IJT808ClientBuilder jT808ClientBuilder)
//{
// jT808ClientBuilder.JT808Builder.Services.AddSingleton<JT808QueueReplyMessageHandler>();
// jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808ReplyMessageHostedService>();
// return jT808ClientBuilder;
//}
///// <summary>
///// 消息应答服务(不同的消费者实例)
///// </summary>
///// <typeparam name="TReplyMessageService">自定义消息回复服务</typeparam>
///// <param name="jT808ClientBuilder"></param>
///// <returns></returns>
//public static IJT808ClientBuilder AddReplyMessage<TReplyMessageHandler>(this IJT808ClientBuilder jT808ClientBuilder)
// where TReplyMessageHandler : JT808QueueReplyMessageHandler
//{
// jT808ClientBuilder.JT808Builder.Services.AddSingleton<JT808QueueReplyMessageHandler, TReplyMessageHandler>();
// jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808ReplyMessageHostedService>();
// return jT808ClientBuilder;
//}
/// <summary>
/// 消息应答服务(不同的消费者实例)
/// </summary>
/// <param name="jT808ClientBuilder"></param>
/// <returns></returns>
public static IJT808ClientBuilder AddReplyMessage<TJT808ReplyMessageHandler>(this IJT808ClientBuilder jT808ClientBuilder)
where TJT808ReplyMessageHandler : IJT808ReplyMessageHandler
{
jT808ClientBuilder.JT808Builder.Services.AddSingleton(new ServiceDescriptor(typeof(IJT808ReplyMessageHandler),typeof(TJT808ReplyMessageHandler), ServiceLifetime.Singleton));
jT808ClientBuilder.JT808Builder.Services.AddHostedService<JT808ReplyMessageHostedService>();
return jT808ClientBuilder;
}
}
}

+ 25
- 23
src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs Vedi File

@@ -5,30 +5,32 @@ using JT808.Gateway.Abstractions;

namespace JT808.Gateway.ReplyMessage
{
//public class JT808ReplyMessageHostedService : IHostedService
//{
// //private readonly IJT808MsgConsumer jT808MsgConsumer;
// //private readonly JT808QueueReplyMessageHandler jT808ReplyMessageHandler;
public class JT808ReplyMessageHostedService : IHostedService
{
private IJT808MsgConsumer jT808MsgConsumer;
private IJT808ReplyMessageHandler jT808ReplyMessageHandler;

// //public JT808ReplyMessageHostedService(
// // JT808QueueReplyMessageHandler jT808ReplyMessageHandler,
// // IJT808MsgConsumer jT808MsgConsumer)
// //{
// // this.jT808MsgConsumer = jT808MsgConsumer;
// // this.jT808ReplyMessageHandler = jT808ReplyMessageHandler;
// //}
public JT808ReplyMessageHostedService(
IJT808ReplyMessageHandler jT808ReplyMessageHandler,
IJT808MsgConsumer jT808MsgConsumer)
{
this.jT808MsgConsumer = jT808MsgConsumer;
this.jT808ReplyMessageHandler = jT808ReplyMessageHandler;
}

// //public Task StartAsync(CancellationToken cancellationToken)
// //{
// // jT808MsgConsumer.Subscribe();
// // jT808MsgConsumer.OnMessage(jT808ReplyMessageHandler.Processor);
// // return Task.CompletedTask;
// //}
public Task StartAsync(CancellationToken cancellationToken)
{
jT808MsgConsumer.Subscribe();
jT808MsgConsumer.OnMessage((Message)=> {
jT808ReplyMessageHandler.Processor(Message.TerminalNo, Message.Data);
});
return Task.CompletedTask;
}

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

+ 5
- 5
src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs Vedi File

@@ -38,13 +38,13 @@ namespace JT808.Gateway.SessionNotice
/// <summary>
/// 会话通知服务(不同的消费者实例)
/// </summary>
/// <param name="jT808NormalGatewayBuilder"></param>
/// <param name="jT808GatewayBuilder"></param>
/// <returns></returns>
public static IJT808GatewayBuilder AddSessionNotice(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
public static IJT808GatewayBuilder AddSessionNotice(this IJT808GatewayBuilder jT808GatewayBuilder)
{
jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton<JT808SessionNoticeService>();
jT808NormalGatewayBuilder.JT808Builder.Services.AddHostedService<JT808SessionNoticeHostedService>();
return jT808NormalGatewayBuilder;
jT808GatewayBuilder.JT808Builder.Services.AddSingleton<JT808SessionNoticeService>();
jT808GatewayBuilder.JT808Builder.Services.AddHostedService<JT808SessionNoticeHostedService>();
return jT808GatewayBuilder;
}

/// <summary>


+ 1
- 1
src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs Vedi File

@@ -11,7 +11,7 @@ namespace JT808.Gateway.SessionNotice
protected ILogger logger { get; }
public JT808SessionNoticeService(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger("JT808SessionNoticeService");
logger = loggerFactory.CreateLogger<JT808SessionNoticeService>();
}
public virtual void Processor((string Notice, string TerminalNo) parameter)
{


+ 4
- 4
src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs Vedi File

@@ -36,13 +36,13 @@ namespace JT808.Gateway.Traffic
/// <summary>
/// 消息流量统计服务(不同的消费者实例)
/// </summary>
/// <param name="jT808NormalGatewayBuilder"></param>
/// <param name="jT808GatewayBuilder"></param>
/// <returns></returns>
public static IJT808GatewayBuilder AddTraffic<TIJT808Traffic>(this IJT808GatewayBuilder jT808NormalGatewayBuilder)
public static IJT808GatewayBuilder AddTraffic<TIJT808Traffic>(this IJT808GatewayBuilder jT808GatewayBuilder)
where TIJT808Traffic : IJT808Traffic
{
jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(TIJT808Traffic));
return jT808NormalGatewayBuilder;
jT808GatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(TIJT808Traffic));
return jT808GatewayBuilder;
}




+ 0
- 3
src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj Vedi File

@@ -21,9 +21,6 @@
<PackageReleaseNotes>基于JT808实现的数据转发服务</PackageReleaseNotes>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>


+ 5
- 5
src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs Vedi File

@@ -28,14 +28,14 @@ namespace JT808.Gateway.Transmit
/// <summary>
/// 转发服务(不同的消费者实例)
/// </summary>
/// <param name="jT808NormalGatewayBuilder"></param>
/// <param name="jT808GatewayBuilder"></param>
/// <param name="configuration"></param>
/// <returns></returns>
public static IJT808GatewayBuilder AddTransmit(this IJT808GatewayBuilder jT808NormalGatewayBuilder, IConfiguration configuration)
public static IJT808GatewayBuilder AddTransmit(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration)
{
jT808NormalGatewayBuilder.JT808Builder.Services.Configure<RemoteServerOptions>(configuration.GetSection("RemoteServerOptions"));
jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton<JT808TransmitService>();
return jT808NormalGatewayBuilder;
jT808GatewayBuilder.JT808Builder.Services.Configure<RemoteServerOptions>(configuration.GetSection("RemoteServerOptions"));
jT808GatewayBuilder.JT808Builder.Services.AddSingleton<JT808TransmitService>();
return jT808GatewayBuilder;
}
}
}

+ 1
- 1
src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs Vedi File

@@ -22,7 +22,7 @@ namespace JT808.Gateway.Transmit
public JT808TransmitService(ILoggerFactory loggerFactory,
IOptionsMonitor<RemoteServerOptions> optionsMonitor)
{
logger = loggerFactory.CreateLogger("JT808TransmitService");
logger = loggerFactory.CreateLogger<JT808TransmitService>();
this.optionsMonitor = optionsMonitor;
InitialDispatcherClient();
}


+ 0
- 3
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs Vedi File

@@ -1,7 +1,6 @@
using JT808.Gateway.Abstractions;
using JT808.Gateway.Abstractions.Configurations;
using JT808.Gateway.MsgLogging;
using JT808.Gateway.Traffic;
using JT808.Gateway.Transmit;
using JT808.Protocol;
using Microsoft.Extensions.Logging;
@@ -15,7 +14,6 @@ namespace JT808.Gateway.NormalHosting.Impl
public class JT808CustomMessageHandlerImpl : JT808MessageHandler
{
private readonly ILogger logger;
//private readonly IJT808Traffic jT808Traffic;
//private readonly JT808TransmitService jT808TransmitService;
private readonly IJT808MsgLogging jT808MsgLogging;
private readonly IJT808MsgReplyProducer MsgReplyProducer;
@@ -34,7 +32,6 @@ namespace JT808.Gateway.NormalHosting.Impl
{
MsgReplyProducer = msgReplyProducer;
//this.jT808TransmitService = jT808TransmitService;
//this.jT808Traffic = jT808Traffic;
this.jT808MsgLogging = jT808MsgLogging;
logger = loggerFactory.CreateLogger<JT808CustomMessageHandlerImpl>();
//添加自定义消息


+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs Vedi File

@@ -12,7 +12,7 @@ namespace JT808.Gateway.NormalHosting.Impl
private readonly ILogger Logger;
public JT808MsgLogging(ILoggerFactory loggerFactory)
{
Logger = loggerFactory.CreateLogger("JT808MsgLogging");
Logger = loggerFactory.CreateLogger<JT808MsgLogging>();
}
public void Processor((string TerminalNo, byte[] Data) parameter, JT808MsgLoggingType jT808MsgLoggingType)
{


+ 0
- 1
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj Vedi File

@@ -21,7 +21,6 @@
<ProjectReference Include="..\..\JT808.Gateway.Client\JT808.Gateway.Client.csproj" />
<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.Traffic\JT808.Gateway.Traffic.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.Transmit\JT808.Gateway.Transmit.csproj" />
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" />
</ItemGroup>


+ 0
- 48
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/TrafficJob.cs Vedi File

@@ -1,48 +0,0 @@
using JT808.Gateway.Traffic;
using JT808.Protocol.Enums;
using JT808.Protocol.Extensions;
using JT808.Protocol.MessageBody;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace JT808.Gateway.NormalHosting.Jobs
{
public class TrafficJob : IHostedService
{
private readonly IJT808Traffic jT808Traffic;
private readonly ILogger Logger;
public TrafficJob(
ILoggerFactory loggerFactory,
IJT808Traffic jT808Traffic)
{
Logger = loggerFactory.CreateLogger("TrafficJob");
this.jT808Traffic = jT808Traffic;
}

public Task StartAsync(CancellationToken cancellationToken)
{
Task.Run(async () =>
{
while (!cancellationToken.IsCancellationRequested)
{
await Task.Delay(2 * 1000);
foreach (var item in jT808Traffic.GetAll())
{
Logger.LogDebug($"{item.Item1}-{item.Item2}");
}
}
}, cancellationToken);
return Task.CompletedTask;
}

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

+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs Vedi File

@@ -20,7 +20,7 @@ namespace JT808.Gateway.NormalHosting.Jobs
ILoggerFactory loggerFactory,
IJT808TcpClientFactory jT808TcpClientFactory)
{
Logger = loggerFactory.CreateLogger("UpJob");
Logger = loggerFactory.CreateLogger<UpJob>();
this.jT808TcpClientFactory = jT808TcpClientFactory;
}



+ 0
- 2
src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs Vedi File

@@ -9,7 +9,6 @@ using NLog.Extensions.Logging;
using JT808.Gateway.NormalHosting.Impl;
using JT808.Gateway.MsgLogging;
using JT808.Gateway.Transmit;
using JT808.Gateway.Traffic;
using JT808.Gateway.NormalHosting.Services;
using JT808.Gateway.Abstractions;
using JT808.Gateway.SessionNotice;
@@ -54,7 +53,6 @@ namespace JT808.Gateway.NormalHosting
.AddMessageHandler<JT808CustomMessageHandlerImpl>()
.AddMsgReplyConsumer<JT808MsgReplyConsumer>()
.AddMsgLogging<JT808MsgLogging>()
//.AddTraffic()
//.AddSessionNotice()
//.AddTransmit(hostContext.Configuration)
.AddTcp()


+ 0
- 2
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj Vedi File

@@ -19,11 +19,9 @@
<ItemGroup>
<ProjectReference Include="..\..\JT808.Gateway.Client\JT808.Gateway.Client.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Kafka\JT808.Gateway.Kafka.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.MsgIdHandler\JT808.Gateway.MsgIdHandler.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.MsgLogging\JT808.Gateway.MsgLogging.csproj" />
<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.Traffic\JT808.Gateway.Traffic.csproj" />
<ProjectReference Include="..\..\JT808.Gateway.Services\JT808.Gateway.Transmit\JT808.Gateway.Transmit.csproj" />
<ProjectReference Include="..\..\JT808.Gateway\JT808.Gateway.csproj" />
</ItemGroup>


+ 1
- 1
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs Vedi File

@@ -20,7 +20,7 @@ namespace JT808.Gateway.QueueHosting.Jobs
ILoggerFactory loggerFactory,
IJT808TcpClientFactory jT808TcpClientFactory)
{
Logger = loggerFactory.CreateLogger("UpJob");
Logger = loggerFactory.CreateLogger<UpJob>();
this.jT808TcpClientFactory = jT808TcpClientFactory;
}



+ 0
- 1
src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs Vedi File

@@ -9,7 +9,6 @@ using NLog.Extensions.Logging;
using JT808.Gateway.MsgLogging;
using JT808.Gateway.ReplyMessage;
using JT808.Gateway.Transmit;
using JT808.Gateway.Traffic;
using JT808.Gateway.Abstractions;
using JT808.Gateway.SessionNotice;
using JT808.Gateway.Client;


+ 0
- 14
src/JT808.Gateway.sln Vedi File

@@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.Kafka", "JT80
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{3EF8490D-C993-49D8-8A3D-493B7F259D70}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.MsgIdHandler", "JT808.Gateway.Services\JT808.Gateway.MsgIdHandler\JT808.Gateway.MsgIdHandler.csproj", "{D62E3054-6924-4F1A-9BEF-E52B191F16B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.MsgLogging", "JT808.Gateway.Services\JT808.Gateway.MsgLogging\JT808.Gateway.MsgLogging.csproj", "{A242A839-4F00-4434-A7E8-7E3BEBA5B75C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SessionNotice", "JT808.Gateway.Services\JT808.Gateway.SessionNotice\JT808.Gateway.SessionNotice.csproj", "{1CB84599-5F56-4461-A451-DF16E3854AB9}"
@@ -35,8 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.CleintBenchma
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ServerBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.ServerBenchmark\JT808.Gateway.ServerBenchmark.csproj", "{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.Traffic", "JT808.Gateway.Services\JT808.Gateway.Traffic\JT808.Gateway.Traffic.csproj", "{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.WebApiClientTool", "JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj", "{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ReplyMessage", "JT808.Gateway.Services\JT808.Gateway.ReplyMessage\JT808.Gateway.ReplyMessage.csproj", "{886D0A3F-C974-442B-9820-F1C4C04EAAB6}"
@@ -59,10 +55,6 @@ Global
{274C048E-A8E3-4422-A578-A10A97DF36F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{274C048E-A8E3-4422-A578-A10A97DF36F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{274C048E-A8E3-4422-A578-A10A97DF36F2}.Release|Any CPU.Build.0 = Release|Any CPU
{D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Release|Any CPU.Build.0 = Release|Any CPU
{A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -99,10 +91,6 @@ Global
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.Build.0 = Release|Any CPU
{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Release|Any CPU.Build.0 = Release|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -116,7 +104,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D62E3054-6924-4F1A-9BEF-E52B191F16B6} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
{A242A839-4F00-4434-A7E8-7E3BEBA5B75C} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
{1CB84599-5F56-4461-A451-DF16E3854AB9} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
{598E445A-AF2E-42F0-98F4-18EC22E473FC} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
@@ -125,7 +112,6 @@ Global
{52D895BD-C60B-42D8-9229-C85927546FDA} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9}
{E34C6B7D-A48B-4871-895C-07AC12F959D3} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F}
{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
{886D0A3F-C974-442B-9820-F1C4C04EAAB6} = {3EF8490D-C993-49D8-8A3D-493B7F259D70}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution


+ 1
- 1
src/JT808.Gateway/JT808TcpServer.cs Vedi File

@@ -48,7 +48,7 @@ namespace JT808.Gateway
{
MessageHandler = messageHandler;
SessionManager = jT808SessionManager;
Logger = loggerFactory.CreateLogger("JT808TcpServer");
Logger = loggerFactory.CreateLogger<JT808TcpServer>();
Serializer = jT808Config.GetSerializer();
Configuration = jT808ConfigurationAccessor.Value;
InitServer();


+ 1
- 1
src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs Vedi File

@@ -25,7 +25,7 @@ namespace JT808.Gateway.Services
)
{
SessionManager = jT808SessionManager;
Logger = loggerFactory.CreateLogger("JT808TcpReceiveTimeout");
Logger = loggerFactory.CreateLogger<JT808TcpReceiveTimeoutHostedService>();
Configuration = jT808ConfigurationAccessor.Value;
}



+ 1
- 1
src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs Vedi File

@@ -25,7 +25,7 @@ namespace JT808.Gateway.Services
)
{
SessionManager = jT808SessionManager;
Logger = loggerFactory.CreateLogger("JT808UdpReceiveTimeout");
Logger = loggerFactory.CreateLogger<JT808UdpReceiveTimeoutHostedService>();
Configuration = jT808ConfigurationAccessor.Value;
}



Caricamento…
Annulla
Salva