EChart_ParticlesComposition.cs 62 KB

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