mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
增加验证数据源
This commit is contained in:
parent
98808a65ea
commit
ee396146d3
@ -38,6 +38,27 @@ namespace OpenAuth.App
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 测试数据源连接
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">数据源ID</param>
|
||||||
|
/// <returns>是否连接成功</returns>
|
||||||
|
public bool TestConnection(string id)
|
||||||
|
{
|
||||||
|
var obj = Repository.GetById(id);
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
throw new Exception("数据源不存在");
|
||||||
|
}
|
||||||
|
var conn = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = obj.Connectionstring,
|
||||||
|
DbType = (DbType)Enum.Parse(typeof(DbType), obj.Dbtype),
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
});
|
||||||
|
conn.Open();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public void Add(AddOrUpdateExternalDataSourceReq req)
|
public void Add(AddOrUpdateExternalDataSourceReq req)
|
||||||
{
|
{
|
||||||
var obj = req.MapTo<ExternalDataSource>();
|
var obj = req.MapTo<ExternalDataSource>();
|
||||||
|
Loading…
Reference in New Issue
Block a user