CNAS取数仪器端升级
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 line
4.1KB

  1. using CnasSynchronousCommon;
  2. using CnasSynchronusDAL;
  3. using CnasSynchronusIDAL;
  4. using CnasSynchrousModel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. namespace CnasSynchronusClient
  11. {
  12. public class SQLServerInstrumentData : InstrumentData
  13. {
  14. public string StrHost { get; set; }
  15. public string StrServerName { get; set; }
  16. public string StrUser { get; set; }
  17. public string StrPwd { get; set; }
  18. public string StrConnection { get; set; }
  19. public string strTableName { get; set; }
  20. public string strDateColumn { get; set; }
  21. public string strDate { get; set; }
  22. public SqlServerFormatConfig sqlServerFormat { get; set; }
  23. public ISqlServerService sqlserverDataBaseService { get { return new SqlServerDBService(); } }
  24. public SQLServerInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs)
  25. {
  26. try
  27. {
  28. sqlServerFormat = FileOperation.GetFormatConfigData<SqlServerFormatConfig>("SqlServerFormatConfig.xml");
  29. this.StrHost = dataSourceInfo.Host;
  30. this.StrServerName = dataSourceInfo.ServerName;
  31. this.StrUser = dataSourceInfo.UserId;
  32. this.StrPwd = dataSourceInfo.UserPwd;
  33. this.StrConnection = sqlServerFormat.SqlServerConnection;
  34. this.strTableName = vs[0].ToString();
  35. this.strDateColumn = vs[1].ToString();
  36. this.strDate = vs[2].ToString();
  37. }
  38. catch (Exception ex)
  39. {
  40. AppLog.Error(ex.Message);
  41. }
  42. }
  43. /// <summary>
  44. /// 获取本地配置文件
  45. /// </summary>
  46. /// <returns></returns>
  47. public override Dictionary<string, DataTable> GetInstrumentData()
  48. {
  49. return sqlserverDataBaseService.GetInstrumentData(new SqlServerOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = "" , StrConnecttion = StrConnection });
  50. }
  51. /// <summary>
  52. /// 获取本地数据(根据日期)
  53. /// </summary>
  54. /// <returns></returns>
  55. public override DataTable GetInstrumentDataByDate()
  56. {
  57. return sqlserverDataBaseService.GetInstrumentDataByDate(
  58. new SqlServerOpenParams
  59. {
  60. StrHost = StrHost,
  61. StrServer = StrServerName,
  62. StrUser = StrUser,
  63. StrPwd = StrPwd,
  64. StrPort = "",
  65. StrConnecttion = StrConnection,
  66. autoSql = sqlServerFormat.AutoSql
  67. },
  68. new ConditionParams
  69. {
  70. TableName = strTableName,
  71. DateColumn = strDateColumn,
  72. DateValue = strDate
  73. });
  74. }
  75. /// <summary>
  76. /// 测试连接
  77. /// </summary>
  78. /// <returns></returns>
  79. public bool TestSQLServerLink()
  80. {
  81. return sqlserverDataBaseService.TestConnect(new SqlServerOpenParams
  82. {
  83. StrHost = StrHost,
  84. StrServer = StrServerName,
  85. StrUser = StrUser,
  86. StrPwd = StrPwd,
  87. StrPort = "",
  88. StrConnecttion= StrConnection
  89. });
  90. }
  91. public override DataTable GetInstrumentDataStruct()
  92. {
  93. return sqlserverDataBaseService.GetInstrumentDataStruct(
  94. new SqlServerOpenParams
  95. {
  96. StrHost = StrHost,
  97. StrServer = StrServerName,
  98. StrUser = StrUser,
  99. StrPwd = StrPwd,
  100. StrPort = "",
  101. StrConnecttion = StrConnection,
  102. autoSql = sqlServerFormat.AutoSql
  103. },
  104. new ConditionParams
  105. {
  106. TableName = strTableName
  107. });
  108. }
  109. }
  110. }