Parcourir la source

推送到第三方平台

develop
H Vs il y a 9 mois
Parent
révision
e4df994169
1 fichiers modifiés avec 31 ajouts et 6 suppressions
  1. +31
    -6
      NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs

+ 31
- 6
NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs Voir le fichier

@@ -219,12 +219,23 @@ namespace NearCardAttendance.Service.TcpServer.Handler
/// <returns></returns>
private async Task HandleSignRecsAsync(ProtocolParser parser, IChannel channel)
{
ProtocolWrapper stdtSignRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1");
await SendToTcpClientAsync(stdtSignRecsWrapper, channel);
ProtocolWrapper stdtSignRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1");
await SendToTcpClientAsync(stdtSignRecsWrapper, channel);

var deviceId = parser.Data.Substring(0, 18).TrimEnd();
var cardId= parser.Data.Substring(18,18).TrimEnd();
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";
//await _httpHelper.HttpToPostAsync(url, new object());
var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
var data = new
{
attendanceStatus = 2, //考勤状态: 0.进 1.出 2.未知
attendanceTime = DateTime.TryParse(startTime, out DateTime time) ? time.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
imei = deviceId
};
var res=await _httpHelper.HttpToPostAsync(url, data);
_logger.LogInformation($"{nameof(HandleSignRecsAsync)} 推送结果,{res}");
}
/// <summary>
@@ -239,8 +250,22 @@ namespace NearCardAttendance.Service.TcpServer.Handler
ProtocolWrapper stdtSchoolRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1");
await SendToTcpClientAsync(stdtSchoolRecsWrapper, channel);

//var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
//await _httpHelper.HttpToPostAsync(url, new object());
var deviceId = parser.Data.Substring(0, 18).TrimEnd();
var cardId = parser.Data.Substring(18, 18).TrimEnd();
var studentId = parser.Data.Substring(36, 18).TrimEnd();
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 data = new
{
attendanceStatus = int.TryParse(optType,out int type) ? type : 0,
attendanceTime = DateTime.TryParse(startTime, out DateTime time) ? time.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
imei = deviceId
};
var res = await _httpHelper.HttpToPostAsync(url, data);
_logger.LogInformation($"{nameof(HandleStdtSchoolRecsAsync)} 推送结果,{res}");
}
}
}

Chargement…
Annuler
Enregistrer