diff --git a/OpenAuth.App/ExtDataSourceApp/ExtDataSourceApp.cs b/OpenAuth.App/ExtDataSourceApp/ExtDataSourceApp.cs index 340f2ee3..bd8ca4fe 100644 --- a/OpenAuth.App/ExtDataSourceApp/ExtDataSourceApp.cs +++ b/OpenAuth.App/ExtDataSourceApp/ExtDataSourceApp.cs @@ -38,6 +38,27 @@ namespace OpenAuth.App return result; } + /// + /// 测试数据源连接 + /// + /// 数据源ID + /// 是否连接成功 + 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) { var obj = req.MapTo();