EChart_ParticlesComposition.cs 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  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. DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
  299. DataTable AllAnalysisDetails = new DataTable();
  300. AllAnalysisDetails.Columns.Add("Name");
  301. AllAnalysisDetails.Columns.Add("TypeId");
  302. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  303. AllAnalysisDetails.Columns.Add("Class");
  304. AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
  305. for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
  306. {
  307. DataRow dr2 = AllAnalysisDetails.NewRow();
  308. dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
  309. dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
  310. dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
  311. dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
  312. dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
  313. AllAnalysisDetails.Rows.Add(dr2);
  314. }
  315. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  316. List<string> ClassName = new List<string>();
  317. DataTable getClass_dt = particledata.GetAllClass();
  318. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  319. {
  320. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  321. }
  322. DataTable AreaRatio = new DataTable();
  323. AreaRatio.TableName = "InclusionAreaRatio";
  324. AreaRatio.Columns.Add("e1");
  325. AreaRatio.Columns.Add("e2");
  326. AreaRatio.Columns.Add("e3", typeof(double));
  327. AreaRatio.Columns.Add("e4");
  328. AreaRatio.Columns.Add("e5");
  329. AreaRatio.Columns.Add("Cunt", typeof(int));
  330. //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
  331. double totalInclusionArea = 0;
  332. totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
  333. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  334. {
  335. DataRow dr2 = AreaRatio.NewRow();
  336. dr2["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
  337. dr2["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
  338. dr2["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
  339. dr2["e4"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
  340. dr2["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  341. dr2["Cunt"]= AllAnalysisDetails.Rows[i]["Cunt"].ToString();
  342. AreaRatio.Rows.Add(dr2);
  343. }
  344. DataTable AreaRatio_dt = AreaRatio.Copy();
  345. AreaRatio_dt.Clear();
  346. for (int i = 0; i < ClassName.Count(); i++)
  347. {
  348. DataTable dt = AreaRatio.Copy();
  349. dt.Clear();
  350. for (int a = 0; a < AreaRatio.Rows.Count; a++)
  351. {
  352. if (AreaRatio.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  353. {
  354. dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
  355. }
  356. }
  357. DataView dv = dt.DefaultView;
  358. dv.Sort = "e3 DESC";
  359. DataTable dt_Element = dv.ToTable();
  360. for (int a = 0; a < dt_Element.Rows.Count; a++)
  361. {
  362. AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  363. }
  364. }
  365. DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
  366. AllAnalysisDetails1.Clear();
  367. for (int i = 0; i < ClassName.Count; i++)
  368. {
  369. DataTable dt = AreaRatio_dt.Copy();
  370. dt.Clear();
  371. for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
  372. {
  373. if (AreaRatio_dt.Rows[a]["e1"].ToString() == ClassName[i].ToString())
  374. {
  375. dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
  376. }
  377. }
  378. if (dt.Rows.Count > 0)
  379. {
  380. double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(e3)", "").ToString()));
  381. double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  382. int cunt= Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
  383. DataRow dr3 = AllAnalysisDetails1.NewRow();
  384. dr3["e1"] = ClassName[i].ToString();
  385. dr3["e3"] = Math.Round(Area, 2);
  386. //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  387. dr3["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea2) * 100, 2);
  388. dr3["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
  389. dr3["Cunt"] = cunt;
  390. AllAnalysisDetails1.Rows.Add(dr3);
  391. }
  392. }
  393. return AllAnalysisDetails1;
  394. }
  395. private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
  396. {
  397. DataTable dt_Partick = new DataTable();
  398. dt_Partick.Columns.Add("TypeId");
  399. dt_Partick.Columns.Add("TypeName");
  400. dt_Partick.Columns.Add("TypeColor");
  401. dt_Partick.Columns.Add("con");
  402. dt_Partick.Columns.Add("av");
  403. dt_Partick.Columns.Add("max");
  404. dt_Partick.Columns.Add("ar", typeof(double));
  405. dt_Partick.Columns.Add("GroupName");
  406. List<string> typeName = new List<string>();
  407. for (int i = 0; i < data.Rows.Count; i++)
  408. {
  409. typeName.Add(data.Rows[i]["TypeId"].ToString());
  410. }
  411. typeName = typeName.Distinct().ToList();
  412. for (int i = 0; i < typeName.Count; i++)
  413. {
  414. DataTable dt = dt_Partick.Clone();
  415. for (int j = 0; j < data.Rows.Count; j++)
  416. {
  417. if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
  418. {
  419. DataRow row = dt.NewRow();
  420. row["TypeId"] = data.Rows[j]["TypeId"];
  421. row["TypeName"] = data.Rows[j]["TypeName"];
  422. row["TypeColor"] = data.Rows[j]["TypeColor"];
  423. row["ar"] = data.Rows[j]["Area"];
  424. dt.Rows.Add(row);
  425. }
  426. }
  427. DataRow dr = dt_Partick.NewRow();
  428. dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
  429. dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
  430. dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
  431. dr["con"] = dt.Rows.Count;
  432. dr["av"] = dt.Compute("min(ar)", "");
  433. dr["max"] = dt.Compute("Max(ar)", "");
  434. dr["ar"] = dt.Compute("SUM(ar)", "");
  435. dt_Partick.Rows.Add(dr);
  436. }
  437. for (int i = 0; i < dt_Partick.Rows.Count; i++)
  438. {
  439. for (int j = 0; j < table.Rows.Count; j++)
  440. {
  441. if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
  442. {
  443. dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
  444. break;
  445. }
  446. }
  447. }
  448. return dt_Partick;
  449. }
  450. private DataTable ConSolidateInvalid(DataTable dt)
  451. {
  452. DataTable dt_invalid = dt.Clone();
  453. DataTable dt_no_invalid = dt.Clone();
  454. for (int i = 0; i < dt.Rows.Count; i++)
  455. {
  456. if (dt.Rows[i]["TypeName"].ToString()=="Invalid")
  457. {
  458. dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
  459. }
  460. else
  461. {
  462. dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
  463. }
  464. }
  465. return dt_no_invalid;
  466. }
  467. /// <summary>
  468. /// 获取颗粒成分数据
  469. /// </summary>
  470. private Chartdate GetPComponentData(string path)
  471. {
  472. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  473. //创建新的图形数据源
  474. Chartdate chart = new Chartdate();
  475. chart.Title = m_ReportApp.m_reportname;
  476. chart.YName = m_str_AxisY;
  477. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  478. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  479. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  480. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  481. string filedAndParticl = "";
  482. DataTable dt = particledata.GetParticleListForParticlSize("area", filedAndParticl);
  483. //设置标签名称
  484. List<string> listName = new List<string>();
  485. //ListName
  486. for (int i = 0; i < dt.Rows.Count; i++)
  487. {
  488. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
  489. {
  490. continue;
  491. }
  492. listName.Add(dt.Rows[i]["TypeName"].ToString());
  493. }
  494. for (int i = 0; i < dt.Rows.Count; i++)
  495. {
  496. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
  497. {
  498. continue;
  499. }
  500. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
  501. if (index == -1)
  502. {
  503. index = 7;
  504. }
  505. string name = NameList[index];
  506. if (listName.IndexOf(name) == -1)
  507. {
  508. listName.Add(name);
  509. }
  510. }
  511. chart.ListName = listName;
  512. //设置数据
  513. List<Item> listData = new List<Item>();
  514. //ListData
  515. for (int k = 0; k < dt.Rows.Count; k++)
  516. {
  517. string str = dt.Rows[k]["con"].ToString();
  518. string name = dt.Rows[k]["TypeName"].ToString();
  519. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  520. {
  521. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
  522. if (index == -1)
  523. {
  524. index = 7;
  525. }
  526. name = NameList[index];
  527. }
  528. Item item = new Item()
  529. {
  530. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  531. name = name
  532. };
  533. listData.Add(item);
  534. }
  535. chart.ListData = listData;
  536. return chart;
  537. }
  538. /// <summary>
  539. /// 获取元素成分数据
  540. /// </summary>
  541. private Chartdate GetEComponentData(string path)
  542. {
  543. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  544. //创建新的图形数据源
  545. Chartdate chart = new Chartdate();
  546. chart.Title = m_ReportApp.m_reportname;
  547. chart.YName = m_str_AxisY;
  548. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  549. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  550. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  551. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  552. string filedAndParticl = "";
  553. DataTable dt = particledata.GetElementForArea(filedAndParticl);
  554. //设置标签名称
  555. List<string> listName = new List<string>();
  556. //ListName
  557. for (int i = 0; i < dt.Rows.Count; i++)
  558. {
  559. listName.Add(dt.Rows[i]["name"].ToString());
  560. }
  561. chart.ListName = listName;
  562. //设置数据
  563. List<Item> listData = new List<Item>();
  564. //ListData
  565. for (int k = 0; k < dt.Rows.Count; k++)
  566. {
  567. string str = dt.Rows[k]["earea"].ToString();
  568. try
  569. {
  570. Item item = new Item()
  571. {
  572. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  573. name = dt.Rows[k]["name"].ToString()
  574. };
  575. listData.Add(item);
  576. }
  577. catch
  578. {
  579. Item item = new Item()
  580. {
  581. value = str,
  582. name = dt.Rows[k]["name"].ToString()
  583. };
  584. listData.Add(item);
  585. }
  586. }
  587. chart.ListData = listData;
  588. return chart;
  589. }
  590. /// <summary>
  591. /// 获取此尺寸分布图数据
  592. /// </summary>
  593. private Chartdate GetPSizeData(string path)
  594. {
  595. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  596. //创建新的图形数据源
  597. Chartdate chart = new Chartdate();
  598. chart.Title = m_ReportApp.m_reportname;
  599. chart.YName = m_str_AxisY;
  600. //设置标签名称
  601. List<string> listName = new List<string>();
  602. //获取粒级表
  603. string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  604. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  605. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  606. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  607. {
  608. if (sizestr.Split(',')[i].Length > 0)
  609. {
  610. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  611. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  612. listName.Add(d1.ToString() + "~" + d2.ToString());
  613. }
  614. }
  615. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  616. listName.Add(d.ToString() + "~MAX");
  617. chart.ListName = listName;
  618. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  619. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  620. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  621. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  622. string filedAndParticl = "";
  623. //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
  624. //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  625. string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  626. string po = "";
  627. switch (con)
  628. {
  629. case "DMAX":
  630. po = "DMAX";
  631. break;
  632. case "DMIN":
  633. po = "DMIN";
  634. break;
  635. case "ECD":
  636. po = "Area";
  637. break;
  638. case "FERET":
  639. po = "DFERET";
  640. break;
  641. }
  642. DataTable dtp = particledata.GetParticleAll(filedAndParticl);
  643. //设置数据
  644. List<Item> listData = new List<Item>();
  645. //ListData
  646. for (int k = 0; k < listName.Count; k++)
  647. {
  648. string str = listName[k];
  649. string d1 = str.Split('~')[0];
  650. string d2 = str.Split('~')[1];
  651. if (d2 == "MAX")
  652. {
  653. d2 = "999";
  654. }
  655. DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
  656. Item item = new Item()
  657. {
  658. value = datas.Count().ToString(),
  659. name = str
  660. };
  661. listData.Add(item);
  662. }
  663. chart.ListData = listData;
  664. return chart;
  665. }
  666. private Chartdate GetPSizeDataCombin(string path)
  667. {
  668. DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
  669. //创建新的图形数据源
  670. Chartdate chart = new Chartdate();
  671. chart.Title = m_ReportApp.m_reportname;
  672. chart.YName = m_str_AxisY;
  673. //设置标签名称
  674. List<string> listName = new List<string>();
  675. //获取粒级表
  676. string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  677. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  678. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  679. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  680. {
  681. if (sizestr.Split(',')[i].Length > 0)
  682. {
  683. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  684. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  685. listName.Add(d1.ToString() + "~" + d2.ToString());
  686. }
  687. }
  688. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  689. listName.Add(d.ToString() + "~MAX");
  690. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  691. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  692. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  693. int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  694. string filedAndParticl = "";
  695. //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
  696. //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  697. string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  698. string po = "";
  699. switch (con)
  700. {
  701. case "DMAX":
  702. po = "DMAX";
  703. break;
  704. case "DMIN":
  705. po = "DMIN";
  706. break;
  707. case "ECD":
  708. po = "Area";
  709. break;
  710. case "FERET":
  711. po = "DFERET";
  712. break;
  713. }
  714. DataTable dtp = particledata.GetParticleAll(filedAndParticl);
  715. //计算分类整个表的数据
  716. DataTable dt = ClassificationIntegration(path, sel);
  717. List<string> listClassificationName = new List<string>();
  718. //ListName
  719. for (int i = 0; i < dt.Rows.Count; i++)
  720. {
  721. listClassificationName.Add(dt.Rows[i]["e1"].ToString());
  722. }
  723. chart.ListName = listClassificationName;
  724. //设置数据
  725. List<Item> listData = new List<Item>();
  726. //ListData
  727. string strNameGroup = "";
  728. for (int j = 0; j < listClassificationName.Count; j++)
  729. {
  730. string strGroup = "";
  731. for (int k = 0; k < listName.Count; k++)
  732. {
  733. string str = listName[k];
  734. string d1 = str.Split('~')[0];
  735. string d2 = str.Split('~')[1];
  736. if (d2 == "MAX")
  737. {
  738. d2 = "999";
  739. }
  740. DataRow[] datas = dtp.Select(getWhere(d2, d1, po) + " and GroupName = '" + listClassificationName[j] + "'");
  741. strGroup += datas.Count();
  742. if (k != listName.Count - 1)
  743. {
  744. strGroup += ",";
  745. }
  746. }
  747. Item item = new Item()
  748. {
  749. value = strGroup,
  750. name = listClassificationName[j]
  751. };
  752. listData.Add(item);
  753. strNameGroup += listClassificationName[j];
  754. if (j != listClassificationName.Count - 1)
  755. {
  756. strNameGroup += ",";
  757. }
  758. }
  759. chart.Title = "[" + strNameGroup + "]";
  760. chart.ListData = listData;
  761. return chart;
  762. }
  763. private string getWhere(string max, string min, string col)
  764. {
  765. return col + ">=" + min + " and " + col + "<" + max;
  766. }
  767. #endregion
  768. #region echarts
  769. /// <summary>
  770. /// 通过m_list_chartstruct,组合json数据格式
  771. /// </summary>
  772. /// <returns></returns>
  773. private List<Chartdate> GetListJsonStrByChartStruct(int sel)
  774. {
  775. List<Chartdate> list = new List<Chartdate>();
  776. Chartdate chartdate = new Chartdate();
  777. switch (ComSel)
  778. {
  779. case "CommonlyUsedClassify":
  780. //chartdate = GetCommonlyUsedClassifyData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
  781. chartdate = GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
  782. break;
  783. case "PComponent":
  784. chartdate = GetPComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
  785. break;
  786. case "EComponent":
  787. chartdate = GetEComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
  788. break;
  789. case "PSize":
  790. chartdate = GetPSizeData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
  791. break;
  792. case "PSizeCombin":
  793. chartdate = GetPSizeDataCombin(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
  794. break;
  795. case "InclusionareaRatio":
  796. chartdate = GetInclusionAreaRatioData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
  797. break;
  798. case "InclusionareaClassRatio":
  799. chartdate=GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
  800. break;
  801. }
  802. list.Add(chartdate);
  803. return list;
  804. }
  805. /// <summary>
  806. /// 通过m_list_chartstruct,组合json数据格式
  807. /// </summary>
  808. /// <returns></returns>
  809. private ChartdateMore GetListJsonStr()
  810. {
  811. //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  812. //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
  813. //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
  814. int sel = m_conditionChoose.m_conditionData.ProItemProIndex();
  815. string filedAndParticl = "";
  816. DataOperation.DataAccess.ParticleData particledata = null;
  817. DataTable dt = new DataTable();
  818. ChartdateMore chart = new ChartdateMore();
  819. chart.Title = m_ReportApp.m_reportname;
  820. chart.YName = m_str_AxisY;
  821. List<string> listName = new List<string>();
  822. List<string> soursName = new List<string>();
  823. List<List<Item>> listDataMore = new List<List<Item>>();
  824. //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  825. //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
  826. string sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
  827. if (sou.Contains("+"))
  828. {
  829. for (int i = 0; i < sou.Split('+').Length; i++)
  830. {
  831. ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
  832. if (resultFile == null)
  833. {
  834. continue;
  835. }
  836. soursName.Add(resultFile.anotherFileName);
  837. particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
  838. switch (ComSel)
  839. {
  840. case "InclusionareaRatio":
  841. dt = particledata.GetAreaByAllIncA("");
  842. //设置标签名称
  843. for (int a = 0; a < dt.Rows.Count; a++)
  844. {
  845. if (Convert.ToInt32(dt.Rows[a]["TypeId"]) < 100)
  846. {
  847. continue;
  848. }
  849. listName.Add(dt.Rows[a]["TypeName"].ToString());
  850. }
  851. //设置数据
  852. List<Item> listData3 = new List<Item>();
  853. for (int k = 0; k < dt.Rows.Count; k++)
  854. {
  855. string str = dt.Rows[k]["ar"].ToString();
  856. string name = dt.Rows[k]["TypeName"].ToString();
  857. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  858. {
  859. continue;
  860. }
  861. Item item = new Item()
  862. {
  863. value = decimal.Round(decimal.Parse(dt.Rows[k]["ar"].ToString()), 2).ToString(),
  864. name = name
  865. };
  866. listData3.Add(item);
  867. }
  868. listDataMore.Add(listData3);
  869. break;
  870. case "CommonlyUsedClassify":
  871. //计算分类整个表的数据
  872. dt = ClassificationIntegration(resultFile.FilePath,sel);
  873. ////List<string> listName = new List<string>();
  874. ////ListName
  875. for (int a = 0; a < dt.Rows.Count; a++)
  876. {
  877. listName.Add(dt.Rows[a]["e1"].ToString());
  878. }
  879. //chart.ListName = listName;
  880. ////DataTable dt
  881. //设置数据
  882. List<Item> listData2 = new List<Item>();
  883. ////ListData
  884. for (int k = 0; k < dt.Rows.Count; k++)
  885. {
  886. string str = dt.Rows[k]["Cunt"].ToString();
  887. string name = dt.Rows[k]["e1"].ToString();
  888. Item item = new Item()
  889. {
  890. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  891. name = name
  892. };
  893. listData2.Add(item);
  894. //listData2.Add(item);
  895. }
  896. listDataMore.Add(listData2);
  897. break;
  898. case "PComponent":
  899. //创建新的图形数据源
  900. dt = particledata.GetParticleListByIncA("area");
  901. //设置标签名称
  902. for (int j = 0; j < dt.Rows.Count; j++)
  903. {
  904. if (Convert.ToInt32(dt.Rows[j]["TypeId"]) < 100)
  905. {
  906. continue;
  907. }
  908. string name = dt.Rows[j]["TypeName"].ToString();
  909. if (!listName.Contains(name))
  910. {
  911. listName.Add(name);
  912. }
  913. }
  914. for (int j = 0; j < dt.Rows.Count; j++)
  915. {
  916. if (Convert.ToInt32(dt.Rows[j]["TypeId"]) > 100)
  917. {
  918. continue;
  919. }
  920. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[j]["TypeId"]));
  921. if (index == -1)
  922. {
  923. index = 7;
  924. }
  925. string name = NameList[index];
  926. if (!listName.Contains(name))
  927. {
  928. listName.Add(name);
  929. }
  930. }
  931. //设置数据
  932. List<Item> listData = new List<Item>();
  933. //ListData
  934. for (int k = 0; k < dt.Rows.Count; k++)
  935. {
  936. string str = dt.Rows[k]["con"].ToString();
  937. string name = dt.Rows[k]["TypeName"].ToString();
  938. if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
  939. {
  940. if (Convert.ToInt32(dt.Rows[k]["TypeId"])==-1)
  941. {
  942. name = NameList[7];
  943. }
  944. else
  945. {
  946. int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
  947. name = NameList[index];
  948. }
  949. }
  950. Item item = new Item()
  951. {
  952. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  953. name = name
  954. };
  955. listData.Add(item);
  956. }
  957. listDataMore.Add(listData);
  958. break;
  959. case "EComponent":
  960. //创建新的图形数据源
  961. dt = particledata.GetElementForArea(filedAndParticl);
  962. //ListName
  963. for (int j = 0; j < dt.Rows.Count; j++)
  964. {
  965. string name = dt.Rows[j]["name"].ToString();
  966. if (!listName.Contains(name))
  967. {
  968. listName.Add(name);
  969. }
  970. }
  971. //设置数据
  972. List<Item> listData1 = new List<Item>();
  973. //ListData
  974. for (int k = 0; k < dt.Rows.Count; k++)
  975. {
  976. string str = dt.Rows[k]["earea"].ToString();
  977. try
  978. {
  979. Item item = new Item()
  980. {
  981. value = decimal.Round(decimal.Parse(str), 2).ToString(),
  982. name = dt.Rows[k]["name"].ToString()
  983. };
  984. listData1.Add(item);
  985. }
  986. catch
  987. {
  988. Item item = new Item()
  989. {
  990. value = str,
  991. name = dt.Rows[k]["name"].ToString()
  992. };
  993. listData1.Add(item);
  994. }
  995. }
  996. listDataMore.Add(listData1);
  997. break;
  998. case "PSize":
  999. //获取粒级表
  1000. string pathe = m_DataMgr.m_RptConfigFile.PartSizeFileFolder + m_DataMgr.m_RptConfigFile.PartSizeFile;
  1001. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
  1002. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1003. List<string> temp = new List<string>();
  1004. for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
  1005. {
  1006. if (sizestr.Split(',')[j].Length > 0)
  1007. {
  1008. double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
  1009. double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
  1010. string name = d1.ToString() + "~" + d2.ToString();
  1011. temp.Add(name);
  1012. if (!listName.Contains(name))
  1013. {
  1014. listName.Add(name);
  1015. }
  1016. }
  1017. }
  1018. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1019. string name1 = d.ToString() + "~MAX";
  1020. temp.Add(name1);
  1021. if (!listName.Contains(name1))
  1022. {
  1023. listName.Add(name1);
  1024. }
  1025. //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();
  1026. string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  1027. string po = "";
  1028. switch (con)
  1029. {
  1030. case "DMAX":
  1031. po = "DMAX";
  1032. break;
  1033. case "DMIN":
  1034. po = "DMIN";
  1035. break;
  1036. case "ECD":
  1037. po = "Area";
  1038. break;
  1039. case "FERET":
  1040. po = "DFERET";
  1041. break;
  1042. }
  1043. DataTable dtp = particledata.GetParticleAll(filedAndParticl);
  1044. //设置数据
  1045. List<Item> listData4 = new List<Item>();
  1046. //ListData
  1047. for (int k = 0; k < temp.Count; k++)
  1048. {
  1049. string str = temp[k];
  1050. string d1 = str.Split('~')[0];
  1051. string d2 = str.Split('~')[1];
  1052. if (d2 == "MAX")
  1053. {
  1054. d2 = "999";
  1055. }
  1056. DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
  1057. Item item = new Item()
  1058. {
  1059. value = datas.Count().ToString(),
  1060. name = str
  1061. };
  1062. listData4.Add(item);
  1063. }
  1064. listDataMore.Add(listData4);
  1065. break;
  1066. }
  1067. }
  1068. }
  1069. chart.ListName = listName;
  1070. chart.SoursName = soursName;
  1071. chart.ListData = listDataMore;
  1072. return chart;
  1073. }
  1074. class Chartdate
  1075. {
  1076. public string Title { get; set; }
  1077. public string YName { get; set; }
  1078. public List<string> ListName { get; set; }
  1079. public List<Item> ListData { get; set; }
  1080. }
  1081. class ChartdateMore
  1082. {
  1083. public string Title { get; set; }
  1084. public string YName { get; set; }
  1085. public List<string> ListName { get; set; }
  1086. public List<string> SoursName { get; set; }
  1087. public List<List<Item>> ListData { get; set; }
  1088. }
  1089. class Item
  1090. {
  1091. public string value { get; set; }
  1092. public string name { get; set; }
  1093. }
  1094. //获取图片
  1095. private void button1_Click(object sender, EventArgs e)
  1096. {
  1097. }
  1098. /// <summary>
  1099. /// 加载浏览器
  1100. /// </summary>
  1101. public void InitBrowser()
  1102. {
  1103. //加载网页
  1104. if (m_ReportApp.browser == null || m_ReportApp.trans)
  1105. {
  1106. // 获取生成路径下网页文件的绝对路径
  1107. string fileName = Path.Combine(Directory.GetCurrentDirectory(), url);
  1108. //加载网页
  1109. m_ReportApp.browser = new ChromiumWebBrowser(fileName);
  1110. //禁止网页
  1111. m_ReportApp.browser.MenuHandler = new MenuHandler();
  1112. m_ReportApp.browser.Dock = DockStyle.Fill;
  1113. m_ReportApp.js.MessageText = "";
  1114. //添加网页到当前自定义控件
  1115. this.Controls.Add(m_ReportApp.browser);
  1116. //供页面调用以传递数据
  1117. m_ReportApp.browser.RegisterJsObject("jsObj", m_ReportApp.js, false);
  1118. //网页加载结束后调用事件
  1119. m_ReportApp.browser.FrameLoadEnd += WebBrowser_FrameLoadEnd;
  1120. }
  1121. else
  1122. {
  1123. m_ReportApp.browser.ResetText();
  1124. m_ReportApp.browser.Reload();
  1125. m_ReportApp.browser.Refresh();
  1126. //供页面调用以传递数据
  1127. this.Controls.Add(m_ReportApp.browser);
  1128. }
  1129. if (m_ReportApp.timerKG)
  1130. {
  1131. timer1.Enabled = true;
  1132. }
  1133. }
  1134. /// <summary>
  1135. /// 页面加载结束后事件
  1136. /// </summary>
  1137. /// <param name="sender"></param>
  1138. /// <param name="e"></param>
  1139. private void WebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
  1140. {
  1141. if (e.Frame.IsMain)
  1142. {
  1143. //为页面图形提供数据参数
  1144. string str = m_ReportApp.data;
  1145. string strCombin = m_ReportApp.dataCombin;
  1146. //执行网页脚本事件
  1147. m_ReportApp.browser.ExecuteScriptAsync("showchart('" + str + "','" + strCombin + "','" + m_ReportApp.type + "')");
  1148. }
  1149. }
  1150. //禁止网页操作,右键点击等
  1151. class MenuHandler : CefSharp.IContextMenuHandler
  1152. {
  1153. void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model)
  1154. {
  1155. model.Clear();
  1156. }
  1157. bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
  1158. {
  1159. //throw new NotImplementedException();
  1160. return false;
  1161. }
  1162. void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame)
  1163. {
  1164. //throw new NotImplementedException();
  1165. }
  1166. bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback)
  1167. {
  1168. return false;
  1169. }
  1170. }
  1171. class JsEvent
  1172. {
  1173. public string MessageText { set; get; }
  1174. public void ShowTest()
  1175. {
  1176. MessageBox.Show(MessageText);
  1177. }
  1178. }
  1179. #endregion
  1180. #region EChart导出图像委托调用部份
  1181. public delegate void MyDelgate(string va);
  1182. public event MyDelgate butclic;
  1183. private void timer1_Tick(object sender, EventArgs e)
  1184. {
  1185. if (butclic == null)
  1186. return;
  1187. if (m_ReportApp.js == null)
  1188. return;
  1189. if (m_ReportApp.js.MessageText == null)
  1190. return;
  1191. if (m_ReportApp.js.MessageText != "")
  1192. {
  1193. butclic(m_ReportApp.js.MessageText);
  1194. timer1.Enabled = false;
  1195. m_ReportApp.timerKG = false;
  1196. }
  1197. }
  1198. #endregion
  1199. }
  1200. }