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