|
|
|
@ -17,6 +17,8 @@ using DocumentFormat.OpenXml.Math;
|
|
|
|
|
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
|
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
@ -828,13 +830,62 @@ namespace OpenAuth.App.ServiceApp.DroneDocking
|
|
|
|
|
return Response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无人机状态获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<ResData> getResult(string taskid)
|
|
|
|
|
public Response<string> UploadFile(AirPortUploadDbReq req)
|
|
|
|
|
{
|
|
|
|
|
Response<string> Response = new Response<string>();
|
|
|
|
|
var filePath = req.filePath;
|
|
|
|
|
var uploadUrl = req.fileUrl;
|
|
|
|
|
var fileName = Path.GetFileName(filePath);
|
|
|
|
|
byte[] fileBuffer = null;
|
|
|
|
|
HttpClient client = null;
|
|
|
|
|
MultipartFormDataContent formData = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//文件过大,建议使用 大文件上传接口,分段读取,进行上传
|
|
|
|
|
fileBuffer = File.ReadAllBytes(filePath);
|
|
|
|
|
client = new HttpClient();
|
|
|
|
|
client.Timeout = new TimeSpan(0, 0, 0, 5);
|
|
|
|
|
formData = new MultipartFormDataContent();
|
|
|
|
|
var fileContent = new ByteArrayContent(fileBuffer);
|
|
|
|
|
fileContent.Headers.ContentDisposition = new
|
|
|
|
|
ContentDispositionHeaderValue("attachment");
|
|
|
|
|
fileContent.Headers.ContentDisposition.FileName = fileName;
|
|
|
|
|
//注意:务必 根据 文件扩展名,这里指定 ContentType
|
|
|
|
|
fileContent.Headers.ContentType = new
|
|
|
|
|
MediaTypeHeaderValue(fileName);
|
|
|
|
|
formData.Add(fileContent);
|
|
|
|
|
var request = new HttpRequestMessage
|
|
|
|
|
{
|
|
|
|
|
//注意:这里是 PUT
|
|
|
|
|
Method = HttpMethod.Put,
|
|
|
|
|
RequestUri = new Uri(uploadUrl),
|
|
|
|
|
Content = formData
|
|
|
|
|
};
|
|
|
|
|
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(result))
|
|
|
|
|
{
|
|
|
|
|
Response.Result = result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Response.Result = "上传失败";
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
fileBuffer = null;
|
|
|
|
|
formData?.Dispose();
|
|
|
|
|
client?.Dispose();
|
|
|
|
|
}
|
|
|
|
|
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())
|
|
|
|
|