|
|
|
@ -16,6 +16,7 @@ using OpenAuth.App.ServiceApp.DroneDocking.Response;
|
|
|
|
|
using DocumentFormat.OpenXml.Math;
|
|
|
|
|
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
|
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
@ -759,6 +760,116 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
return Response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取临时上传地址
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<Response<string>> getUploadFilePath(AirPortUploadReq req)
|
|
|
|
|
{
|
|
|
|
|
Response<string> Response = new Response<string>();
|
|
|
|
|
|
|
|
|
|
var handler = new HttpClientHandler();
|
|
|
|
|
// 如果需要忽略服务器证书错误(仅测试环境)
|
|
|
|
|
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
|
|
|
|
using (var client = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string url = configuration.GetSection("DroneDocking:Url").Value + "/DataExchange/getUploadFilePath";
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
string centercode = "UAV32_LJY2FPMYDE6UDES3P3ZD7V3IKQ";
|
|
|
|
|
string x_token = _helper.GetToken(centercode);
|
|
|
|
|
|
|
|
|
|
// 序列化为 JSON 字符串
|
|
|
|
|
string json = JsonSerializer.Serialize(req);
|
|
|
|
|
|
|
|
|
|
// 转换为字节数组
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
|
|
|
|
|
var encryptedData = _helper.Encrypt(bytes);
|
|
|
|
|
// 创建请求体
|
|
|
|
|
var httpContent = new StringContent(encryptedData, Encoding.UTF8, "application/json");
|
|
|
|
|
|
|
|
|
|
// 添加请求头
|
|
|
|
|
client.DefaultRequestHeaders.Add("x-lc-secret", x_lc_secret);
|
|
|
|
|
client.DefaultRequestHeaders.Add("x-lc-token", x_token);
|
|
|
|
|
client.DefaultRequestHeaders.Add("x-lc-datacode", "AirportData");
|
|
|
|
|
|
|
|
|
|
//发送请求
|
|
|
|
|
HttpResponseMessage response = await client.PostAsync(url, httpContent);
|
|
|
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
|
|
|
|
|
|
// 获取响应头中的 x_cl_screte 参数
|
|
|
|
|
string resx_cl_screte = GetHeaderValue(response, "x-lc-secret");
|
|
|
|
|
|
|
|
|
|
// 读取响应内容并反序列化
|
|
|
|
|
string responseBody = await response.Content.ReadAsStringAsync();
|
|
|
|
|
var result = JsonSerializer.Deserialize<ReciveData<string>>(responseBody);
|
|
|
|
|
|
|
|
|
|
//解密数据
|
|
|
|
|
byte[] resbytesx = Convert.FromBase64String(resx_cl_screte);
|
|
|
|
|
byte[] resdatabytes = Convert.FromBase64String(result?.data);
|
|
|
|
|
string data = _helper.Decrypt(resbytesx, resdatabytes);
|
|
|
|
|
|
|
|
|
|
Response.Result = data;
|
|
|
|
|
Response.Message = result.message;
|
|
|
|
|
Response.Code = result.code;
|
|
|
|
|
}
|
|
|
|
|
catch (HttpRequestException e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\nException Caught!");
|
|
|
|
|
Console.WriteLine("Message :{0} ", e.Message);
|
|
|
|
|
Response.Result = "连接错误";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无人机状态获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<ResData> getResult(string taskid)
|
|
|
|
|
{
|
|
|
|
|
ResData Response = new ResData();
|
|
|
|
|
using (var uow = base.UnitWork.CreateContext())
|
|
|
|
|
{
|
|
|
|
|
//查询数据 检查是否有重复数据
|
|
|
|
|
var info = uow.DbfineInfo.AsQueryable().Where(r => r.taskid == taskid).First();
|
|
|
|
|
|
|
|
|
|
if (true)
|
|
|
|
|
{
|
|
|
|
|
string json = JsonSerializer.Serialize(info);
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
// 转换为字节数组
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
var encryptedResData = _helper.Encrypt(bytes);
|
|
|
|
|
Response.Result = encryptedResData;
|
|
|
|
|
Response.Message = "获取无人机机场状态成功!";
|
|
|
|
|
Response.Code = 200;
|
|
|
|
|
Response.Secret = x_lc_secret;
|
|
|
|
|
return Response;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string x_lc_secret = _helper.getxseret();
|
|
|
|
|
// 转换为字节数组
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(" ");
|
|
|
|
|
|
|
|
|
|
var encryptedResData = _helper.Encrypt(bytes);
|
|
|
|
|
Response.Result = encryptedResData;
|
|
|
|
|
Response.Message = "获取无人机机场状态失败!";
|
|
|
|
|
Response.Code = 500;
|
|
|
|
|
Response.Secret = x_lc_secret;
|
|
|
|
|
return Response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 安全获取响应头值的方法
|
|
|
|
|
private static string GetHeaderValue(HttpResponseMessage response, string headerName)
|
|
|
|
|
{
|
|
|
|
|