EChart_ParticlesComposition.cs 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. using CefSharp;
  2. using CefSharp.WinForms;
  3. using Newtonsoft.Json;
  4. using OTSIncAReportApp.DataOperation.DataAccess;
  5. using OTSIncAReportApp.DataOperation.Model;
  6. using OTSIncAReportApp.OTSDataMgrFunction;
  7. using OTSIncAReportApp.OTSSampleReportInfo;
  8. using OTSIncAReportApp.OTSTemplateDesigner;
  9. using OTSIncAReportApp.SysMgrTools;
  10. using OTSIncAReportGrids;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Windows.Forms;
  18. namespace OTSIncAReportApp.Control_ECharts
  19. {
  20. /// <summary>
  21. /// 各图char相关模块
  22. /// </summary>
  23. public partial class EChart_ParticlesComposition : UserControl
  24. {
  25. Hashtable table;
  26. #region 图表相关变量
  27. //y轴名称
  28. public string m_str_AxisY { get; set; }
  29. //定义图片
  30. //JsEvent js;
  31. //定义图片base64
  32. public string pic { get; set; }
  33. //定义图形类型
  34. public string type { get; set; }
  35. //图形数据
  36. public string data { get; set; }
  37. string url = "Resources/HTML/charts.html";
  38. //数据图类型:常用夹杂物分类CommonlyUsedClassify ,颗粒成分PComponent,元素成分EComponent,颗粒尺寸分布PSize
  39. string ComSel { get; set; }
  40. public bool Report { get; set; }
  41. frmReportApp m_ReportApp;
  42. List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 7, 8, 9 };
  43. List<string> NameList = new List<string>() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "非夹杂物颗粒SiC", "非夹杂物颗粒FeO", "未识别颗粒" };
  44. private frmReportConditionChoose m_conditionChoose;
  45. private ResultDataMgr m_DataMgr;
  46. Export_ReportTemplate m_export_reporttemplate;
  47. #endregion
  48. #region 窗体加载及构造函数
  49. public EChart_ParticlesComposition(frmReportApp ReportApp, string comsel)
  50. {
  51. ComSel = comsel;
  52. m_ReportApp = ReportApp;
  53. m_conditionChoose = ReportApp.m_conditionChoose;
  54. m_DataMgr = ReportApp.m_rstDataMgr;
  55. InitializeComponent();
  56. //国际化
  57. Language lan = new Language();
  58. table = lan.GetNameTable("CompositionDistributionGrid");
  59. m_export_reporttemplate = new Export_ReportTemplate();
  60. }
  61. public void EChart_ParticlesComposition_Report(string sou )
  62. {
  63. NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
  64. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  65. //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  66. //string sou = m_conditionChoose.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  67. if (!m_ReportApp.more)
  68. {
  69. m_ReportApp.trans = false;
  70. }
  71. else
  72. {
  73. m_ReportApp.trans = true;
  74. }
  75. m_ReportApp.more = false;
  76. //获取到List,json的字符串
  77. List<Chartdate> list_json_str = GetListJsonStrByChartStruct();
  78. url = "Resources/HTML/charts.html";
  79. m_ReportApp.data = JsonConvert.SerializeObject(list_json_str[0]);
  80. InitBrowser();
  81. }
  82. private void EChart_ParticlesComposition_Load(object sender, EventArgs e)
  83. {
  84. string sou = "";
  85. NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
  86. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  87. //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  88. if (Report)
  89. {
  90. sou = m_DataMgr.ResultFilesList[m_DataMgr.getSelectedIndex()].FileName.ToString();
  91. }
  92. else
  93. {
  94. sou = m_conditionChoose.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  95. }
  96. Report = false;
  97. if (sou.Contains("+"))
  98. {
  99. if (m_ReportApp.more)
  100. {
  101. m_ReportApp.trans = false;
  102. }
  103. else
  104. {
  105. m_ReportApp.trans = true;
  106. }
  107. m_ReportApp.more = true;
  108. //获取到List,json的字符串
  109. ChartdateMore list_json_str = GetListJsonStr();
  110. url = "Resources/HTML/chartsMore.html";
  111. m_ReportApp.data = JsonConvert.SerializeObject(list_json_str);
  112. }
  113. else
  114. {
  115. if (!m_ReportApp.more)
  116. {
  117. m_ReportApp.trans = false;
  118. }
  119. else
  120. {
  121. m_ReportApp.trans = true;
  122. }
  123. m_ReportApp.more = false;
  124. //获取到List,json的字符串
  125. for (int i=0;i< m_conditionChoose.m_SourceGridData.ConditionItemList.Count;i++)
  126. {
  127. if (m_conditionChoose.m_SourceGridData.ConditionItemList[i].itemDisplayVal.ToString()== sou)
  128. {
  129. m_DataMgr.SetWorkingResult((int)m_conditionChoose.m_SourceGridData.ConditionItemList[i].itemVal);
  130. }
  131. }
  132. List<Chartdate> list_json_str = GetListJsonStrByChartStruct();
  133. url = "Resources/HTML/charts.html";
  134. m_ReportApp.data = JsonConvert.SerializeObject(list_json_str[0]);
  135. }
  136. InitBrowser();
  137. }
  138. #endregion
  139. #region 获取单数据源
  140. private Chartdate GetCommonlyUsedClassifyData(string path)
  141. {
  142. string spinel = table["str20"].ToString();
  143. string oxide = table["str21"].ToString();
  144. string SulfurOxide = table["str22"].ToString();
  145. string nitrides = table["str23"].ToString();
  146. string sulfide = table["str24"].ToString();
  147. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  148. //创建新的图形数据源
  149. Chartdate chart = new Chartdate();
  150. chart.Title = m_ReportApp.m_reportname;
  151. chart.YName = m_str_AxisY;
  152. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  153. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  154. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  155. int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  156. DataTable dt = new DataTable();
  157. if (sel == 1)
  158. {
  159. List<Particle> particles = m_ReportApp.GetSelectedParticles();
  160. int SPINEL = 0;
  161. int OXIDE = 0;
  162. int SULFIDE_OXIDE = 0;
  163. int NITRIDE = 0;
  164. int SULFIDE = 0;
  165. for (int i = 0; i < m_ReportApp.GetSelectedParticles().Count; i++)
  166. {
  167. //SPINEL
  168. if ((particles[i].TypeId >= 10100 || particles[i].TypeId <= 10199) || (particles[i].TypeId >= 12200 || particles[i].TypeId <= 12299) || (particles[i].TypeId >= 11300 || particles[i].TypeId <= 11299))
  169. {
  170. SPINEL = SPINEL + 1;
  171. }
  172. //OXIDE
  173. if (particles[i].TypeId >= 10000 || particles[i].TypeId <= 10999)
  174. {
  175. OXIDE = OXIDE + 1;
  176. }
  177. //SULFIDE_OXIDE
  178. if ((particles[i].TypeId >= 11200 || particles[i].TypeId <= 11299) || (particles[i].TypeId >= 11400 || particles[i].TypeId <= 11499) || (particles[i].TypeId >= 11200 || particles[i].TypeId <= 11599))
  179. {
  180. SULFIDE_OXIDE = SULFIDE_OXIDE + 1;
  181. }
  182. //NITRIDE
  183. if (particles[i].TypeId >= 12000 || particles[i].TypeId <= 12999)
  184. {
  185. NITRIDE = NITRIDE + 1;
  186. }
  187. //SULFIDE
  188. if (particles[i].TypeId >= 11000 || particles[i].TypeId <= 11999)
  189. {
  190. SULFIDE = SULFIDE + 1;
  191. }
  192. }
  193. DataTable dataTable = new DataTable();
  194. dataTable.Columns.Add("SPINEL", typeof(String));
  195. dataTable.Columns.Add("OXIDE", typeof(String));
  196. dataTable.Columns.Add("SULFIDE_OXIDE", typeof(String));
  197. dataTable.Columns.Add("NITRIDE", typeof(String));
  198. dataTable.Columns.Add("SULFIDE", typeof(String));
  199. dataTable.Rows.Add();
  200. dataTable.Rows[0]["SPINEL"] = SPINEL.ToString();
  201. dataTable.Rows[0]["OXIDE"] = OXIDE.ToString();
  202. dataTable.Rows[0]["SULFIDE_OXIDE"] = SULFIDE_OXIDE.ToString();
  203. dataTable.Rows[0]["NITRIDE"] = NITRIDE.ToString();
  204. dataTable.Rows[0]["SULFIDE"] = SULFIDE.ToString();
  205. dt = dataTable;
  206. }
  207. else
  208. {
  209. dt = particledata.GetCommonlyUsedClassifyData();
  210. }
  211. //DataTable dt = dataTable;
  212. //设置标签名称
  213. List<string> listName = new List<string>();
  214. listName.Add(spinel);
  215. listName.Add(oxide);
  216. listName.Add(SulfurOxide);
  217. listName.Add(nitrides);
  218. listName.Add(sulfide);
  219. chart.ListName = listName;
  220. //设置数据
  221. List<Item> listData = new List<Item>();
  222. //ListData
  223. for (int k = 0; k < dt.Rows.Count; k++)
  224. {
  225. try
  226. {
  227. Item item_SPINEL = new Item()
  228. {
  229. value = decimal.Round(decimal.Parse(dt.Rows[k]["SPINEL"].ToString()), 2).ToString(),
  230. name = spinel
  231. };
  232. listData.Add(item_SPINEL);
  233. Item item_OXIDE = new Item()
  234. {
  235. value = decimal.Round(decimal.Parse(dt.Rows[k]["OXIDE"].ToString()), 2).ToString(),
  236. name = oxide
  237. };
  238. listData.Add(item_OXIDE);
  239. Item item_SULFIDE_OXIDE = new Item()
  240. {
  241. value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE_OXIDE"].ToString()), 2).ToString(),
  242. name = SulfurOxide
  243. };
  244. listData.Add(item_SULFIDE_OXIDE);
  245. Item item_NITRIDE = new Item()
  246. {
  247. value = decimal.Round(decimal.Parse(dt.Rows[k]["NITRIDE"].ToString()), 2).ToString(),
  248. name = nitrides
  249. };
  250. listData.Add(item_NITRIDE);
  251. Item item_SULFIDE = new Item()
  252. {
  253. value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE"].ToString()), 2).ToString(),
  254. name = sulfide
  255. };
  256. listData.Add(item_SULFIDE);
  257. }
  258. catch
  259. {
  260. Item item = new Item()
  261. {
  262. value = "",
  263. name = ""
  264. };
  265. listData.Add(item);
  266. }
  267. }
  268. chart.ListData = listData;
  269. return chart;
  270. }
  271. private Chartdate GetInclusionAreaRatioData(string path)
  272. {
  273. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  274. //创建新的图形数据源
  275. Chartdate chart = new Chartdate();
  276. chart.Title = m_ReportApp.m_reportname;
  277. chart.YName = m_str_AxisY;
  278. int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  279. DataTable data = particledata.GetAreaByAllIncA("");
  280. DataTable dt = ConSolidateInvalid(data);
  281. //设置标签名称
  282. List<string> listName = new List<string>();
  283. //ListName
  284. for (int i = 0; i < dt.Rows.Count; i++)
  285. {
  286. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
  287. {
  288. continue;
  289. }
  290. listName.Add(dt.Rows[i]["TypeName"].ToString());
  291. }
  292. chart.ListName = listName;
  293. //设置数据
  294. List<Item> listData = new List<Item>();
  295. //ListData
  296. for (int k = 0; k < dt.Rows.Count; k++)
  297. {
  298. string str = dt.Rows[k]["ar"].ToString();
  299. string name = dt.Rows[k]["TypeName"].ToString();
  300. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  301. {
  302. continue;
  303. }
  304. Item item = new Item()
  305. {
  306. value =Convert.ToInt32(dt.Rows[k]["ar"]).ToString(),
  307. name = name
  308. };
  309. listData.Add(item);
  310. }
  311. chart.ListData = listData;
  312. return chart;
  313. }
  314. private Chartdate GetInclusionAreaRatioClassData(string path)
  315. {
  316. //创建新的图形数据源
  317. Chartdate chart = new Chartdate();
  318. chart.Title = m_ReportApp.m_reportname;
  319. chart.YName = m_str_AxisY;
  320. //计算分类整个表的数据
  321. DataTable dt= ClassificationIntegration(path);
  322. List<string> listName = new List<string>();
  323. //ListName
  324. for (int i = 0; i < dt.Rows.Count; i++)
  325. {
  326. listName.Add(dt.Rows[i]["e1"].ToString());
  327. }
  328. chart.ListName = listName;
  329. //DataTable dt
  330. //设置数据
  331. List<Item> listData = new List<Item>();
  332. //ListData
  333. for (int k = 0; k < dt.Rows.Count; k++)
  334. {
  335. string str = dt.Rows[k]["Cunt"].ToString();
  336. string name = dt.Rows[k]["e1"].ToString();
  337. Item item = new Item()
  338. {
  339. value = decimal.Round(decimal.Parse(dt.Rows[k]["Cunt"].ToString()), 2).ToString(),
  340. name = name
  341. };
  342. listData.Add(item);
  343. }
  344. chart.ListData = listData;
  345. return chart;
  346. }
  347. private DataTable ClassificationIntegration(string path )
  348. {
  349. //------------------加载模块,获取数据-------------------------------------------------
  350. ResultGrid ls_resultgrid = new ResultGrid(m_ReportApp);
  351. Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid_Report();
  352. //------------------加载模块,获取数据结束----------------------------------------------
  353. Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
  354. string str_SCZS = "";
  355. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
  356. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  357. DataTable data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
  358. DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
  359. DataTable AllAnalysisDetails = new DataTable();
  360. AllAnalysisDetails.Columns.Add("Name");
  361. AllAnalysisDetails.Columns.Add("TypeId");
  362. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  363. AllAnalysisDetails.Columns.Add("Class");
  364. AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
  365. for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
  366. {
  367. DataRow dr2 = AllAnalysisDetails.NewRow();
  368. dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
  369. dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
  370. dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
  371. dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
  372. dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
  373. AllAnalysisDetails.Rows.Add(dr2);
  374. }
  375. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  376. List<string> ClassName = new List<string>();
  377. DataTable getClass_dt = particledata.GetAllClass();
  378. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  379. {
  380. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  381. }
  382. DataTable AreaRatio = new DataTable();
  383. AreaRatio.TableName = "InclusionAreaRatio";
  384. AreaRatio.Columns.Add("e1");
  385. AreaRatio.Columns.Add("e2");
  386. AreaRatio.Columns.Add("e3", typeof(double));
  387. AreaRatio.Columns.Add("e4");
  388. AreaRatio.Columns.Add("e5");
  389. AreaRatio.Columns.Add("Cunt", typeof(int));
  390. //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
  391. double totalInclusionArea = 0;
  392. totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
  393. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  394. {
  395. DataRow dr2 = AreaRatio.NewRow();
  396. dr2["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
  397. dr2["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
  398. dr2["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
  399. dr2["e4"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
  400. dr2["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  401. dr2["Cunt"]= AllAnalysisDetails.Rows[i]["Cunt"].ToString();
  402. AreaRatio.Rows.Add(dr2);
  403. }
  404. DataTable AreaRatio_dt = AreaRatio.Copy();
  405. AreaRatio_dt.Clear();
  406. for (int i = 0; i < ClassName.Count(); i++)
  407. {
  408. DataTable dt = AreaRatio.Copy();
  409. dt.Clear();
  410. for (int a = 0; a < AreaRatio.Rows.Count; a++)
  411. {
  412. if (AreaRatio.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  413. {
  414. dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
  415. }
  416. }
  417. DataView dv = dt.DefaultView;
  418. dv.Sort = "e3 DESC";
  419. DataTable dt_Element = dv.ToTable();
  420. for (int a = 0; a < dt_Element.Rows.Count; a++)
  421. {
  422. AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  423. }
  424. }
  425. DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
  426. AllAnalysisDetails1.Clear();
  427. for (int i = 0; i < ClassName.Count; i++)
  428. {
  429. DataTable dt = AreaRatio_dt.Copy();
  430. dt.Clear();
  431. for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
  432. {
  433. if (AreaRatio_dt.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  434. {
  435. dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
  436. }
  437. }
  438. if (dt.Rows.Count > 0)
  439. {
  440. double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(e3)", "").ToString()));
  441. double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  442. int cunt= Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
  443. DataRow dr3 = AllAnalysisDetails1.NewRow();
  444. dr3["e1"] = ClassName[i].ToString();
  445. dr3["e3"] = Math.Round(Area, 2);
  446. //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  447. dr3["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea2) * 100, 2);
  448. dr3["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  449. dr3["Cunt"] = cunt;
  450. AllAnalysisDetails1.Rows.Add(dr3);
  451. }
  452. }
  453. return AllAnalysisDetails1;
  454. }
  455. private DataTable ConSolidateInvalid(DataTable dt)
  456. {
  457. DataTable dt_invalid = dt.Clone();
  458. DataTable dt_no_invalid = dt.Clone();
  459. for (int i = 0; i < dt.Rows.Count; i++)
  460. {
  461. if (dt.Rows[i]["TypeName"].ToString()=="Invalid")
  462. {
  463. dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
  464. }
  465. else
  466. {
  467. dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
  468. }
  469. }
  470. return dt_no_invalid;
  471. }
  472. /// <summary>
  473. /// 获取颗粒成分数据
  474. /// </summary>
  475. private Chartdate GetPComponentData(string path)
  476. {
  477. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  478. //创建新的图形数据源
  479. Chartdate chart = new Chartdate();
  480. chart.Title = m_ReportApp.m_reportname;
  481. chart.YName = m_str_AxisY;
  482. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  483. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  484. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  485. int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  486. string filedAndParticl = "";
  487. if (sel == 1)
  488. {
  489. List<OTSIncAReportApp.DataOperation.Model.Particle> selectParticles = m_ReportApp.GetSelectedParticles();
  490. foreach (var item in selectParticles)
  491. {
  492. filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
  493. }
  494. if (filedAndParticl != "")
  495. {
  496. filedAndParticl = filedAndParticl + ",";
  497. }
  498. }
  499. DataTable dt = particledata.GetParticleListForParticlSize("area", filedAndParticl);
  500. //设置标签名称
  501. List<string> listName = new List<string>();
  502. //ListName
  503. for (int i = 0; i < dt.Rows.Count; i++)
  504. {
  505. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
  506. {
  507. continue;
  508. }
  509. listName.Add(dt.Rows[i]["TypeName"].ToString());
  510. }
  511. for (int i = 0; i < dt.Rows.Count; i++)
  512. {
  513. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
  514. {
  515. continue;
  516. }
  517. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
  518. if (index == -1)
  519. {
  520. index = 7;
  521. }
  522. string name = NameList[index];
  523. if (listName.IndexOf(name) == -1)
  524. {
  525. listName.Add(name);
  526. }
  527. }
  528. chart.ListName = listName;
  529. //设置数据
  530. List<Item> listData = new List<Item>();
  531. //ListData
  532. for (int k = 0; k < dt.Rows.Count; k++)
  533. {
  534. string str = dt.Rows[k]["con"].ToString();
  535. string name = dt.Rows[k]["TypeName"].ToString();
  536. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  537. {
  538. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
  539. if (index == -1)
  540. {
  541. index = 7;
  542. }
  543. name = NameList[index];
  544. }
  545. Item item = new Item()
  546. {
  547. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  548. name = name
  549. };
  550. listData.Add(item);
  551. }
  552. chart.ListData = listData;
  553. return chart;
  554. }
  555. /// <summary>
  556. /// 获取元素成分数据
  557. /// </summary>
  558. private Chartdate GetEComponentData(string path)
  559. {
  560. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  561. //创建新的图形数据源
  562. Chartdate chart = new Chartdate();
  563. chart.Title = m_ReportApp.m_reportname;
  564. chart.YName = m_str_AxisY;
  565. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  566. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  567. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  568. int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  569. string filedAndParticl = "";
  570. if (sel == 1)
  571. {
  572. List<OTSIncAReportApp.DataOperation.Model.Particle> selectParticles = m_ReportApp.GetSelectedParticles();
  573. foreach (var item in selectParticles)
  574. {
  575. filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
  576. }
  577. if (filedAndParticl != "")
  578. {
  579. filedAndParticl = filedAndParticl + ",";
  580. }
  581. }
  582. DataTable dt = particledata.GetElementForArea(filedAndParticl);
  583. //设置标签名称
  584. List<string> listName = new List<string>();
  585. //ListName
  586. for (int i = 0; i < dt.Rows.Count; i++)
  587. {
  588. listName.Add(dt.Rows[i]["name"].ToString());
  589. }
  590. chart.ListName = listName;
  591. //设置数据
  592. List<Item> listData = new List<Item>();
  593. //ListData
  594. for (int k = 0; k < dt.Rows.Count; k++)
  595. {
  596. string str = dt.Rows[k]["earea"].ToString();
  597. try
  598. {
  599. Item item = new Item()
  600. {
  601. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  602. name = dt.Rows[k]["name"].ToString()
  603. };
  604. listData.Add(item);
  605. }
  606. catch
  607. {
  608. Item item = new Item()
  609. {
  610. value = str,
  611. name = dt.Rows[k]["name"].ToString()
  612. };
  613. listData.Add(item);
  614. }
  615. }
  616. chart.ListData = listData;
  617. return chart;
  618. }
  619. /// <summary>
  620. /// 获取此尺寸分布图数据
  621. /// </summary>
  622. private Chartdate GetPSizeData(string path)
  623. {
  624. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  625. //创建新的图形数据源
  626. Chartdate chart = new Chartdate();
  627. chart.Title = m_ReportApp.m_reportname;
  628. chart.YName = m_str_AxisY;
  629. //设置标签名称
  630. List<string> listName = new List<string>();
  631. //获取粒级表
  632. string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  633. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  634. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  635. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  636. {
  637. if (sizestr.Split(',')[i].Length > 0)
  638. {
  639. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  640. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  641. listName.Add(d1.ToString() + "~" + d2.ToString());
  642. }
  643. }
  644. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  645. listName.Add(d.ToString() + "~MAX");
  646. chart.ListName = listName;
  647. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  648. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  649. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  650. int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  651. string filedAndParticl = "";
  652. if (sel == 1)
  653. {
  654. List<OTSIncAReportApp.DataOperation.Model.Particle> selectParticles = m_ReportApp.GetSelectedParticles();
  655. foreach (var item in selectParticles)
  656. {
  657. filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
  658. }
  659. if (filedAndParticl != "")
  660. {
  661. filedAndParticl = filedAndParticl + ",";
  662. }
  663. }
  664. //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
  665. //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  666. string con = m_conditionChoose.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  667. string po = "";
  668. switch (con)
  669. {
  670. case "DMAX":
  671. po = "DMAX";
  672. break;
  673. case "DMIN":
  674. po = "DMIN";
  675. break;
  676. case "CIRCLE":
  677. po = "Area";
  678. break;
  679. case "FERET":
  680. po = "DFERET";
  681. break;
  682. }
  683. DataTable dtp = particledata.GetParticleAll(filedAndParticl);
  684. //设置数据
  685. List<Item> listData = new List<Item>();
  686. //ListData
  687. for (int k = 0; k < listName.Count; k++)
  688. {
  689. string str = listName[k];
  690. string d1 = str.Split('~')[0];
  691. string d2 = str.Split('~')[1];
  692. if (d2 == "MAX")
  693. {
  694. d2 = "999";
  695. }
  696. DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
  697. Item item = new Item()
  698. {
  699. value = datas.Count().ToString(),
  700. name = str
  701. };
  702. listData.Add(item);
  703. }
  704. chart.ListData = listData;
  705. return chart;
  706. }
  707. private string getWhere(string max, string min, string col)
  708. {
  709. return col + ">=" + min + " and " + col + "<=" + max;
  710. }
  711. #endregion
  712. #region echarts
  713. /// <summary>
  714. /// 通过m_list_chartstruct,组合json数据格式
  715. /// </summary>
  716. /// <returns></returns>
  717. private List<Chartdate> GetListJsonStrByChartStruct()
  718. {
  719. List<Chartdate> list = new List<Chartdate>();
  720. Chartdate chartdate = new Chartdate();
  721. switch (ComSel)
  722. {
  723. case "CommonlyUsedClassify":
  724. //chartdate = GetCommonlyUsedClassifyData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  725. chartdate = GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  726. break;
  727. case "PComponent":
  728. chartdate = GetPComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  729. break;
  730. case "EComponent":
  731. chartdate = GetEComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  732. break;
  733. case "PSize":
  734. chartdate = GetPSizeData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  735. break;
  736. case "InclusionareaRatio":
  737. chartdate = GetInclusionAreaRatioData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  738. break;
  739. case "InclusionareaClassRatio":
  740. chartdate=GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  741. break;
  742. }
  743. list.Add(chartdate);
  744. return list;
  745. }
  746. /// <summary>
  747. /// 通过m_list_chartstruct,组合json数据格式
  748. /// </summary>
  749. /// <returns></returns>
  750. private ChartdateMore GetListJsonStr()
  751. {
  752. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  753. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  754. int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  755. string filedAndParticl = "";
  756. if (sel == 1)
  757. {
  758. List<OTSIncAReportApp.DataOperation.Model.Particle> selectParticles = m_ReportApp.GetSelectedParticles();
  759. foreach (var item in selectParticles)
  760. {
  761. filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
  762. }
  763. if (filedAndParticl != "")
  764. {
  765. filedAndParticl = filedAndParticl + ",";
  766. }
  767. }
  768. DataOperation.DataAccess.ParticleData particledata = null;
  769. DataTable dt = new DataTable();
  770. ChartdateMore chart = new ChartdateMore();
  771. chart.Title = m_ReportApp.m_reportname;
  772. chart.YName = m_str_AxisY;
  773. List<string> listName = new List<string>();
  774. List<string> soursName = new List<string>();
  775. List<List<Item>> listDataMore = new List<List<Item>>();
  776. //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  777. //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  778. string sou = m_conditionChoose.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  779. if (sou.Contains("+"))
  780. {
  781. for (int i = 0; i < sou.Split('+').Length; i++)
  782. {
  783. DataOperation.Model.ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.FileName == sou.Split('+')[i]);
  784. if (resultFile == null)
  785. {
  786. continue;
  787. }
  788. soursName.Add(resultFile.FileName);
  789. particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
  790. switch (ComSel)
  791. {
  792. case "InclusionareaRatio":
  793. dt = particledata.GetAreaByAllIncA("");
  794. //设置标签名称
  795. for (int a = 0; a < dt.Rows.Count; a++)
  796. {
  797. if (Convert.ToInt32(dt.Rows[a]["TypeId"]) < 100)
  798. {
  799. continue;
  800. }
  801. listName.Add(dt.Rows[a]["TypeName"].ToString());
  802. }
  803. //设置数据
  804. List<Item> listData3 = new List<Item>();
  805. for (int k = 0; k < dt.Rows.Count; k++)
  806. {
  807. string str = dt.Rows[k]["ar"].ToString();
  808. string name = dt.Rows[k]["TypeName"].ToString();
  809. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  810. {
  811. continue;
  812. }
  813. Item item = new Item()
  814. {
  815. value = decimal.Round(decimal.Parse(dt.Rows[k]["ar"].ToString()), 2).ToString(),
  816. name = name
  817. };
  818. listData3.Add(item);
  819. }
  820. listDataMore.Add(listData3);
  821. break;
  822. case "CommonlyUsedClassify":
  823. //计算分类整个表的数据
  824. dt = ClassificationIntegration(resultFile.FilePath);
  825. ////List<string> listName = new List<string>();
  826. ////ListName
  827. for (int a = 0; a < dt.Rows.Count; a++)
  828. {
  829. listName.Add(dt.Rows[a]["e1"].ToString());
  830. }
  831. //chart.ListName = listName;
  832. ////DataTable dt
  833. //设置数据
  834. List<Item> listData2 = new List<Item>();
  835. ////ListData
  836. for (int k = 0; k < dt.Rows.Count; k++)
  837. {
  838. string str = dt.Rows[k]["Cunt"].ToString();
  839. string name = dt.Rows[k]["e1"].ToString();
  840. Item item = new Item()
  841. {
  842. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  843. name = name
  844. };
  845. listData2.Add(item);
  846. //listData2.Add(item);
  847. }
  848. listDataMore.Add(listData2);
  849. break;
  850. case "PComponent":
  851. //创建新的图形数据源
  852. dt = particledata.GetParticleListByIncA("area");
  853. //设置标签名称
  854. for (int j = 0; j < dt.Rows.Count; j++)
  855. {
  856. if (Convert.ToInt32(dt.Rows[j]["TypeId"]) < 100)
  857. {
  858. continue;
  859. }
  860. string name = dt.Rows[j]["TypeName"].ToString();
  861. if (!listName.Contains(name))
  862. {
  863. listName.Add(name);
  864. }
  865. }
  866. for (int j = 0; j < dt.Rows.Count; j++)
  867. {
  868. if (Convert.ToInt32(dt.Rows[j]["TypeId"]) > 100)
  869. {
  870. continue;
  871. }
  872. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[j]["TypeId"]));
  873. if (index == -1)
  874. {
  875. index = 7;
  876. }
  877. string name = NameList[index];
  878. if (!listName.Contains(name))
  879. {
  880. listName.Add(name);
  881. }
  882. }
  883. //设置数据
  884. List<Item> listData = new List<Item>();
  885. //ListData
  886. for (int k = 0; k < dt.Rows.Count; k++)
  887. {
  888. string str = dt.Rows[k]["con"].ToString();
  889. string name = dt.Rows[k]["TypeName"].ToString();
  890. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  891. {
  892. if (Convert.ToInt32(dt.Rows[k]["TypeId"])==-1)
  893. {
  894. name = NameList[7];
  895. }
  896. else
  897. {
  898. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
  899. name = NameList[index];
  900. }
  901. }
  902. Item item = new Item()
  903. {
  904. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  905. name = name
  906. };
  907. listData.Add(item);
  908. }
  909. listDataMore.Add(listData);
  910. break;
  911. case "EComponent":
  912. //创建新的图形数据源
  913. dt = particledata.GetElementForArea(filedAndParticl);
  914. //ListName
  915. for (int j = 0; j < dt.Rows.Count; j++)
  916. {
  917. string name = dt.Rows[j]["name"].ToString();
  918. if (!listName.Contains(name))
  919. {
  920. listName.Add(name);
  921. }
  922. }
  923. //设置数据
  924. List<Item> listData1 = new List<Item>();
  925. //ListData
  926. for (int k = 0; k < dt.Rows.Count; k++)
  927. {
  928. string str = dt.Rows[k]["earea"].ToString();
  929. try
  930. {
  931. Item item = new Item()
  932. {
  933. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  934. name = dt.Rows[k]["name"].ToString()
  935. };
  936. listData1.Add(item);
  937. }
  938. catch
  939. {
  940. Item item = new Item()
  941. {
  942. value = str,
  943. name = dt.Rows[k]["name"].ToString()
  944. };
  945. listData1.Add(item);
  946. }
  947. }
  948. listDataMore.Add(listData1);
  949. break;
  950. case "PSize":
  951. //获取粒级表
  952. string pathe = m_DataMgr.m_RptConfigFile.PartSizeFileFolder + m_DataMgr.m_RptConfigFile.PartSizeFile;
  953. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  954. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  955. List<string> temp = new List<string>();
  956. for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
  957. {
  958. if (sizestr.Split(',')[j].Length > 0)
  959. {
  960. double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
  961. double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
  962. string name = d1.ToString() + "~" + d2.ToString();
  963. temp.Add(name);
  964. if (!listName.Contains(name))
  965. {
  966. listName.Add(name);
  967. }
  968. }
  969. }
  970. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  971. string name1 = d.ToString() + "~MAX";
  972. temp.Add(name1);
  973. if (!listName.Contains(name1))
  974. {
  975. listName.Add(name1);
  976. }
  977. //string con = m_ReportApp.SourceGridData.ConditionItemList[m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE)].itemVal.ToString();
  978. string con = m_conditionChoose.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  979. string po = "";
  980. switch (con)
  981. {
  982. case "DMAX":
  983. po = "DMAX";
  984. break;
  985. case "DMIN":
  986. po = "DMIN";
  987. break;
  988. case "CIRCLE":
  989. po = "Area";
  990. break;
  991. case "FERET":
  992. po = "DFERET";
  993. break;
  994. }
  995. DataTable dtp = particledata.GetParticleAll(filedAndParticl);
  996. //设置数据
  997. List<Item> listData4 = new List<Item>();
  998. //ListData
  999. for (int k = 0; k < temp.Count; k++)
  1000. {
  1001. string str = temp[k];
  1002. string d1 = str.Split('~')[0];
  1003. string d2 = str.Split('~')[1];
  1004. if (d2 == "MAX")
  1005. {
  1006. d2 = "999";
  1007. }
  1008. DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
  1009. Item item = new Item()
  1010. {
  1011. value = datas.Count().ToString(),
  1012. name = str
  1013. };
  1014. listData4.Add(item);
  1015. }
  1016. listDataMore.Add(listData4);
  1017. break;
  1018. }
  1019. }
  1020. }
  1021. chart.ListName = listName;
  1022. chart.SoursName = soursName;
  1023. chart.ListData = listDataMore;
  1024. return chart;
  1025. }
  1026. class Chartdate
  1027. {
  1028. public string Title { get; set; }
  1029. public string YName { get; set; }
  1030. public List<string> ListName { get; set; }
  1031. public List<Item> ListData { get; set; }
  1032. }
  1033. class ChartdateMore
  1034. {
  1035. public string Title { get; set; }
  1036. public string YName { get; set; }
  1037. public List<string> ListName { get; set; }
  1038. public List<string> SoursName { get; set; }
  1039. public List<List<Item>> ListData { get; set; }
  1040. }
  1041. class Item
  1042. {
  1043. public string value { get; set; }
  1044. public string name { get; set; }
  1045. }
  1046. //获取图片
  1047. private void button1_Click(object sender, EventArgs e)
  1048. {
  1049. //string str = GetPic();
  1050. //pic = str;
  1051. ////保存目录
  1052. //string dir = Path.Combine(Directory.GetCurrentDirectory(), "Resources/HTML/pic");
  1053. ////文件名称
  1054. //string fileName = "headdemo" + DateTime.Now.ToString("yyyyMMddHHmmssff");
  1055. ////保存文件所在站点位置
  1056. //string filePath = Path.Combine(dir, fileName);
  1057. //if (!System.IO.Directory.Exists(dir))
  1058. // System.IO.Directory.CreateDirectory(dir);
  1059. ////将Base64String转为图片并保存
  1060. //byte[] arr2 = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
  1061. //using (MemoryStream ms2 = new MemoryStream(arr2))
  1062. //{
  1063. // System.Drawing.Bitmap bmp2 = new System.Drawing.Bitmap(ms2);
  1064. // bmp2.Save(filePath + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
  1065. //}
  1066. }
  1067. /// <summary>
  1068. /// 加载浏览器
  1069. /// </summary>
  1070. public void InitBrowser()
  1071. {
  1072. //加载网页
  1073. if (m_ReportApp.browser == null || m_ReportApp.trans)
  1074. {
  1075. // 获取生成路径下网页文件的绝对路径
  1076. string fileName = Path.Combine(Directory.GetCurrentDirectory(), url);
  1077. //加载网页
  1078. m_ReportApp.browser = new ChromiumWebBrowser(fileName);
  1079. //禁止网页
  1080. m_ReportApp.browser.MenuHandler = new MenuHandler();
  1081. m_ReportApp.browser.Dock = DockStyle.Fill;
  1082. m_ReportApp.js.MessageText = "";
  1083. //添加网页到当前自定义控件
  1084. this.Controls.Add(m_ReportApp.browser);
  1085. //供页面调用以传递数据
  1086. m_ReportApp.browser.RegisterJsObject("jsObj", m_ReportApp.js, false);
  1087. //升级cef版本后新方法
  1088. //CefSharpSettings.LegacyJavascriptBindingEnabled = true;
  1089. //CefSharpSettings.WcfEnabled = true;
  1090. //m_ReportApp.browser.JavascriptObjectRepository.Register("jsObj", m_ReportApp.js, isAsync: false, options: BindingOptions.DefaultBinder);
  1091. //网页加载结束后调用事件
  1092. m_ReportApp.browser.FrameLoadEnd += WebBrowser_FrameLoadEnd;
  1093. }
  1094. else
  1095. {
  1096. m_ReportApp.browser.ResetText();
  1097. m_ReportApp.browser.Reload();
  1098. m_ReportApp.browser.Refresh();
  1099. //供页面调用以传递数据
  1100. this.Controls.Add(m_ReportApp.browser);
  1101. }
  1102. if (m_ReportApp.timerKG)
  1103. {
  1104. timer1.Enabled = true;
  1105. }
  1106. }
  1107. /// <summary>
  1108. /// 页面加载结束后事件
  1109. /// </summary>
  1110. /// <param name="sender"></param>
  1111. /// <param name="e"></param>
  1112. private void WebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
  1113. {
  1114. if (e.Frame.IsMain)
  1115. {
  1116. //为页面图形提供数据参数
  1117. string str = m_ReportApp.data;
  1118. //执行网页脚本事件
  1119. m_ReportApp.browser.ExecuteScriptAsync("showchart('" + str + "','" + m_ReportApp.type + "')");
  1120. }
  1121. }
  1122. //public string GetPic()
  1123. //{
  1124. // return js.MessageText;
  1125. //}
  1126. //禁止网页操作,右键点击等
  1127. class MenuHandler : CefSharp.IContextMenuHandler
  1128. {
  1129. void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model)
  1130. {
  1131. model.Clear();
  1132. }
  1133. bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
  1134. {
  1135. //throw new NotImplementedException();
  1136. return false;
  1137. }
  1138. void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame)
  1139. {
  1140. //throw new NotImplementedException();
  1141. }
  1142. bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback)
  1143. {
  1144. return false;
  1145. }
  1146. }
  1147. class JsEvent
  1148. {
  1149. public string MessageText { set; get; }
  1150. public void ShowTest()
  1151. {
  1152. MessageBox.Show(MessageText);
  1153. }
  1154. }
  1155. #endregion
  1156. #region EChart导出图像委托调用部份
  1157. public delegate void MyDelgate(string va);
  1158. public event MyDelgate butclic;
  1159. private void timer1_Tick(object sender, EventArgs e)
  1160. {
  1161. if (butclic == null)
  1162. return;
  1163. if (m_ReportApp.js == null)
  1164. return;
  1165. if (m_ReportApp.js.MessageText == null)
  1166. return;
  1167. if (m_ReportApp.js.MessageText != "")
  1168. {
  1169. butclic(m_ReportApp.js.MessageText);
  1170. timer1.Enabled = false;
  1171. m_ReportApp.timerKG = false;
  1172. }
  1173. }
  1174. #endregion
  1175. }
  1176. }