Commit 6b20f279 by ruyun.zhang

提取执行失败重试3次

parent e285003f
using Dapper;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Dapper;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPOI.SS.UserModel;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services.ExtractExcelService;
using Performance.Services.Queues;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Performance.Services
{
......@@ -263,6 +262,9 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
/// <returns></returns>
public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql, Dictionary<string, string> parameters)
{
int retryCount = 0;
while (retryCount < 2)
{
try
{
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
......@@ -275,13 +277,14 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
_logger.LogInformation($"提取绩效数据SQL脚本{execsql}");
var result = connection.Query(execsql, commandTimeout: 20000);
_logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录");
return result;
}
}
catch (Exception ex)
{
_logger.LogError($"提取绩效数据SQL脚本查询错误:{execsql} 错误原因:{ex}");
_logger.LogError($"重试:{retryCount};提取绩效数据SQL脚本查询错误:{execsql} 错误原因:{ex}");
retryCount++;
}
}
return null;
}
......
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