RptConfigFile.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using System.Data;
  3. using System.Windows.Forms;
  4. namespace OTSCommon.Model
  5. {
  6. public enum OTS_SysType_ID
  7. {
  8. IncA = 0,
  9. CleannessA = 1
  10. }
  11. [Serializable]
  12. public class RptConfigFile
  13. {
  14. private string path;
  15. public const string ConfigFileFolder = @".\Config\ProData\";
  16. private const string m_TriTempFile = "DefaultTriTemplateFile.tpf";
  17. public static string m_ReportMgrParamFile = "\\Config\\SysData\\OTSReportMgrParam.rpf"; //报告对应使用的参数文件名
  18. static RptConfigFile m_config=null;
  19. public static RptConfigFile GetRptConfig()
  20. {
  21. if (m_config == null)
  22. {
  23. m_config = new RptConfigFile();
  24. }
  25. return m_config;
  26. }
  27. private RptConfigFile()
  28. {
  29. path = Application.StartupPath + RptConfigFile.m_ReportMgrParamFile; //报表程序的配置文件
  30. LoadDataFromFile();
  31. }
  32. public void LoadDataFromFile()
  33. {
  34. DataSet ds = XMLoperate.GetXml(path);
  35. var st= GetDataFromDataSetXml(ds, "systype");
  36. if (st == "IncA")
  37. {
  38. this.Systype = OTS_SysType_ID.IncA;
  39. }
  40. else
  41. {
  42. this.Systype = OTS_SysType_ID.CleannessA;
  43. }
  44. this.PartSizeFile = GetDataFromDataSetXml(ds, "name", "PartSizeFile");//ds.Tables[1].Rows[2]["Name"].ToString();
  45. this.TriTempFile = m_TriTempFile;
  46. }
  47. 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>
  48. {
  49. string v = "";
  50. if (memberName == "XMLData")
  51. {
  52. v = dataSrc.Tables[memberName].Rows[0][propertyName].ToString();
  53. }
  54. else
  55. {
  56. var rs = dataSrc.Tables["Member"].Select("RegName= '" + memberName+"'");
  57. v=rs[0][propertyName].ToString();//find the first match row's corresponding property value.
  58. }
  59. return v;
  60. }
  61. /// <summary>
  62. /// 粒级表目录
  63. /// </summary>
  64. public string PartSizeFileFolder
  65. {
  66. get { return ConfigFileFolder; }
  67. }
  68. public OTS_SysType_ID Systype
  69. {
  70. get;
  71. set;
  72. }
  73. /// <summary>
  74. /// 三元相图目录
  75. /// </summary>
  76. public string TrigTemplateFileFolder
  77. {
  78. get { return ConfigFileFolder; }
  79. }
  80. public string ReportMgrParamFile
  81. {
  82. get { return m_ReportMgrParamFile; }
  83. }
  84. /// <summary>
  85. /// 比例因子
  86. /// </summary>
  87. //public string Scale
  88. //{
  89. // get;
  90. // set;
  91. //}
  92. /// <summary>
  93. /// 默认使用的粒级文件
  94. /// </summary>
  95. public string PartSizeFile
  96. {
  97. get;
  98. set;
  99. }
  100. /// <summary>
  101. /// 默认使用的三元相图模板文件
  102. /// </summary>
  103. public string TriTempFile
  104. {
  105. get;
  106. set;
  107. }
  108. }
  109. }