using CnasSynchronousCommon; using CnasSynchronusDAL; using CnasSynchronusIDAL; using CnasSynchrousModel; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace CnasSynchronusClient { public class SQLServerInstrumentData : InstrumentData { public string StrHost { get; set; } public string StrServerName { get; set; } public string StrUser { get; set; } public string StrPwd { get; set; } public string StrConnection { get; set; } public string strTableName { get; set; } public string strDateColumn { get; set; } public string strDate { get; set; } public SqlServerFormatConfig sqlServerFormat { get; set; } public ISqlServerService sqlserverDataBaseService { get { return new SqlServerDBService(); } } public SQLServerInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs) { try { sqlServerFormat = FileOperation.GetFormatConfigData("SqlServerFormatConfig.xml"); this.StrHost = dataSourceInfo.Host; this.StrServerName = dataSourceInfo.ServerName; this.StrUser = dataSourceInfo.UserId; this.StrPwd = dataSourceInfo.UserPwd; this.StrConnection = sqlServerFormat.SqlServerConnection; this.strTableName = vs[0].ToString(); this.strDateColumn = vs[1].ToString(); this.strDate = vs[2].ToString(); } catch (Exception ex) { AppLog.Error(ex.Message); } } /// /// 获取本地配置文件 /// /// public override Dictionary GetInstrumentData() { return sqlserverDataBaseService.GetInstrumentData(new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "" , StrConnecttion = StrConnection }); } /// /// 获取本地数据(根据日期) /// /// public override DataTable GetInstrumentDataByDate() { return sqlserverDataBaseService.GetInstrumentDataByDate( new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "", StrConnecttion = StrConnection, autoSql = sqlServerFormat.AutoSql }, new ConditionParams { TableName = strTableName, DateColumn = strDateColumn, DateValue = strDate }); } /// /// 测试连接 /// /// public bool TestSQLServerLink() { return sqlserverDataBaseService.TestConnect(new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "", StrConnecttion= StrConnection }); } public override DataTable GetInstrumentDataStruct() { return sqlserverDataBaseService.GetInstrumentDataStruct( new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "", StrConnecttion = StrConnection, autoSql = sqlServerFormat.AutoSql }, new ConditionParams { TableName = strTableName }); } } }