You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using CommonFunc.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using XGL.Models;
|
|
|
|
namespace CommonFunc
|
|
{
|
|
/// <summary>
|
|
/// 数据对象类
|
|
/// </summary>
|
|
public class SqlDataObject
|
|
{
|
|
/// <summary>
|
|
/// 返回一sql连接字符串
|
|
/// </summary>
|
|
public static string GetMySqlConnectionString
|
|
{
|
|
get
|
|
{
|
|
ConnectionConfig conSetting = DatabaseConfig.GetSettingsDirectory();
|
|
return CommonFunc.DESProvider.DecryptString(conSetting.MySqlConnectionString);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 业务数据库
|
|
/// </summary>
|
|
public static string GetMESSqlConnectionString
|
|
{
|
|
get
|
|
{
|
|
string connStr = Utils.GetAppSetting("CloudConnectionString");
|
|
return CommonFunc.DESProvider.DecryptString(connStr);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 云数据库
|
|
/// </summary>
|
|
public static string GetCloudSqlConnectionString
|
|
{
|
|
get
|
|
{
|
|
string connStr = Utils.GetAppSetting("CloudConnectionString");
|
|
return CommonFunc.DESProvider.DecryptString(connStr);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取本地业务库
|
|
/// </summary>
|
|
public static string GetMESClientSqlConnectionString
|
|
{
|
|
get
|
|
{
|
|
string connStr = Utils.GetAppSetting("MESClientConnectionString");
|
|
return CommonFunc.DESProvider.DecryptString(connStr);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取网络业务库
|
|
/// </summary>
|
|
public static string GetMESNetClientSqlConnectionString
|
|
{
|
|
get
|
|
{
|
|
string sql = $"SELECT db_url FROM sys_datasource where pool_name = '{"ds_"+Utils.GetAppSetting("SiteCode")}'";
|
|
DataTable dt = Utils.cloudDBHelper.getDataSet(sql).Tables[0];
|
|
if (dt == null || dt.Rows.Count <= 0 || string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
|
|
{
|
|
string connStr = Utils.GetAppSetting("MESNetClientConnectionString");
|
|
return CommonFunc.DESProvider.DecryptString(connStr);
|
|
}
|
|
else
|
|
{
|
|
string connStr= dt.Rows[0][0].ToString();
|
|
//更新网络业务库连接字符串
|
|
Utils.SetAppSetting("MESNetClientConnectionString", CommonFunc.DESProvider.EncryptString(connStr));
|
|
//返回网络业务库连接字符串
|
|
return connStr;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|