[後端] 修改解析mssql connect string問題
This commit is contained in:
parent
3b12a644de
commit
e234159e87
@ -134,7 +134,6 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
#endregion 取得obix 設定
|
#endregion 取得obix 設定
|
||||||
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
#region 天歸檔
|
#region 天歸檔
|
||||||
if (await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Day"))
|
if (await task_Detail.GetNeedWorkTask("ArchiveElectricMeterDayJob", "Day"))
|
||||||
{
|
{
|
||||||
@ -630,6 +629,7 @@ namespace BackendWorkerService.Quartz.Jobs
|
|||||||
await task_Detail.WorkFail("ArchiveElectricMeterDayJob", "Day", exception.ToString());
|
await task_Detail.WorkFail("ArchiveElectricMeterDayJob", "Day", exception.ToString());
|
||||||
logger.LogError("【ArchiveElectricMeterDayJob】【天歸檔】【任務失敗】");
|
logger.LogError("【ArchiveElectricMeterDayJob】【天歸檔】【任務失敗】");
|
||||||
logger.LogError("【ArchiveElectricMeterDayJob】【天歸檔】【任務失敗】[Exception]:{0}", exception.ToString());
|
logger.LogError("【ArchiveElectricMeterDayJob】【天歸檔】【任務失敗】[Exception]:{0}", exception.ToString());
|
||||||
|
logger.LogError(await backgroundServiceMsSqlRepository.GetDbAllString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -136,5 +136,10 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string> GetDbAllString()
|
||||||
|
{
|
||||||
|
return "DBNAme:" + GetDbConnection().ConnectionString + " " + GetDbConnection().Database;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,7 @@ namespace Repository.BackendRepository.Interface
|
|||||||
/// <param name="fileInfos"></param>
|
/// <param name="fileInfos"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task ManualInsertFileBackgroundServiceTask(string building_ip, string building_guid, string target_table, List<Models.FileInfo> fileInfos);
|
Task ManualInsertFileBackgroundServiceTask(string building_ip, string building_guid, string target_table, List<Models.FileInfo> fileInfos);
|
||||||
|
|
||||||
|
Task<string> GetDbAllString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,10 @@ namespace Repository.Helper
|
|||||||
var databaseStr = ed.AESDecrypt(_msSqlDBConfig.Database);
|
var databaseStr = ed.AESDecrypt(_msSqlDBConfig.Database);
|
||||||
var rootStr = ed.AESDecrypt(_msSqlDBConfig.Root);
|
var rootStr = ed.AESDecrypt(_msSqlDBConfig.Root);
|
||||||
var passwordStr = ed.AESDecrypt(_msSqlDBConfig.Password);
|
var passwordStr = ed.AESDecrypt(_msSqlDBConfig.Password);
|
||||||
var portStr = ed.AESDecrypt(_msSqlDBConfig.Port);
|
var portStr = !string.IsNullOrEmpty(_msSqlDBConfig.Port) ? ed.AESDecrypt(_msSqlDBConfig.Port) : string.Empty;
|
||||||
|
|
||||||
var connStr = $"data source={serverStr},{portStr};initial catalog={databaseStr};User ID={rootStr};Password={passwordStr}";
|
string source = !string.IsNullOrEmpty(portStr) ? string.Join(",", serverStr, portStr) : serverStr;
|
||||||
|
var connStr = $"data source={source};initial catalog={databaseStr};User ID={rootStr};Password={passwordStr}";
|
||||||
//var conn = new SqlConnection(connStr);
|
//var conn = new SqlConnection(connStr);
|
||||||
return connStr;
|
return connStr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user