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.

ExcelInstrumentData.cs 3.8KB

5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
5 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. ExcelFormat= FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml");
  24. if (ExcelFormat.ReadExcelFileMode == "0")
  25. {
  26. RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo);
  27. remoteFileCopy.CopyFileFromRemote(".xls");
  28. this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls";
  29. this.strTableName = vs[0].ToString();
  30. this.strDateColumn = vs[1].ToString();
  31. this.strDate = vs[2].ToString();
  32. }
  33. else
  34. {
  35. string strFileName = DateTime.Now.ToString(ExcelFormat.ExcelFileNameFormat);
  36. if (strFileName != "")
  37. {
  38. RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo);
  39. remoteFileCopy.CopyFileFromRemote(".xls", strFileName + ".xls");
  40. this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls";
  41. this.strTableName = $"'{strFileName}$'";
  42. this.strDateColumn = vs[1].ToString();
  43. this.strDate = vs[2].ToString();
  44. }
  45. }
  46. }
  47. public override Dictionary<string, DataTable> GetInstrumentData()
  48. {
  49. return dataBaseService.GetInstrumentData(
  50. new ExcelOpenParams
  51. {
  52. StrPath = StrLocalPath,
  53. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  54. autoSql = ExcelFormat.AutoSql
  55. });
  56. }
  57. public override DataTable GetInstrumentDataByDate()
  58. {
  59. return dataBaseService.GetInstrumentDataByDate(
  60. new ExcelOpenParams
  61. {
  62. StrPath = StrLocalPath,
  63. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  64. autoSql = ExcelFormat.AutoSql
  65. },
  66. new ConditionParams
  67. {
  68. TableName = strTableName,
  69. DateColumn = strDateColumn,
  70. DateValue = strDate
  71. });
  72. }
  73. public override DataTable GetInstrumentDataStruct()
  74. {
  75. return dataBaseService.GetInstrumentDataStruct(
  76. new ExcelOpenParams
  77. {
  78. StrPath = StrLocalPath,
  79. ExcelFileVersion = ExcelFormat.ExcelFileVersion,
  80. autoSql = ExcelFormat.AutoSql
  81. },
  82. new ConditionParams
  83. {
  84. TableName = strTableName
  85. });
  86. }
  87. }
  88. }