EChart_ParticlesComposition.cs 55 KB

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