Browse Source

调整配置信息

develop
H Vs 8 months ago
parent
commit
7d21a7d442
7 changed files with 38 additions and 13 deletions
  1. +13
    -0
      NearCardAttendance.Model/ServiceConfig.cs
  2. +1
    -0
      NearCardAttendance.Service/NearCardAttendance.Service.csproj
  3. +11
    -7
      NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs
  4. +1
    -0
      NearCardAttendance.TcpServer/NearCardAttendance.TcpServer.csproj
  5. +4
    -3
      NearCardAttendance.TcpServer/Program.cs
  6. +4
    -2
      NearCardAttendance.TcpServer/appsettings.debug.json
  7. +4
    -1
      NearCardAttendance.TcpServer/appsettings.test.json

+ 13
- 0
NearCardAttendance.Model/ServiceConfig.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NearCardAttendance.Model
{
public class ServiceConfig
{
public string XinHuaLeYuUrl { get; set; } = default!;
}
}

+ 1
- 0
NearCardAttendance.Service/NearCardAttendance.Service.csproj View File

@@ -14,6 +14,7 @@

<ItemGroup>
<ProjectReference Include="..\NearCardAttendance.Common\NearCardAttendance.Common.csproj" />
<ProjectReference Include="..\NearCardAttendance.Model\NearCardAttendance.Model.csproj" />
</ItemGroup>

</Project>

+ 11
- 7
NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs View File

@@ -11,6 +11,8 @@ using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using NearCardAttendance.Model;
using Microsoft.Extensions.Options;

namespace NearCardAttendance.Service.TcpServer.Handler
{
@@ -19,15 +21,16 @@ namespace NearCardAttendance.Service.TcpServer.Handler
private readonly ILogger<RegisterHandler> _logger;
private readonly HttpHelper _httpHelper = default!;
private readonly IDisposable _loggerScope = default!;
private readonly ServiceConfig _configService;

private readonly TcpClientsManager _managerTcpClients;
private readonly ScheduleResendManager _managerScheduleResend;
//private readonly TcpClientsManager _managerTcpClients;
//private readonly ScheduleResendManager _managerScheduleResend;

public RegisterHandler(ILogger<RegisterHandler> logger,HttpHelper httpHelper)
public RegisterHandler(ILogger<RegisterHandler> logger,HttpHelper httpHelper, IOptions<ServiceConfig> configService)
{
_logger = logger;
_httpHelper = httpHelper;
_configService = configService.Value;
}

public override void ChannelActive(IChannelHandlerContext context)
@@ -228,7 +231,8 @@ namespace NearCardAttendance.Service.TcpServer.Handler
var studentId = parser.Data.Substring(36,18).TrimEnd();
var startTime = parser.Data.Substring(54, 14).TrimEnd();
// Push card attendance information to third-party platform
var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
//var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
var url = _configService.XinHuaLeYuUrl;
var data = new
{
attendanceStatus = 2, //考勤状态: 0.进 1.出 2.未知
@@ -257,8 +261,8 @@ namespace NearCardAttendance.Service.TcpServer.Handler
var startTime = parser.Data.Substring(54, 14).TrimEnd();
var optType = parser.Data.Substring(68, 1).TrimEnd();

var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
//var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
var url = _configService.XinHuaLeYuUrl;
var data = new
{
attendanceStatus = int.TryParse(optType,out int type) ? type : 0,


+ 1
- 0
NearCardAttendance.TcpServer/NearCardAttendance.TcpServer.csproj View File

@@ -37,6 +37,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NearCardAttendance.Model\NearCardAttendance.Model.csproj" />
<ProjectReference Include="..\NearCardAttendance.Common\NearCardAttendance.Common.csproj" />
<ProjectReference Include="..\NearCardAttendance.Service\NearCardAttendance.Service.csproj" />
</ItemGroup>


+ 4
- 3
NearCardAttendance.TcpServer/Program.cs View File

@@ -11,6 +11,7 @@ using NearCardAttendance.Service.TcpServer.Handler;
using NearCardAttendance.Service.TcpServer.Mapper;
using NearCardAttendance.TcpServer.Config;
using Serilog;
using NearCardAttendance.Model;
using System.Text;

namespace NearCardAttendance.TcpServer
@@ -53,9 +54,9 @@ namespace NearCardAttendance.TcpServer
var configuration = hostContext.Configuration;

#region 配置信息
//services
// .Configure<ServiceConfig>(configuration.GetSection("ServiceConfig"))
// ;
services
.Configure<ServiceConfig>(configuration.GetSection("ServiceConfig"))
;
#endregion

#region Http请求


+ 4
- 2
NearCardAttendance.TcpServer/appsettings.debug.json View File

@@ -1,4 +1,6 @@
{
"AllowedHosts": "*"
"AllowedHosts": "*",
"ServiceConfig": {
"XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"
}
}

+ 4
- 1
NearCardAttendance.TcpServer/appsettings.test.json View File

@@ -1,3 +1,6 @@
{
"AllowedHosts": "*"
"AllowedHosts": "*",
"ServiceConfig": {
"XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"
}
}

Loading…
Cancel
Save