RptConfigFile.cs 3.3 KB

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