修改推送频率
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
d2e3e4de86
commit
2addbe30dd
|
|
@ -1,4 +1,5 @@
|
|||
using AutoMapper;
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
using ExcelDataReader;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging;
|
||||
|
|
@ -904,15 +905,45 @@ namespace IRaCIS.Core.API.Controllers
|
|||
var downloadInfo = (SubejctVisitDownload)rusult.OtherData;
|
||||
|
||||
|
||||
long receivedsize = 0;
|
||||
long receivedSize = 0;
|
||||
long receivedCount = 0;
|
||||
|
||||
long totalSize = downloadInfo.ImageSize;
|
||||
long toTalCount = downloadInfo.ImageCount;
|
||||
long totalCount = downloadInfo.ImageCount;
|
||||
|
||||
var abortToken = HttpContext.RequestAborted;
|
||||
|
||||
// -------- SignalR 节流参数 --------
|
||||
var notifyInterval = TimeSpan.FromSeconds(1);
|
||||
var lastNotify = DateTime.UtcNow;
|
||||
|
||||
|
||||
async Task NotifyProgressAsync(bool force = false)
|
||||
{
|
||||
if (!force && DateTime.UtcNow - lastNotify < notifyInterval)
|
||||
return;
|
||||
|
||||
lastNotify = DateTime.UtcNow;
|
||||
|
||||
var progress = new
|
||||
{
|
||||
CountPercent = totalCount > 0
|
||||
? Math.Round(receivedCount * 100m / totalCount, 2).ToString() + "%"
|
||||
: "0%",
|
||||
|
||||
SizePercent = totalSize > 0
|
||||
? Math.Round(receivedSize * 100m / totalSize, 2).ToString() + "%"
|
||||
: "0%"
|
||||
};
|
||||
|
||||
// 不阻塞下载流程
|
||||
_ = _downLoadHub.Clients
|
||||
.User(_userInfo.IdentityUserId.ToString())
|
||||
.ReceivProgressAsync(
|
||||
inCommand.CurrentNoticeId,
|
||||
progress
|
||||
);
|
||||
}
|
||||
|
||||
Response.ContentType = "application/zip";
|
||||
Response.Headers["Content-Disposition"] = $"attachment; filename=Image_{ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId)}.zip";
|
||||
Response.Headers["Cache-Control"] = "no-store";
|
||||
|
|
@ -948,7 +979,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
foreach (var instance in series.InstanceList)
|
||||
{
|
||||
//当前完成大小
|
||||
receivedsize = receivedsize + instance.FileSize ?? 0;
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
abortToken.ThrowIfCancellationRequested();
|
||||
|
|
@ -992,19 +1023,14 @@ namespace IRaCIS.Core.API.Controllers
|
|||
//await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
|
||||
|
||||
await _downLoadHub.Clients.User(_userInfo.IdentityUserId.ToString()).ReceivProgressAsync(inCommand.CurrentNoticeId,
|
||||
(new
|
||||
{
|
||||
CountPercent = downloadInfo.ImageCount > 0 ? Math.Round(receivedCount * 100m / downloadInfo.ImageCount, 2) : 0m,
|
||||
SizePercent = totalSize > 0 ? Math.Round(receivedsize * 100m / totalSize, 2) : 0m
|
||||
}
|
||||
));
|
||||
await NotifyProgressAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 正常完成
|
||||
await NotifyProgressAsync(true);
|
||||
await _patientService.DownloadImageSuccess(downloadInfo.Id);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
|
@ -1028,6 +1054,10 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ namespace IRaCIS.Core.API
|
|||
public class DownloadHub : Hub<IDownloadClient>
|
||||
{
|
||||
|
||||
public ILogger<UploadHub> _logger { get; set; }
|
||||
public DownloadHub(ILogger<UploadHub> logger)
|
||||
public ILogger<DownloadHub> _logger { get; set; }
|
||||
public DownloadHub(ILogger<DownloadHub> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue