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.

90 line
3.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 InstrumentDescribeZH
  13. {
  14. public InstrumentDescribeZH(InstrumentType instrumentType, string TableName)
  15. {
  16. this.instrumentType = instrumentType;
  17. this.TableName = TableName;
  18. }
  19. public InstrumentType instrumentType { get; set; }
  20. public string TableName { get; set; }
  21. public Dictionary<string,string> DictField { get; set; }
  22. public IExcelService excelDataBaseService { get { return new ExcelDBService(); } }
  23. //根据仪器类型获取字段中文描述
  24. public void GetFieldDescribe()
  25. {
  26. //1.获得存放文件名
  27. DictField = new Dictionary<string, string>();
  28. string strFileName = "";
  29. switch (instrumentType)
  30. {
  31. case InstrumentType.AshMeltingPoint:
  32. strFileName = "AshMeltingPoint.xls";
  33. break;
  34. case InstrumentType.ElementalAnalyzer:
  35. strFileName = "ElementalAnalyzer.xls";
  36. break;
  37. case InstrumentType.IndustrialAnalyzer:
  38. strFileName = "IndustrialAnalyzer.xls";
  39. break;
  40. case InstrumentType.InfraredSulfurMeter:
  41. strFileName = "InfraredSulfurMeter.xls";
  42. break;
  43. case InstrumentType.MoistureMeter:
  44. strFileName = "MoistureMeter.xls";
  45. break;
  46. case InstrumentType.SulphurMeter:
  47. strFileName = "SulphurMeter.xls";
  48. break;
  49. case InstrumentType.CalorimetricApparatus:
  50. strFileName = "CalorimetricApparatus.xls";
  51. break;
  52. }
  53. if (strFileName == "") return;
  54. //根据文件名和表名,读取该文件中表
  55. ExcelFormatConfig excelFormat = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml");
  56. string strPath = FileHelper.getBasePath() + "Document\\" + strFileName;
  57. DataTable dt = excelDataBaseService.GetDataByTableName(
  58. new ExcelOpenParams
  59. {
  60. StrPath = strPath,
  61. ExcelFileVersion= excelFormat.ExcelFileVersion,
  62. autoSql=excelFormat.AutoSql
  63. },
  64. new ConditionParams
  65. {
  66. TableName = TableName
  67. });
  68. if (dt == null || dt.Rows.Count == 0) return;
  69. //整理数据
  70. foreach (DataRow dr in dt.Rows)
  71. {
  72. string strColumnName = dr[0].ToString();
  73. string strColumnDetail = dr[3].ToString();
  74. if (!DictField.ContainsKey(strColumnName))
  75. DictField.Add(strColumnName.ToUpper(), strColumnDetail);
  76. }
  77. }
  78. }
  79. }