using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LYFZ.WanYuKeFuData.Model
{
public class DBConnection : LYFZ.WinAPI.IDBConnection
{
public DBConnection()
{
}
public DBConnection(string enterpriseID, string ip, int port)
{
this.SetBJBCloudServerDBString(enterpriseID,ip,port);
}
string _DataBaseServer;
///
/// 数据库服务器地址(服务器名)
///
public string DataBaseServer
{
get { return _DataBaseServer; }
set { _DataBaseServer = value; }
}
int _DataBasePort;
///
/// 端口
///
public int DataBasePort
{
get { return _DataBasePort; }
set { _DataBasePort = value; }
}
string _DataBaseUser;
///
/// 用户
///
public string DataBaseUser
{
get { return _DataBaseUser; }
set { _DataBaseUser = value; }
}
string _DataBasePass;
///
/// 密码
///
public string DataBasePass
{
get { return _DataBasePass; }
set { _DataBasePass = value; }
}
string _DataBaseName;
///
/// 数据库名
///
public string DataBaseName
{
get { return _DataBaseName; }
set { _DataBaseName = value; }
}
///
/// 获取数据库连接字任串
///
[Newtonsoft.Json.JsonIgnore]
public string DBConnectionString
{
get
{
return GetDBConnectionString();
}
}
///
/// 设置铂金版云数据库
///
///
public void SetBJBCloudServerDBString(string enterpriseID,string ip,int port)
{
this.DataBaseServer = ip;
this.DataBasePort = port;
this.DataBaseName = "DB" + enterpriseID;
this.DataBaseUser = "SA" + enterpriseID;
this.DataBasePass = "PW@" + enterpriseID;
}
///
/// 获取数据库连接字任串
///
///
public string GetDBConnectionString()
{
string temp_DataBaseServer = _DataBaseServer;
if (_DataBasePort > 0)
{
temp_DataBaseServer = string.Format("{0},{1}", _DataBaseServer, _DataBasePort.ToString());
}
return String.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", temp_DataBaseServer, _DataBaseName, _DataBaseUser, _DataBasePass);
}
}
}