EChart_ParticlesComposition.cs 58 KB

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