|
@@ -1539,11 +1539,11 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
var file = "";
|
|
|
if (item.GraphicToken == item.PreviewGraphicToken)
|
|
|
{
|
|
|
- file = jpg;
|
|
|
+ file = ConvertToVid(item.PreviewGraphicToken, UploadFileTypeEnum.IMG);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- file = ConvertToVid(item.PreviewGraphicToken);
|
|
|
+ file = ConvertToVid(item.PreviewGraphicToken, UploadFileTypeEnum.MP4);
|
|
|
}
|
|
|
var consultationFileDTO = new ConsultationFileDTO();
|
|
|
consultationFileDTO.FileDataType = item.GraphicType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie;
|
|
@@ -1562,11 +1562,11 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
var file = "";
|
|
|
if (item.OriginalFileUrl == item.ThumbnailUrl)
|
|
|
{
|
|
|
- file = jpg;
|
|
|
+ file = ConvertToVid(item.OriginalFileUrl, UploadFileTypeEnum.IMG);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- file = ConvertToVid(item.OriginalFileUrl);
|
|
|
+ file = ConvertToVid(item.OriginalFileUrl, UploadFileTypeEnum.MP4);
|
|
|
}
|
|
|
var consultationFileDTO = new ConsultationFileDTO();
|
|
|
consultationFileDTO.FileDataType = item.FileType == 0 ? RemedicalFileDataTypeEnum.ThirdVidSingle : RemedicalFileDataTypeEnum.ThirdVidMovie;
|
|
@@ -1768,7 +1768,16 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
if (!string.IsNullOrWhiteSpace(oldFileToken) && oldFileToken.StartsWith(prefix))
|
|
|
{
|
|
|
var fileUrl = oldFileToken.Replace(prefix, "");
|
|
|
- var localPath = DownloadAsync(fileUrl, $"{Guid.NewGuid():N}.jpg").Result;
|
|
|
+ var fileName = Path.GetFileNameWithoutExtension(fileUrl);
|
|
|
+ var jpgFileName = fileName + ".jpg";
|
|
|
+ //验证头
|
|
|
+ var storageUrl = "";
|
|
|
+ var validateResult = ValidateHeadFile(jpgFileName, ref storageUrl);
|
|
|
+ if (validateResult)
|
|
|
+ {
|
|
|
+ return storageUrl;
|
|
|
+ }
|
|
|
+ var localPath = DownloadAsync(fileUrl, jpgFileName).Result;
|
|
|
if (!string.IsNullOrWhiteSpace(localPath))
|
|
|
{
|
|
|
var newUrl = UploadAsync(localPath).Result;
|
|
@@ -1788,7 +1797,71 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private string ConvertToVid(string oldFileToken)
|
|
|
+ private bool ValidateHeadFile(string fileName, ref string storageUrl)
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ var authorizationResult = _jsonRpcProxy.Storage.GetAuthorizationAsync(new FileServiceRequest
|
|
|
+ {
|
|
|
+ Token = DefaultToken,
|
|
|
+ FileName = fileName,
|
|
|
+ IsRechristen = false,
|
|
|
+ IsUpgradePackage = false,
|
|
|
+ RequestMethod = "head"
|
|
|
+ }).Result;
|
|
|
+ if (authorizationResult == null)
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo("Head Create Signature Fail");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var newRequestHeads = new Dictionary<string, string>();
|
|
|
+ newRequestHeads.Add("Authorization", authorizationResult.Authorization);
|
|
|
+ storageUrl = authorizationResult.StorageUrl;
|
|
|
+ using (var newRequest = new HttpRequestMessage())
|
|
|
+ {
|
|
|
+ newRequest.RequestUri = new Uri(storageUrl);
|
|
|
+ newRequest.Method = HttpMethod.Head;
|
|
|
+ foreach (var newHead in newRequestHeads)
|
|
|
+ {
|
|
|
+ newRequest.Headers.TryAddWithoutValidation(newHead.Key, newHead.Value);
|
|
|
+ }
|
|
|
+ var newResponse = _httpClient.SendAsync(newRequest).Result;
|
|
|
+ if (newResponse != null && newResponse.StatusCode == HttpStatusCode.OK)
|
|
|
+ {
|
|
|
+ //read response content
|
|
|
+ if (storageUrl.Contains("/SystemUpgradePackage/"))//表示vinno
|
|
|
+ {
|
|
|
+ var resultContent = newResponse.Content.Headers.ContentLength > 0;
|
|
|
+ if (resultContent)
|
|
|
+ {
|
|
|
+ result = result & true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = result & false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var newETag = newResponse.Headers?.ETag?.Tag ?? string.Empty;
|
|
|
+ if (!string.IsNullOrEmpty(newETag))
|
|
|
+ {
|
|
|
+ result = result & true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = result & false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = result & false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private string ConvertToVid(string oldFileToken, UploadFileTypeEnum fileType)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -1796,22 +1869,32 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
if (!string.IsNullOrWhiteSpace(oldFileToken) && oldFileToken.StartsWith(prefix))
|
|
|
{
|
|
|
var fileUrl = oldFileToken.Replace(prefix, "");
|
|
|
- var localPath = DownloadAsync(fileUrl, $"{Guid.NewGuid():N}.vid").Result;
|
|
|
- if (!string.IsNullOrWhiteSpace(localPath))
|
|
|
+ var fileName = Path.GetFileNameWithoutExtension(fileUrl);
|
|
|
+ var vidFileName = fileName + ".vid";
|
|
|
+ //验证头
|
|
|
+ var storageUrl = "";
|
|
|
+ var validateResult = ValidateHeadFile(vidFileName, ref storageUrl);
|
|
|
+ if (validateResult)
|
|
|
{
|
|
|
- var newUrl = UploadAsync(localPath).Result;
|
|
|
- if (!string.IsNullOrWhiteSpace(newUrl))
|
|
|
- {
|
|
|
- return newUrl;
|
|
|
- }
|
|
|
+ return storageUrl;
|
|
|
+ }
|
|
|
+ var vidResult = _jsonRpcProxy.Lab.DoConvertToVid(new WingInterfaceLibrary.Request.Lab.LabFileInfoRequest
|
|
|
+ {
|
|
|
+ Token = DefaultToken,
|
|
|
+ FileName = fileName,
|
|
|
+ FilePath = fileUrl,
|
|
|
+ FileType = fileType
|
|
|
+ }).Result;
|
|
|
+ if (!string.IsNullOrWhiteSpace(vidResult))
|
|
|
+ {
|
|
|
+ return vidResult;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return oldFileToken;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- Logger.WriteLineWarn($"ConvertToJpg err, ex:{ex}");
|
|
|
+ Logger.WriteLineWarn($"ConvertToVid err, ex:{ex}");
|
|
|
return oldFileToken;
|
|
|
}
|
|
|
}
|
|
@@ -2051,7 +2134,7 @@ namespace Flyinsono.DBCopy.Tool.Service
|
|
|
{
|
|
|
Token = DefaultToken,
|
|
|
FileName = Path.GetFileName(localPath),
|
|
|
- IsRechristen = true,
|
|
|
+ IsRechristen = false,
|
|
|
});
|
|
|
var fileUrl = authorizationResult.StorageUrl;
|
|
|
using (var fileStream = new FileStream(localPath, FileMode.Open))
|