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