Commit 980923c5 by lcx

自定义提取日志推送

parent fae509c7
......@@ -61,13 +61,13 @@ public ApiResponse CustomExtract(int allotId)
}
else
{
scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
scopedQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
}
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
});
_notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
_notificationQueue.Send(new Notification(allotId, "ReceiveMessage", new TextContent("自定义数据提取任务开始执行")));
return new ApiResponse(ResponseType.OK);
......
......@@ -8,6 +8,7 @@
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
using Performance.Services.Queues;
using System;
using System.Collections.Generic;
using System.IO;
......@@ -26,6 +27,7 @@ public class CustomExtractService : IAutoInjection
private readonly PerforPerdeptdicRepository _perforPerdeptdicRepository;
private readonly PerforHospitalconfigRepository _perforHospitalconfigRepository;
private readonly PerforCustscriptRepository _perforcustscriptRepository;
private readonly IHubNotificationQueue _notificationQueue;
public CustomExtractService(
ILogger<CustomExtractService> logger,
......@@ -35,7 +37,8 @@ public class CustomExtractService : IAutoInjection
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository,
PerforCustscriptRepository perforcustscriptRepository)
PerforCustscriptRepository perforcustscriptRepository,
IHubNotificationQueue notificationQueue)
{
_logger = logger;
_options = options;
......@@ -45,6 +48,7 @@ public class CustomExtractService : IAutoInjection
_perforPerdeptdicRepository = perforPerdeptdicRepository;
_perforHospitalconfigRepository = perforHospitalconfigRepository;
_perforcustscriptRepository = perforcustscriptRepository;
_notificationQueue = notificationQueue;
}
public bool CheckConfigScript(int userId, int allotId)
......@@ -136,6 +140,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
var conf = configs.FirstOrDefault(w => w.Id == item.ConfigId);
if (conf != null)
{
_notificationQueue.Send(new Notification(allot.ID, "ReceiveMessage", new TextContent($"正在提取“{item.Name}”的数据")));
var execsql = item.Script;
var dynamics = QueryData(conf, execsql, parameters);
......@@ -150,8 +155,12 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
var sheet = workbook.CreateSheet(item.Name);
// 没数据跳过
if (dynamics == null || dynamics.Count() == 0)
{
_notificationQueue.Send(new Notification(allot.ID, "ReceiveMessage", new TextContent($"“{item.Name}”提取的数据为空")));
continue;
}
_notificationQueue.Send(new Notification(allot.ID, "ReceiveMessage", new TextContent($"正在写入“{item.Name}”的数据")));
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
for (int col = 0; col < headers.Count; col++)
{
......@@ -219,6 +228,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
}
row++;
}
_notificationQueue.Send(new Notification(allot.ID, "ReceiveMessage", new TextContent($"“{item.Name}”的数据写入完成")));
}
catch (Exception ex)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment