EChart_ParticlesComposition.cs 58 KB

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