Commit 5f62e208 authored by 段廷瑞's avatar 段廷瑞

Merge branch 'master' of http://192.168.1.181/root/Ftt_Common

parents 563e385a 4ad24f61
......@@ -327,6 +327,7 @@ namespace UpdateExecuter
{
FileInfo _execFile = null;
string _execSql = "";
var configDbName = ""; // 链接中配置的库。
try
{
ShowFileInfo($"在客户[{client}]执行脚本……", null, true);
......@@ -335,10 +336,16 @@ namespace UpdateExecuter
{
using (SqlConnection conn = new SqlConnection(strConn))
{
//部分脚本文件可能会使用Use Ftt,如果后面执行的脚本文件中没有显示Use DB 则都虎被执行到Ftt。需要先取一下链接中配置的库,在每个脚本文件执行之前都执行一下切换动作,切换到配置的库。
if (string.IsNullOrEmpty(configDbName)) configDbName = SqlHelper.ExecuteScalar(conn, CommandType.Text, "Select Db_Name();").ToString();
// 按顺序逐个文件执行,可保证脚本之间的依赖关系
Array.ForEach(files, new Action<FileInfo>(delegate (FileInfo file)
{
_execFile = file;
// 执行环境切换到默认库。
SqlHelper.ExecuteNonQuery(conn, CommandType.Text, $"USE {configDbName};");
_execFile = file;
ShowFileInfo($"在客户[{client}]执行脚本文件:{file.Name}.", file, true);
......
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