|
- using CnasSynchronousCommon;
- using CnasSynchronusDAL;
- using CnasSynchronusIDAL;
- using CnasSynchrousModel;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
-
- namespace CnasSynchronusClient
- {
- public class InstrumentDescribeZH
- {
- public InstrumentDescribeZH(InstrumentType instrumentType, string TableName)
- {
- this.instrumentType = instrumentType;
- this.TableName = TableName;
- }
-
- public InstrumentType instrumentType { get; set; }
-
- public string TableName { get; set; }
-
- public Dictionary<string,string> DictField { get; set; }
-
- public IExcelService excelDataBaseService { get { return new ExcelDBService(); } }
-
- //根据仪器类型获取字段中文描述
- public void GetFieldDescribe()
- {
- //1.获得存放文件名
- DictField = new Dictionary<string, string>();
- string strFileName = "";
- switch (instrumentType)
- {
- case InstrumentType.AshMeltingPoint:
- strFileName = "AshMeltingPoint.xls";
- break;
- case InstrumentType.ElementalAnalyzer:
- strFileName = "ElementalAnalyzer.xls";
- break;
- case InstrumentType.IndustrialAnalyzer:
- strFileName = "IndustrialAnalyzer.xls";
- break;
- case InstrumentType.InfraredSulfurMeter:
- strFileName = "InfraredSulfurMeter.xls";
- break;
- case InstrumentType.MoistureMeter:
- strFileName = "MoistureMeter.xls";
- break;
- case InstrumentType.SulphurMeter:
- strFileName = "SulphurMeter.xls";
- break;
- case InstrumentType.CalorimetricApparatus:
- strFileName = "CalorimetricApparatus.xls";
- break;
- }
- if (strFileName == "") return;
-
- //根据文件名和表名,读取该文件中表
- ExcelFormatConfig excelFormat = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml");
- string strPath = FileHelper.getBasePath() + "Document\\" + strFileName;
- DataTable dt = excelDataBaseService.GetDataByTableName(
- new ExcelOpenParams
- {
- StrPath = strPath,
- ExcelFileVersion= excelFormat.ExcelFileVersion,
- autoSql=excelFormat.AutoSql
- },
- new ConditionParams
- {
- TableName = TableName
- });
-
- if (dt == null || dt.Rows.Count == 0) return;
-
- //整理数据
- foreach (DataRow dr in dt.Rows)
- {
- string strColumnName = dr[0].ToString();
- string strColumnDetail = dr[3].ToString();
-
- if (!DictField.ContainsKey(strColumnName))
- DictField.Add(strColumnName.ToUpper(), strColumnDetail);
- }
- }
- }
- }
|