|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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>("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);
- }
- }
-
- /// <summary>
- /// 获取本地配置文件
- /// </summary>
- /// <returns></returns>
- public override Dictionary<string, DataTable> GetInstrumentData()
- {
- return sqlserverDataBaseService.GetInstrumentData(new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "" , StrConnecttion = StrConnection });
- }
-
- /// <summary>
- /// 获取本地数据(根据日期)
- /// </summary>
- /// <returns></returns>
- 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
- });
- }
-
- /// <summary>
- /// 测试连接
- /// </summary>
- /// <returns></returns>
- 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
- });
- }
- }
- }
|