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.

InstrumentDescribeZH.cs 2.7KB

преди 5 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. string strPath = FileHelper.getBasePath() + "Document\\" + strFileName;
  56. DataTable dt = excelDataBaseService.GetDataByTableName(new ExcelOpenParams { StrPath = strPath }, new ConditionParams { TableName = TableName });
  57. if (dt == null || dt.Rows.Count == 0) return;
  58. //整理数据
  59. foreach (DataRow dr in dt.Rows)
  60. {
  61. string strColumnName = dr[0].ToString();
  62. string strColumnDetail = dr[3].ToString();
  63. if (!DictField.ContainsKey(strColumnName))
  64. DictField.Add(strColumnName.ToUpper(), strColumnDetail);
  65. }
  66. }
  67. }
  68. }