123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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;
- /// <summary>
- /// 数据库服务器地址(服务器名)
- /// </summary>
- public string DataBaseServer
- {
- get { return _DataBaseServer; }
- set { _DataBaseServer = value; }
- }
- int _DataBasePort;
- /// <summary>
- /// 端口
- /// </summary>
- public int DataBasePort
- {
- get { return _DataBasePort; }
- set { _DataBasePort = value; }
- }
- string _DataBaseUser;
- /// <summary>
- /// 用户
- /// </summary>
- public string DataBaseUser
- {
- get { return _DataBaseUser; }
- set { _DataBaseUser = value; }
- }
- string _DataBasePass;
- /// <summary>
- /// 密码
- /// </summary>
- public string DataBasePass
- {
- get { return _DataBasePass; }
- set { _DataBasePass = value; }
- }
- string _DataBaseName;
- /// <summary>
- /// 数据库名
- /// </summary>
- public string DataBaseName
- {
- get { return _DataBaseName; }
- set { _DataBaseName = value; }
- }
- /// <summary>
- /// 获取数据库连接字任串
- /// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public string DBConnectionString
- {
- get
- {
- return GetDBConnectionString();
- }
- }
- /// <summary>
- /// 设置铂金版云数据库
- /// </summary>
- /// <param name="enterpriseID"></param>
- 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;
- }
- /// <summary>
- /// 获取数据库连接字任串
- /// </summary>
- /// <returns></returns>
- 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);
- }
- }
- }
|