RptConfigFile.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 if(st == "TCCleannessA")
  38. {
  39. this.Systype = OTS_SysType_ID.TCCleannessA;
  40. }
  41. else if(st == "BatteryCleannessA")
  42. {
  43. this.Systype = OTS_SysType_ID.BatteryCleannessA;
  44. }
  45. else {this.Systype = OTS_SysType_ID.SteelMineral;}
  46. this.PartSizeFile = GetDataFromDataSetXml(ds, "name", "PartSizeFile");//ds.Tables[1].Rows[2]["Name"].ToString();
  47. this.TriTempFile = m_TriTempFile;
  48. }
  49. 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>
  50. {
  51. string v = "";
  52. if (memberName == "XMLData")
  53. {
  54. v = dataSrc.Tables[memberName].Rows[0][propertyName].ToString();
  55. }
  56. else
  57. {
  58. var rs = dataSrc.Tables["Member"].Select("RegName= '" + memberName+"'");
  59. v=rs[0][propertyName].ToString();//find the first match row's corresponding property value.
  60. }
  61. return v;
  62. }
  63. /// <summary>
  64. /// 粒级表目录
  65. /// </summary>
  66. public string PartSizeFileFolder
  67. {
  68. get { return ConfigFileFolder; }
  69. }
  70. public OTS_SysType_ID Systype
  71. {
  72. get;
  73. set;
  74. }
  75. /// <summary>
  76. /// 三元相图目录
  77. /// </summary>
  78. public string TrigTemplateFileFolder
  79. {
  80. get { return ConfigFileFolder; }
  81. }
  82. public string ReportMgrParamFile
  83. {
  84. get { return m_ReportMgrParamFile; }
  85. }
  86. /// <summary>
  87. /// 比例因子
  88. /// </summary>
  89. //public string Scale
  90. //{
  91. // get;
  92. // set;
  93. //}
  94. /// <summary>
  95. /// 默认使用的粒级文件
  96. /// </summary>
  97. public string PartSizeFile
  98. {
  99. get;
  100. set;
  101. }
  102. /// <summary>
  103. /// 默认使用的三元相图模板文件
  104. /// </summary>
  105. public string TriTempFile
  106. {
  107. get;
  108. set;
  109. }
  110. }
  111. }