Commit 804a1896 by wyc

连接地址配置

parent de2d9088
......@@ -2301,7 +2301,7 @@
<param name="procIds"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.LowProcController.GetDatumAsync(System.Int64,System.Nullable{System.Int64},Performance.DtoModels.PagedQueryRequest,System.Collections.Generic.List{Performance.DtoModels.DynamicQuery})">
<member name="M:Performance.Api.Controllers.LowProcController.GetDatumAsync(System.Int64,System.String,Performance.DtoModels.PagedQueryRequest,System.Collections.Generic.List{Performance.DtoModels.DynamicQuery})">
<summary>
扩展数据查询
</summary>
......
......@@ -12,5 +12,6 @@ public class AppSQLEncrypt
public string TempMySqlConnectionString { get; set; } = "";
public string TempSqlServerConnectionString { get; set; } = "";
public string TempOracleConnectionString { get; set; } = "";
public string TempPostgreSqlConnectionString { get; set; } = "";
}
}
using System;
using System.Data;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using MySql.Data.MySqlClient;
using Npgsql;
using Oracle.ManagedDataAccess.Client;
using Performance.Infrastructure.Helper;
using System;
using System.Data;
using System.Data.SqlClient;
namespace Performance.Repository
{
......@@ -31,11 +32,15 @@ public static IDbConnection Create(DatabaseType type, string connectionString)
case DatabaseType.Oracle:
return new OracleConnection(connectionString);
case DatabaseType.PostgreSql:
return new NpgsqlConnection(connectionString);
default:
throw new Exception($"nonsupport {DatabaseType.MySql}");
throw new Exception($"不支持的数据库类型: {type}");
}
}
/// <summary>
/// 创建连接字符串
/// </summary>
......@@ -75,6 +80,14 @@ public static string GetConnectionString(DatabaseType type, string ip, string da
return string.Format(connectionString, ip, database, uid, pwd);
}
if (type == DatabaseType.PostgreSql)
{
string connectionString = string.IsNullOrEmpty(AppSQLEncryptConfig.Instance.TempPostgreSqlConnectionString)
? "Host={0};Database={1};Username={2};Password={3};timeout=1024;Pooling=true;"
: AppSQLEncryptConfig.Instance.TempPostgreSqlConnectionString;
return string.Format(connectionString, ip, database, uid, pwd);
}
return "";
}
......
......@@ -4,6 +4,7 @@ public enum DatabaseType
{
MySql = 0,
SqlServer = 1,
Oracle = 2
Oracle = 2,
PostgreSql = 3
}
}
......@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="5.0.18" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.4" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using AutoMapper;
using AutoMapper;
using Microsoft.Extensions.Logging;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Infrastructure.Helper;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Performance.Services.ExtractExcelService
{
......
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