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 lines
3.9KB

  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.Data.SqlClient;
  9. using System.Linq;
  10. using System.Text;
  11. namespace CnasSynchronusClient
  12. {
  13. public class PostgreSQLServerInstrumentData : InstrumentData
  14. {
  15. public string StrHost { get; set; }
  16. public string StrServerName { get; set; }
  17. public string StrUser { get; set; }
  18. public string StrPwd { get; set; }
  19. public string strTableName { get; set; }
  20. public string strDateColumn { get; set; }
  21. public string strDate { get; set; }
  22. public string StrPort { get; set; }
  23. public IPostgreSqlDBService mysqlDataBaseService { get { return new PostgreSqlDBService(); } }
  24. public PostgreSqlFormatConfig PostgreSqlFormat { get; set; }
  25. public PostgreSQLServerInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs)
  26. {
  27. try
  28. {
  29. PostgreSqlFormat = FileOperation.GetFormatConfigData<PostgreSqlFormatConfig>("PostgreSqlFormatConfig.xml");
  30. this.StrHost = dataSourceInfo.Host;
  31. this.StrServerName = dataSourceInfo.ServerName;
  32. this.StrUser = dataSourceInfo.UserId;
  33. this.StrPwd = dataSourceInfo.UserPwd;
  34. this.StrPort = dataSourceInfo.Port;
  35. this.strTableName = vs[0].ToString();
  36. this.strDateColumn = vs[1].ToString();
  37. this.strDate = vs[2].ToString();
  38. }
  39. catch (Exception ex)
  40. {
  41. AppLog.Error(ex.Message);
  42. }
  43. }
  44. public override Dictionary<string, DataTable> GetInstrumentData()
  45. {
  46. return mysqlDataBaseService.GetInstrumentData(new PostgreSQLOpenParams { StrHost = StrHost, StrServer = StrServerName, StrUser = StrUser, StrPwd = StrPwd, StrPort = StrPort });
  47. }
  48. public override DataTable GetInstrumentDataByDate()
  49. {
  50. return mysqlDataBaseService.GetInstrumentDataByDate(
  51. new PostgreSQLOpenParams
  52. {
  53. StrHost = StrHost,
  54. StrServer = StrServerName,
  55. StrUser = StrUser,
  56. StrPwd = StrPwd,
  57. StrPort = StrPort,
  58. autoSql = PostgreSqlFormat.AutoSql
  59. },
  60. new ConditionParams
  61. {
  62. TableName = strTableName,
  63. DateColumn = strDateColumn,
  64. DateValue = strDate
  65. }
  66. );
  67. }
  68. public override DataTable GetInstrumentDataStruct()
  69. {
  70. return mysqlDataBaseService.GetInstrumentDataStruct(
  71. new PostgreSQLOpenParams
  72. {
  73. StrHost = StrHost,
  74. StrServer = StrServerName,
  75. StrUser = StrUser,
  76. StrPwd = StrPwd,
  77. StrPort = StrPort,
  78. autoSql = PostgreSqlFormat.AutoSql
  79. },
  80. new ConditionParams
  81. {
  82. TableName = strTableName
  83. }
  84. );
  85. }
  86. /// <summary>
  87. /// 测试连接
  88. /// </summary>
  89. /// <returns></returns>
  90. public bool TestSQLServerLink()
  91. {
  92. return mysqlDataBaseService.TestConnect(
  93. StrHost,StrServerName,StrUser,StrPwd,StrPort
  94. );
  95. //{
  96. // =StrHost,
  97. // = StrServerName,
  98. // = StrUser,
  99. // StrPwd,
  100. // = "",
  101. // StrConnecttion = StrConnection
  102. //});
  103. }
  104. public override DataTable GetInstrumentDataStruct(string Tablename)
  105. {
  106. throw new NotImplementedException();
  107. }
  108. }
  109. }