44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Maticsoft.DBUtility
|
|
{
|
|
public class PubConstant
|
|
{
|
|
public static Dictionary<string, string> dbs = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// 获取连接字符串
|
|
/// </summary>
|
|
public static string ConnectionString
|
|
{
|
|
get
|
|
{
|
|
|
|
string _connectionString = AppConfigurtaionServices.Configuration.GetConnectionString("ConnectionString");
|
|
string ConStringEncrypt = AppConfigurtaionServices.Configuration.GetConnectionString("ConStringEncrypt");
|
|
if (ConStringEncrypt == "true")
|
|
{
|
|
_connectionString = DESEncrypt.Decrypt(_connectionString);
|
|
}
|
|
return _connectionString;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到web.config里配置项的数据库连接字符串。
|
|
/// </summary>
|
|
/// <param name="configName"></param>
|
|
/// <returns></returns>
|
|
public static string GetConnectionString(string configName)
|
|
{
|
|
string connectionString = DESEncrypt.Decrypt(AppConfigurtaionServices.Configuration.GetConnectionString(configName));
|
|
return connectionString;
|
|
}
|
|
}
|
|
}
|