BasicData.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. using DevExpress.Office.Drawing;
  2. using NPOI.Util;
  3. using OTSCommon.DBOperate;
  4. using OTSIncAReportApp.DataOperation.DataAccess;
  5. using OTSIncAReportApp.OTSRstMgrFunction;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using static OTSDataType.otsdataconst;
  13. using static OTSIncAReportApp.OTSReport_Export;
  14. namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
  15. {
  16. public class BasicData
  17. {
  18. ParticleData fielddata;
  19. private string SizeChart = "";
  20. List<string> colid = new List<string>();
  21. List<string> colid_Below7 = new List<string>();
  22. List<string> GroupInformation = new List<string>();
  23. private List<DataTable> BData = new List<DataTable>();
  24. private List<DataTable> Measurements = new List<DataTable>();//测量结果数据列队
  25. private DataTable AllClass = new DataTable();
  26. private DataTable AllElement = new DataTable();
  27. private bool IsShereAClassificationGroup = false;
  28. private ResultFile resfile;
  29. private string FilePath = "";
  30. private string VDA19String = "5,15,25,50,100,150,200,400,600,1000";
  31. /// <summary>
  32. /// 获取粒级表
  33. /// </summary>
  34. public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
  35. {
  36. colid.Clear();
  37. colid_Below7.Clear();
  38. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  39. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  40. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  41. SizeChart = ds.Tables[0].Rows[0]["Sizes"].ToString();
  42. var sizes = ParseSizeString(SizeChart);
  43. BuildSizeColumnLists(sizes, colid, colid_Below7);
  44. }
  45. /// <summary>
  46. /// 获取粒级表
  47. /// </summary>
  48. /// <returns></returns>
  49. public List<string> GetParticlesizeTable()
  50. {
  51. if (colid.Count > 7)
  52. {
  53. return colid;
  54. }
  55. else
  56. {
  57. return colid_Below7;
  58. }
  59. }
  60. public void SetDBData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
  61. {
  62. // 输出集合初始化
  63. BData = new List<DataTable>();
  64. Measurements = new List<DataTable>();
  65. // 本次使用的 ParticleData(局部)
  66. ParticleData particleData = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  67. // 基础列
  68. var baseCols = new List<string> { "TypeName", "ar", "TypeId", "Largest", "Class", "GroupId", "con" };
  69. // 获取粒级表 sizestr(支持 VDA19)
  70. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  71. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  72. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  73. string sizestr = m_mbszclass.M_VDA19.IsVDA19 ? VDA19String : ds.Tables[0].Rows[0]["Sizes"].ToString();
  74. var sizes = ParseSizeString(sizestr);
  75. // 构建 size 列名(保留原有逻辑)
  76. bool blBelow7;
  77. List<string> sizeBucketNames;
  78. BuildSizeColumns(sizes, out sizeBucketNames, out blBelow7);
  79. // 构建 m_bt_DBData 列
  80. DataTable m_bt_DBData = new DataTable();
  81. foreach (var c in baseCols.Concat(sizeBucketNames))
  82. {
  83. m_bt_DBData.Columns.Add(c);
  84. }
  85. // 读取并过滤原始数据(TypeId > 10)
  86. DataTable dt = InvalidRemoval(particleData.GetParticleListForParticlSize("area", ""));
  87. DataTable AreaInformationOfAllElements = InvalidRemoval(particleData.GetAreaByAllIncA(""));
  88. DataTable dtp = InvalidRemoval(particleData.GetParticleAll(""));
  89. // 计算匹配列名 po
  90. string po = ComputeMode;
  91. switch (po)
  92. {
  93. case "DMAX":
  94. po = "DMAX";
  95. break;
  96. case "DMIN":
  97. po = "DMIN";
  98. break;
  99. case "ECD":
  100. po = "Area";
  101. break;
  102. case "FERET":
  103. po = "DFERET";
  104. break;
  105. }
  106. // 将 dtp 按 TypeId 建索引,避免多次 Select
  107. var dtpByType = GroupRowsByType(dtp);
  108. // 构建 m_bt_DBData 行
  109. foreach (DataRow srcRow in dt.Rows)
  110. {
  111. string typeId = srcRow["TypeId"].ToString();
  112. DataRow dr = m_bt_DBData.NewRow();
  113. dr["TypeName"] = srcRow["TypeName"].ToString();
  114. dr["TypeId"] = typeId;
  115. dr["con"] = srcRow["con"].ToString();
  116. dr["GroupId"] = srcRow["GroupId"].ToString();
  117. dr["Class"] = string.IsNullOrEmpty(srcRow["GroupName"].ToString()) ? "Default" : srcRow["GroupName"].ToString();
  118. dr["Largest"] = Math.Round(Convert.ToDouble(srcRow["max"]), 2);
  119. List<DataRow> rowsOfType;
  120. dtpByType.TryGetValue(typeId, out rowsOfType);
  121. if (rowsOfType == null) rowsOfType = new List<DataRow>();
  122. // 为每个 size bucket 计数
  123. for (int a = 0; a < sizeBucketNames.Count; a++)
  124. {
  125. double min = 0, max = double.MaxValue;
  126. if (blBelow7)
  127. {
  128. min = sizes[a];
  129. max = (a < sizes.Count - 1) ? sizes[a + 1] : double.MaxValue;
  130. }
  131. else
  132. {
  133. var parts = sizeBucketNames[a].Split('~');
  134. double.TryParse(parts[0], out min);
  135. if (parts.Length > 1 && parts[1] != "MAX")
  136. {
  137. double.TryParse(parts[1], out max);
  138. }
  139. else if (parts.Length > 1 && parts[1] == "MAX")
  140. {
  141. max = double.MaxValue;
  142. }
  143. }
  144. int count = CountRowsInRange(rowsOfType, po, min, max);
  145. dr[sizeBucketNames[a]] = count;
  146. }
  147. // ar 字段填充
  148. dr["ar"] = 0;
  149. foreach (DataRow arRow in AreaInformationOfAllElements.Rows)
  150. {
  151. if (arRow["TypeId"].ToString() == typeId)
  152. {
  153. dr["ar"] = arRow["ar"];
  154. break;
  155. }
  156. }
  157. m_bt_DBData.Rows.Add(dr);
  158. }
  159. // 按名称过滤不需要的物质分类(保持原行为)
  160. FilterByDeleteClass(m_bt_DBData, m_mbszclass);
  161. // 构建 GroupInformation(去重)
  162. GroupInformation = ExtractUniqueClasses(m_bt_DBData, "Class");
  163. //GroupInformation = m_bt_DBData.AsEnumerable()
  164. // .Select(r => r["Class"].ToString())
  165. // .Distinct()
  166. // .ToList();
  167. // 系统类型为 IncA 时,按 Class 拆分
  168. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.IncA)
  169. {
  170. BData = GroupInformation.Select(g =>
  171. {
  172. var t = m_bt_DBData.Clone();
  173. foreach (DataRow r in m_bt_DBData.Rows)
  174. {
  175. if (r["Class"].ToString() == g) t.Rows.Add(r.ItemArray);
  176. }
  177. return t;
  178. }).ToList();
  179. Measurements = GroupInformation.Select(g =>
  180. {
  181. var t = dtp.Clone();
  182. foreach (DataRow r in dtp.Rows)
  183. {
  184. string groupName = string.IsNullOrEmpty(r["GroupName"].ToString()) ? "Default" : r["GroupName"].ToString();
  185. if (groupName == g) t.Rows.Add(r.ItemArray);
  186. }
  187. return t;
  188. }).ToList();
  189. return;
  190. }
  191. // 判断是否使用指定组(RuleGroup 中存在 GroupId == "0")
  192. bool useSpecifyGroups = TableContainsGroupIdZero(m_otsreport_export.m_mbszclass.RuleGroup);
  193. //bool useSpecifyGroups = m_otsreport_export.m_mbszclass.RuleGroup.AsEnumerable()
  194. // .Any(r => r["GroupId"].ToString() == "0");
  195. if (!useSpecifyGroups)
  196. {
  197. // 按现有 GroupId 拆分 BData
  198. var groups = ExtractUniqueClasses(m_bt_DBData, "GroupId");
  199. //var groups = m_bt_DBData.AsEnumerable()
  200. // .Select(r => r["GroupId"].ToString())
  201. // .Distinct()
  202. // .ToList();
  203. BData = groups.Select(g =>
  204. {
  205. var t = m_bt_DBData.Clone();
  206. foreach (DataRow r in m_bt_DBData.Rows)
  207. {
  208. if (r["GroupId"].ToString() == g) t.Rows.Add(r.ItemArray);
  209. }
  210. return t;
  211. }).ToList();
  212. // Measurements 按 GroupInformation 拆分
  213. Measurements = GroupInformation.Select(g =>
  214. {
  215. var t = dtp.Clone();
  216. foreach (DataRow r in dtp.Rows)
  217. {
  218. string strGroupId = string.IsNullOrEmpty(r["GroupName"].ToString()) ? "Default" : r["GroupName"].ToString();
  219. if (strGroupId == g) t.Rows.Add(r.ItemArray);
  220. }
  221. return t;
  222. }).ToList();
  223. return;
  224. }
  225. // 使用指定规则组:按模板 m_mbszclass.List_data 构造
  226. BData = BuildSpecifyGroup(m_bt_DBData, m_mbszclass);
  227. // 测量结果颗粒组队列(修复原代码索引误用)
  228. List<DataTable> datas1 = new List<DataTable>();
  229. List<string> stringsa = particleData.ObtainParticleCategory(m_otsreport_export, this);
  230. for (int i = 0; i < stringsa.Count; i++)
  231. {
  232. DataTable data = dtp.Clone();
  233. for (int a = 0; a < dtp.Rows.Count; a++)
  234. {
  235. if (Convert.ToInt64(dtp.Rows[i]["TypeId"]) > 10)
  236. {
  237. string strGroupName = string.IsNullOrEmpty(dtp.Rows[a]["GroupName"].ToString()) ? "Default" : dtp.Rows[a]["GroupName"].ToString();
  238. if (stringsa[i].ToString() == strGroupName)
  239. {
  240. data.Rows.Add(dtp.Rows[a].ItemArray);
  241. }
  242. }
  243. }
  244. datas1.Add(data);
  245. }
  246. Measurements = new List<DataTable>();
  247. for (int i = 0; i < m_otsreport_export.m_mbszclass.List_data.Count; i++)
  248. {
  249. bool b3 = false;
  250. string str_class = "";
  251. for (int a = 0; a < m_otsreport_export.m_mbszclass.RuleGroup.Rows.Count; a++)
  252. {
  253. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupId"].ToString() == m_otsreport_export.m_mbszclass.List_data[i].TableName)
  254. {
  255. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["display"].ToString() == "1")
  256. {
  257. str_class = m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupName"].ToString();
  258. b3 = true;
  259. }
  260. }
  261. }
  262. if (b3)
  263. {
  264. DataTable table = datas1[i].Clone();
  265. for (int a = 0; a < datas1[i].Rows.Count; a++)
  266. {
  267. for (int b = 0; b < m_otsreport_export.m_mbszclass.List_data[i].Rows.Count; b++)
  268. {
  269. if (m_otsreport_export.m_mbszclass.List_data[i].Rows[b]["display"].ToString() == "1")
  270. {
  271. if (datas1[i].Rows[a]["TypeId"].ToString() == m_otsreport_export.m_mbszclass.List_data[i].Rows[b]["STDId"].ToString())
  272. {
  273. table.Rows.Add(datas1[i].Rows[a].ItemArray);
  274. }
  275. }
  276. }
  277. }
  278. Measurements.Add(table);
  279. }
  280. }
  281. }
  282. // ---------- 私有辅助函数 ----------
  283. private bool TableContainsGroupIdZero(DataTable table)
  284. {
  285. if (table == null || table.Rows.Count == 0) return false;
  286. foreach (DataRow row in table.Rows)
  287. {
  288. if (row == null) continue;
  289. var obj = row["GroupId"];
  290. if (obj == null) continue;
  291. if (obj.ToString().Trim() == "0") return true;
  292. }
  293. return false;
  294. }
  295. private List<string> ExtractUniqueClasses(DataTable table ,string textNmae)
  296. {
  297. var set = new HashSet<string>();
  298. if (table == null) return new List<string>();
  299. foreach (DataRow row in table.Rows)
  300. {
  301. if (row == null) continue;
  302. var obj = row[textNmae];
  303. if (obj == null) continue;
  304. var s = obj.ToString().Trim();
  305. if (string.IsNullOrEmpty(s)) continue;
  306. set.Add(s);
  307. }
  308. return new List<string>(set);
  309. }
  310. private List<double> ParseSizeString(string sizestr)
  311. {
  312. if (string.IsNullOrEmpty(sizestr)) return new List<double>();
  313. return sizestr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
  314. .Select(s => { double.TryParse(s.Trim(), out double v); return v; })
  315. .ToList();
  316. }
  317. private void BuildSizeColumnLists(List<double> sizes, List<string> out_geCols, List<string> out_rangeCols)
  318. {
  319. out_geCols.Clear();
  320. out_rangeCols.Clear();
  321. if (sizes == null || sizes.Count == 0) return;
  322. foreach (var d in sizes) out_geCols.Add("≥" + d.ToString());
  323. for (int i = 0; i < sizes.Count - 1; i++)
  324. {
  325. out_rangeCols.Add(sizes[i].ToString() + "~" + sizes[i + 1].ToString());
  326. }
  327. out_rangeCols.Add(sizes.Last().ToString() + "~MAX");
  328. }
  329. private void BuildSizeColumns(List<double> sizes, out List<string> sizeBucketNames, out bool blBelow7)
  330. {
  331. sizeBucketNames = new List<string>();
  332. blBelow7 = (sizes != null && sizes.Count > 7);
  333. if (sizes == null || sizes.Count == 0) return;
  334. if (blBelow7)
  335. {
  336. foreach (var d in sizes) sizeBucketNames.Add("≥" + d.ToString());
  337. }
  338. else
  339. {
  340. for (int i = 0; i < sizes.Count - 1; i++)
  341. {
  342. sizeBucketNames.Add(sizes[i].ToString() + "~" + sizes[i + 1].ToString());
  343. }
  344. sizeBucketNames.Add(sizes.Last().ToString() + "~MAX");
  345. }
  346. }
  347. private Dictionary<string, List<DataRow>> GroupRowsByType(DataTable dtp)
  348. {
  349. var dict = new Dictionary<string, List<DataRow>>();
  350. if (dtp == null) return dict;
  351. foreach (DataRow r in dtp.Rows)
  352. {
  353. string key = r["TypeId"].ToString();
  354. if (!dict.ContainsKey(key)) dict[key] = new List<DataRow>();
  355. dict[key].Add(r);
  356. }
  357. return dict;
  358. }
  359. private int CountRowsInRange(List<DataRow> rows, string columnName, double min, double max)
  360. {
  361. if (rows == null || rows.Count == 0) return 0;
  362. int cnt = 0;
  363. if (columnName == "Area")
  364. {
  365. double areaMin = (min / 2.0) * (min / 2.0) * Math.PI;
  366. double areaMax = (max == double.MaxValue) ? double.MaxValue : (max / 2.0) * (max / 2.0) * Math.PI;
  367. foreach (var r in rows)
  368. {
  369. if (double.TryParse(r["Area"].ToString(), out double v))
  370. {
  371. if (v >= areaMin && v < areaMax) cnt++;
  372. }
  373. }
  374. }
  375. else
  376. {
  377. foreach (var r in rows)
  378. {
  379. if (double.TryParse(r[columnName].ToString(), out double v))
  380. {
  381. if (v >= min && v < max) cnt++;
  382. }
  383. }
  384. }
  385. return cnt;
  386. }
  387. private void FilterByDeleteClass(DataTable table, c_TemplateClass m_mbszclass)
  388. {
  389. if (m_mbszclass?.M_KLLBXX?.list_str_kllb_DeleteClass == null || m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count == 0) return;
  390. var toRemove = new HashSet<string>(m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass);
  391. for (int i = table.Rows.Count - 1; i >= 0; i--)
  392. {
  393. if (toRemove.Contains(table.Rows[i]["TypeName"].ToString()))
  394. {
  395. table.Rows.RemoveAt(i);
  396. }
  397. }
  398. }
  399. private List<DataTable> BuildSpecifyGroup(DataTable m_bt_DBData, c_TemplateClass m_mbszclass)
  400. {
  401. var SpecifyGroup = new List<DataTable>();
  402. for (int i = 0; i < m_mbszclass.List_data.Count; i++)
  403. {
  404. DataTable tpl = m_mbszclass.List_data[i];
  405. DataTable data = m_bt_DBData.Clone();
  406. bool visible = false;
  407. string str_class = "";
  408. foreach (DataRow rg in m_mbszclass.RuleGroup.Rows)
  409. {
  410. if (rg["GroupId"].ToString() == tpl.TableName)
  411. {
  412. if (rg["display"].ToString() == "1")
  413. {
  414. visible = true;
  415. str_class = rg["GroupName"].ToString();
  416. }
  417. break;
  418. }
  419. }
  420. data.TableName = tpl.TableName;
  421. if (!visible)
  422. {
  423. SpecifyGroup.Add(data);
  424. continue;
  425. }
  426. for (int a = 0; a < tpl.Rows.Count; a++)
  427. {
  428. if (tpl.Rows[a]["display"].ToString() != "1") continue;
  429. string stdId = tpl.Rows[a]["STDId"].ToString();
  430. var found = FindRowByTypeId(m_bt_DBData, stdId);
  431. if (found != null)
  432. {
  433. data.Rows.Add(found.ItemArray);
  434. }
  435. else
  436. {
  437. DataRow newRow = data.NewRow();
  438. newRow["TypeName"] = tpl.Rows[a]["StrName"];
  439. newRow["ar"] = 0;
  440. newRow["TypeId"] = stdId;
  441. newRow["GroupId"] = tpl.Rows[a]["GroupId"];
  442. newRow["con"] = 0;
  443. newRow["Largest"] = 0;
  444. newRow["Class"] = str_class;
  445. for (int j = 7; j < data.Columns.Count; j++) newRow[j] = 0;
  446. data.Rows.Add(newRow);
  447. }
  448. }
  449. SpecifyGroup.Add(data);
  450. }
  451. return SpecifyGroup;
  452. }
  453. private DataRow FindRowByTypeId(DataTable table, string typeId)
  454. {
  455. foreach (DataRow r in table.Rows)
  456. {
  457. if (r["TypeId"].ToString() == typeId) return r;
  458. }
  459. return null;
  460. }
  461. // ---------- 其余方法保持原样 ----------
  462. /// <summary>
  463. /// 获取夹杂物组信息
  464. /// </summary>
  465. /// <returns></returns>
  466. public List<string> GetGroupInformation()
  467. {
  468. return GroupInformation;
  469. }
  470. /// <summary>
  471. /// 获取读取数据库并过滤颗粒
  472. /// </summary>
  473. /// <returns></returns>
  474. public List<DataTable> GetDBData()
  475. {
  476. return BData;
  477. }
  478. /// <summary>
  479. /// 获取读取数据库并过滤颗粒
  480. /// </summary>
  481. /// <returns></returns>
  482. public List<DataTable> etDBData()
  483. {
  484. return BData;
  485. }
  486. public void SetAllClass()
  487. {
  488. AllClass = fielddata.GetAllClass();
  489. }
  490. /// <summary>
  491. /// 获取全部大类
  492. /// </summary>
  493. /// <returns></returns>
  494. public DataTable GetAllClass()
  495. {
  496. return AllClass;
  497. }
  498. /// <summary>
  499. ///测量结果数据列队
  500. /// </summary>
  501. /// <returns></returns>
  502. public List<DataTable> GetMeasurements()
  503. {
  504. return Measurements;
  505. }
  506. /// <summary>
  507. /// 定义ParticleData类
  508. /// </summary>
  509. public void newParticleData(OTSReport_Export m_otsreport_export)
  510. {
  511. fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  512. }
  513. public ParticleData getParticleData()
  514. {
  515. return fielddata;
  516. }
  517. public void SetAllElement()
  518. {
  519. AllElement = fielddata.GetAllElement();
  520. }
  521. /// <summary>
  522. /// 获取全部元素
  523. /// </summary>
  524. /// <returns></returns>
  525. public DataTable GetAllElement()
  526. {
  527. return AllElement;
  528. }
  529. /// <summary>
  530. /// 判断是否有大分类,有为true
  531. /// </summary>
  532. /// <param name="m_otsreport_export"></param>
  533. /// <returns></returns>
  534. public void IsThereAMajorClassification(BasicData basicData, OTSReport_Export m_otsreport_export)
  535. {
  536. List<string> ClassName = new List<string>();
  537. for (int i = 0; i < BData.Count; i++)
  538. {
  539. if (BData[i].Rows.Count != 0)
  540. {
  541. ClassName.Add(i.ToString());
  542. }
  543. }
  544. if (ClassName.Count < 2)
  545. {
  546. IsShereAClassificationGroup = false;
  547. }
  548. else
  549. {
  550. IsShereAClassificationGroup = true;
  551. }
  552. }
  553. public bool GetIsThereAMajorClassification()
  554. {
  555. return IsShereAClassificationGroup;
  556. }
  557. public void IsResultFilesList(OTSReport_Export m_otsreport_export)
  558. {
  559. resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
  560. }
  561. /// <summary>
  562. /// 获取标准库名称
  563. /// </summary>
  564. /// <returns></returns>
  565. public string GetResfile()
  566. {
  567. string str_libraryName = "";
  568. bool endsWithDb = resfile.GetSTDName().EndsWith(".db", StringComparison.OrdinalIgnoreCase);
  569. if (endsWithDb)
  570. {
  571. str_libraryName = resfile.GetSTDName();
  572. }
  573. else
  574. {
  575. str_libraryName = resfile.GetSTDName() + ".db";
  576. }
  577. return str_libraryName;
  578. }
  579. public void IsFilePath(OTSReport_Export m_otsreport_export)
  580. {
  581. FilePath = m_otsreport_export.m_ReportApp.m_rstDataMgr.CurResultFile.FilePath;
  582. }
  583. /// <summary>
  584. /// 得到文件路径
  585. /// </summary>
  586. /// <returns></returns>
  587. public string GetFilePath()
  588. {
  589. return FilePath;
  590. }
  591. #region 内部函数(保留原有两个)
  592. private string getWhere(string max, string min, string col, string partic)
  593. {
  594. if (col == "Area")
  595. {
  596. return col + ">=" + ((Convert.ToDouble(min) / 2) * (Convert.ToDouble(min) / 2) * Math.PI).ToString() + " and " + col + "<" + ((Convert.ToDouble(max) / 2) * (Convert.ToDouble(max) / 2) * Math.PI).ToString() + " and TypeId=" + partic;
  597. }
  598. else
  599. {
  600. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  601. }
  602. }
  603. private DataTable InvalidRemoval(DataTable dt)
  604. {
  605. DataTable dataTable = dt.Copy();
  606. dataTable.Clear();
  607. for (int i = 0; i < dt.Rows.Count; i++)
  608. {
  609. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 10)
  610. {
  611. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  612. }
  613. }
  614. return dataTable;
  615. }
  616. #endregion
  617. }
  618. }