| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 | using OTSCommon;using System;using System.Data;using System.Windows.Forms;using static OTSDataType.otsdataconst;namespace OTSIncAReportApp.OTSRstMgrFunction{     [Serializable]    public class RptConfigFile    {        private string path;        public const string ConfigFileFolder = @".\Config\ProData\";        private const string m_TriTempFile = "DefaultTriTemplateFile.tpf";        public static string m_ReportMgrParamFile = "\\Config\\SysData\\OTSReportMgrParam.rpf"; //报告对应使用的参数文件名        static RptConfigFile m_config=null;       public static RptConfigFile GetRptConfig()        {            if (m_config == null)            {                m_config = new RptConfigFile();            }            return m_config;        }        private RptConfigFile()        {            path = Application.StartupPath + RptConfigFile.m_ReportMgrParamFile;         //报表程序的配置文件            LoadDataFromFile();        }        public void LoadDataFromFile()        {            DataSet ds = XMLoperate.GetXml(path);                      var st= GetDataFromDataSetXml(ds, "systype");            if (st == "IncA")            {                this.Systype = OTS_SysType_ID.IncA;            }            else if(st == "TCCleannessA")            {                this.Systype = OTS_SysType_ID.TCCleannessA;            }            else if(st == "BatteryCleannessA")            {                this.Systype = OTS_SysType_ID.BatteryCleannessA;            }            this.PartSizeFile = GetDataFromDataSetXml(ds, "name", "PartSizeFile");//ds.Tables[1].Rows[2]["Name"].ToString();            this.TriTempFile = m_TriTempFile;        }                public string GetDataFromDataSetXml(DataSet dataSrc, string propertyName,string memberName="XMLData")//the particular schema of OTS system.such as "<XMLData p1="aa" p2="bb"><Member RegName="cc" p1="dd"/>...</XMLData>        {            string v = "";            if (memberName == "XMLData")            {                v = dataSrc.Tables[memberName].Rows[0][propertyName].ToString();            }            else             {                var rs = dataSrc.Tables["Member"].Select("RegName= '" + memberName+"'");                                    v=rs[0][propertyName].ToString();//find the first match row's corresponding property value.            }            return v;        }        /// <summary>        /// 粒级表目录        /// </summary>        public  string PartSizeFileFolder        {            get { return ConfigFileFolder; }        }        public OTS_SysType_ID Systype        {            get;            set;        }        /// <summary>        /// 三元相图目录        /// </summary>        public string TrigTemplateFileFolder        {            get { return ConfigFileFolder; }        }        public string ReportMgrParamFile        {            get { return m_ReportMgrParamFile; }        }        /// <summary>        /// 比例因子        /// </summary>        //public string Scale        //{        //    get;        //    set;        //}        /// <summary>        /// 默认使用的粒级文件        /// </summary>        public string PartSizeFile        {            get;            set;        }        /// <summary>        /// 默认使用的三元相图模板文件        /// </summary>        public string TriTempFile        {            get;            set;        }    }}
 |