CNAS取数仪器端升级
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

ExcelInstrumentData.cs 4.2KB

4 ay önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 ExcelInstrumentData : InstrumentData
  13. {
  14. public string StrLocalPath { get; set; }
  15. public string strTableName { get; set; }
  16. public string strDateColumn { get; set; }
  17. public string strDate { get; set; }
  18. public IExcelService dataBaseService { get { return new ExcelDBService(); } }
  19. public ExcelFormatConfig ExcelFormat { get; set; }
  20. public ExcelInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs)
  21. {
  22. if (dataSourceInfo.Path == null) return;
  23. try
  24. {
  25. ExcelFormat = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml");
  26. if (ExcelFormat.ReadExcelFileMode == "0")
  27. {
  28. RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo);
  29. remoteFileCopy.CopyFileFromRemote(".xls");
  30. this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls";
  31. this.strTableName = vs[0].ToString();
  32. this.strDateColumn = vs[1].ToString();
  33. this.strDate = vs[2].ToString();
  34. }
  35. else
  36. {
  37. string strFileName = DateTime.Now.ToString(ExcelFormat.ExcelFileNameFormat);
  38. if (strFileName != "")
  39. {
  40. RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo);
  41. remoteFileCopy.CopyFileFromRemote(".xls", strFileName + ".xls");
  42. this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path+ strFileName + ".xls", "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls";
  43. this.strTableName = $"'{strFileName}$'";
  44. this.strDateColumn = vs[1].ToString();
  45. this.strDate = vs[2].ToString();
  46. }
  47. }
  48. }
  49. catch (Exception ex)
  50. {
  51. AppLog.Error(ex.Message);
  52. }
  53. }
  54. public override Dictionary<string, DataTable> GetInstrumentData()
  55. {
  56. if (StrLocalPath == null || ExcelFormat == null || ExcelFormat == null)
  57. return new Dictionary<string, DataTable>();
  58. return dataBaseService.GetInstrumentData(
  59. new ExcelOpenParams
  60. {
  61. StrPath = StrLocalPath,
  62. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  63. autoSql = ExcelFormat.AutoSql
  64. });
  65. }
  66. public override DataTable GetInstrumentDataByDate()
  67. {
  68. return dataBaseService.GetInstrumentDataByDate(
  69. new ExcelOpenParams
  70. {
  71. StrPath = StrLocalPath,
  72. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  73. autoSql = ExcelFormat.AutoSql
  74. },
  75. new ConditionParams
  76. {
  77. TableName = strTableName,
  78. DateColumn = strDateColumn,
  79. DateValue = strDate
  80. });
  81. }
  82. public override DataTable GetInstrumentDataStruct()
  83. {
  84. return dataBaseService.GetInstrumentDataStruct(
  85. new ExcelOpenParams
  86. {
  87. StrPath = StrLocalPath,
  88. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  89. autoSql = ExcelFormat.AutoSql
  90. },
  91. new ConditionParams
  92. {
  93. TableName = strTableName
  94. });
  95. }
  96. }
  97. }