CNAS取数仪器端升级
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ExcelInstrumentData.cs 4.1KB

5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
5 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").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. return dataBaseService.GetInstrumentData(
  57. new ExcelOpenParams
  58. {
  59. StrPath = StrLocalPath,
  60. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  61. autoSql = ExcelFormat.AutoSql
  62. });
  63. }
  64. public override DataTable GetInstrumentDataByDate()
  65. {
  66. return dataBaseService.GetInstrumentDataByDate(
  67. new ExcelOpenParams
  68. {
  69. StrPath = StrLocalPath,
  70. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  71. autoSql = ExcelFormat.AutoSql
  72. },
  73. new ConditionParams
  74. {
  75. TableName = strTableName,
  76. DateColumn = strDateColumn,
  77. DateValue = strDate
  78. });
  79. }
  80. public override DataTable GetInstrumentDataStruct()
  81. {
  82. return dataBaseService.GetInstrumentDataStruct(
  83. new ExcelOpenParams
  84. {
  85. StrPath = StrLocalPath,
  86. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  87. autoSql = ExcelFormat.AutoSql
  88. },
  89. new ConditionParams
  90. {
  91. TableName = strTableName
  92. });
  93. }
  94. }
  95. }