EChart_ParticlesComposition.cs 58 KB

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