12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337 |
- using CefSharp;
- using CefSharp.WinForms;
- using Newtonsoft.Json;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.OTSRstMgrFunction;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.OTSTemplateDesigner;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGrids;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- namespace OTSIncAReportApp.Control_ECharts
- {
- /// <summary>
- /// 各图char相关模块
- /// </summary>
- public partial class EChart_ParticlesComposition : UserControl
- {
- Hashtable table;
- #region 图表相关变量
- //y轴名称
- public string m_str_AxisY { get; set; }
- //定义图片
- //JsEvent js;
- //定义图片base64
- public string pic { get; set; }
- //定义图形类型
- public string type { get; set; }
- //图形数据
- public string data { get; set; }
- string url = "CefSharp\\Resources\\HTML\\charts.html";
- //数据图类型:常用夹杂物分类CommonlyUsedClassify ,颗粒成分PComponent,元素成分EComponent,颗粒尺寸分布PSize
- string ComSel { get; set; }
- public bool Report { get; set; }
- frmReportApp m_ReportApp;
- List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 7, 8, 9 };
- List<string> NameList = new List<string>() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "非夹杂物颗粒SiC", "非夹杂物颗粒FeO", "未识别颗粒" };
- private frmReportConditionChoose m_conditionChoose;
- private ResultDataMgr m_DataMgr;
- #endregion
- #region 窗体加载及构造函数
- public EChart_ParticlesComposition(frmReportApp ReportApp, string comsel)
- {
- ComSel = comsel;
- m_ReportApp = ReportApp;
- m_conditionChoose = ReportApp.m_conditionChoose;
- m_DataMgr = ReportApp.m_rstDataMgr;
- InitializeComponent();
- //国际化
- Language lan = new Language();
- table = lan.GetNameTable("CompositionDistributionGrid");
- //m_export_reporttemplate = new GBData();
- }
-
- private void EChart_ParticlesComposition_Load(object sender, EventArgs e)
- {
- string sou = "";
- int sel = 0;//选择颗粒范围(0为全部颗粒1为选择颗粒)
- 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() };
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
- //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- if (Report)
- {
- sou = m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].anotherFileName.ToString();
- sel = 0;
- }
- else
- {
- sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
- sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- }
- Report = false;
- if (sou.Contains("+"))
- {
- if (m_ReportApp.more)
- {
- m_ReportApp.trans = false;
- }
- else
- {
- m_ReportApp.trans = true;
- }
- m_ReportApp.more = true;
- //获取到List,json的字符串
- ChartdateMore list_json_str = GetListJsonStr();
- url = "CefSharp\\Resources/HTML/chartsMore.html";
- m_ReportApp.data = JsonConvert.SerializeObject(list_json_str);
- }
- else
- {
- if (!m_ReportApp.more)
- {
- m_ReportApp.trans = false;
- }
- else
- {
- m_ReportApp.trans = true;
- }
- m_ReportApp.more = false;
- //获取到List,json的字符串
-
- for (int i=0;i< m_conditionChoose.m_conditionData.ConditionItemList.Count;i++)
- {
- if (m_conditionChoose.m_conditionData.ConditionItemList[i].itemDisplayVal.ToString()== sou)
- {
- m_DataMgr.SetWorkingResultId((int)m_conditionChoose.m_conditionData.ConditionItemList[i].itemVal);
- }
- }
-
- List<Chartdate> list_json_str = GetListJsonStrByChartStruct(sel);
- url = "CefSharp\\Resources/HTML/charts.html";
- m_ReportApp.data = JsonConvert.SerializeObject(list_json_str[0]);
- if (ComSel == "PSize")
- {
- ComSel = "PSizeCombin";
- m_ReportApp.dataCombin = JsonConvert.SerializeObject(GetListJsonStrByChartStruct(sel)[0]);
- }
- else
- {
- m_ReportApp.dataCombin = "";
- }
- }
- InitBrowser();
- }
- #endregion
- #region 获取单数据源
- //private Chartdate GetCommonlyUsedClassifyData(string path)
- //{
- // string spinel = table["str20"].ToString();
- // string oxide = table["str21"].ToString();
- // string SulfurOxide = table["str22"].ToString();
- // string nitrides = table["str23"].ToString();
- // string sulfide = table["str24"].ToString();
- // DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- // //创建新的图形数据源
- // Chartdate chart = new Chartdate();
- // chart.Title = m_ReportApp.m_reportname;
- // chart.YName = m_str_AxisY;
- // //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- // //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- // //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- // int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- // DataTable dt = new DataTable();
- // dt = particledata.GetCommonlyUsedClassifyData();
- // //DataTable dt = dataTable;
- // //设置标签名称
- // List<string> listName = new List<string>();
- // listName.Add(spinel);
- // listName.Add(oxide);
- // listName.Add(SulfurOxide);
- // listName.Add(nitrides);
- // listName.Add(sulfide);
- // chart.ListName = listName;
- // //设置数据
- // List<Item> listData = new List<Item>();
- // //ListData
- // for (int k = 0; k < dt.Rows.Count; k++)
- // {
- // try
- // {
- // Item item_SPINEL = new Item()
- // {
- // value = decimal.Round(decimal.Parse(dt.Rows[k]["SPINEL"].ToString()), 2).ToString(),
- // name = spinel
- // };
- // listData.Add(item_SPINEL);
- // Item item_OXIDE = new Item()
- // {
- // value = decimal.Round(decimal.Parse(dt.Rows[k]["OXIDE"].ToString()), 2).ToString(),
- // name = oxide
- // };
- // listData.Add(item_OXIDE);
- // Item item_SULFIDE_OXIDE = new Item()
- // {
- // value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE_OXIDE"].ToString()), 2).ToString(),
- // name = SulfurOxide
- // };
- // listData.Add(item_SULFIDE_OXIDE);
- // Item item_NITRIDE = new Item()
- // {
- // value = decimal.Round(decimal.Parse(dt.Rows[k]["NITRIDE"].ToString()), 2).ToString(),
- // name = nitrides
- // };
- // listData.Add(item_NITRIDE);
- // Item item_SULFIDE = new Item()
- // {
- // value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE"].ToString()), 2).ToString(),
- // name = sulfide
- // };
- // listData.Add(item_SULFIDE);
- // }
- // catch
- // {
- // Item item = new Item()
- // {
- // value = "",
- // name = ""
- // };
- // listData.Add(item);
- // }
- // }
- // chart.ListData = listData;
- // return chart;
- //}
- private Chartdate GetInclusionAreaRatioData(string path,int sel)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- DataTable data = new DataTable();
- data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- //DataTable data = particledata.GetAreaByAllIncA("");
- DataTable dt = ConSolidateInvalid(data);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[i]["TypeName"].ToString());
- }
-
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["ar"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- continue;
- }
- Item item = new Item()
- {
- value =Convert.ToInt32(dt.Rows[k]["ar"]).ToString(),
- name = name
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- private Chartdate GetInclusionAreaRatioClassData(string path,int sel)
- {
-
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //计算分类整个表的数据
- DataTable dt= ClassificationIntegration(path,sel);
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["e1"].ToString() != "")
- listName.Add(dt.Rows[i]["e1"].ToString());
- }
- chart.ListName = listName;
- //DataTable dt
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- if (dt.Rows[k]["e1"].ToString() != "")
- {
- string str = dt.Rows[k]["Cunt"].ToString();
- string name = dt.Rows[k]["e1"].ToString();
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["Cunt"].ToString()), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- }
- chart.ListData = listData;
- return chart;
- }
- private DataTable ClassificationIntegration(string path ,int sel)
- {
- //------------------加载模块,获取数据-------------------------------------------------
- ResultGrid ls_resultgrid = new ResultGrid(m_ReportApp);
- Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid_Report();
- //------------------加载模块,获取数据结束----------------------------------------------
- Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
-
- string str_SCZS = "";
-
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- DataTable data = new DataTable();
- data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- if(data.Rows.Count==0)
- {
- return data;
- }
-
- DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
- DataTable AllAnalysisDetails = new DataTable();
- AllAnalysisDetails.Columns.Add("Name");
- AllAnalysisDetails.Columns.Add("TypeId");
- AllAnalysisDetails.Columns.Add("Area", typeof(double));
- AllAnalysisDetails.Columns.Add("Class");
- AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
- for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
- {
- DataRow dr2 = AllAnalysisDetails.NewRow();
- dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
- dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
- dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
- dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
- dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
- AllAnalysisDetails.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = particledata.GetAllClass();
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- DataTable AreaRatio = new DataTable();
- AreaRatio.TableName = "InclusionAreaRatio";
- AreaRatio.Columns.Add("e1");
- AreaRatio.Columns.Add("e2");
- AreaRatio.Columns.Add("e3", typeof(double));
- AreaRatio.Columns.Add("e4");
- AreaRatio.Columns.Add("e5");
- AreaRatio.Columns.Add("Cunt", typeof(int));
- //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
- double totalInclusionArea = 0;
- totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
- for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
- {
- DataRow dr2 = AreaRatio.NewRow();
- dr2["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
- dr2["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
- dr2["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
- dr2["e4"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
- dr2["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
- dr2["Cunt"]= AllAnalysisDetails.Rows[i]["Cunt"].ToString();
- AreaRatio.Rows.Add(dr2);
- }
- DataTable AreaRatio_dt = AreaRatio.Copy();
- AreaRatio_dt.Clear();
- for (int i = 0; i < ClassName.Count(); i++)
- {
- DataTable dt = AreaRatio.Copy();
- dt.Clear();
- for (int a = 0; a < AreaRatio.Rows.Count; a++)
- {
- if (AreaRatio.Rows[a]["e1"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
- }
- }
- DataView dv = dt.DefaultView;
- dv.Sort = "e3 DESC";
- DataTable dt_Element = dv.ToTable();
- for (int a = 0; a < dt_Element.Rows.Count; a++)
- {
- AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
- }
- }
- DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
- AllAnalysisDetails1.Clear();
- for (int i = 0; i < ClassName.Count; i++)
- {
- DataTable dt = AreaRatio_dt.Copy();
- dt.Clear();
- for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
- {
- if (AreaRatio_dt.Rows[a]["e1"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count > 0)
- {
- double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(e3)", "").ToString()));
- double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- int cunt= Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
- DataRow dr3 = AllAnalysisDetails1.NewRow();
- dr3["e1"] = ClassName[i].ToString();
- dr3["e3"] = Math.Round(Area, 2);
- //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- dr3["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea2) * 100, 2);
- dr3["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
- dr3["Cunt"] = cunt;
- AllAnalysisDetails1.Rows.Add(dr3);
- }
- }
- return AllAnalysisDetails1;
- }
- private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
- {
- DataTable dt_Partick = new DataTable();
- dt_Partick.Columns.Add("TypeId");
- dt_Partick.Columns.Add("TypeName");
- dt_Partick.Columns.Add("TypeColor");
- dt_Partick.Columns.Add("con");
- dt_Partick.Columns.Add("av");
- dt_Partick.Columns.Add("max");
- dt_Partick.Columns.Add("ar", typeof(double));
- dt_Partick.Columns.Add("GroupName");
- List<string> typeName = new List<string>();
- for (int i = 0; i < data.Rows.Count; i++)
- {
- typeName.Add(data.Rows[i]["TypeId"].ToString());
- }
- typeName = typeName.Distinct().ToList();
- for (int i = 0; i < typeName.Count; i++)
- {
- DataTable dt = dt_Partick.Clone();
- for (int j = 0; j < data.Rows.Count; j++)
- {
- if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
- {
- DataRow row = dt.NewRow();
- row["TypeId"] = data.Rows[j]["TypeId"];
- row["TypeName"] = data.Rows[j]["TypeName"];
- row["TypeColor"] = data.Rows[j]["TypeColor"];
- row["ar"] = data.Rows[j]["Area"];
- dt.Rows.Add(row);
- }
- }
- DataRow dr = dt_Partick.NewRow();
- dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
- dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
- dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
- dr["con"] = dt.Rows.Count;
- dr["av"] = dt.Compute("min(ar)", "");
- dr["max"] = dt.Compute("Max(ar)", "");
- dr["ar"] = dt.Compute("SUM(ar)", "");
- dt_Partick.Rows.Add(dr);
- }
- for (int i = 0; i < dt_Partick.Rows.Count; i++)
- {
- for (int j = 0; j < table.Rows.Count; j++)
- {
- if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
- {
- dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
- break;
- }
- }
- }
- return dt_Partick;
- }
- private DataTable ConSolidateInvalid(DataTable dt)
- {
-
- DataTable dt_invalid = dt.Clone();
- DataTable dt_no_invalid = dt.Clone();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["TypeName"].ToString()=="Invalid")
- {
- dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
- }
- else
- {
- dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
- }
- }
- return dt_no_invalid;
- }
- /// <summary>
- /// 获取颗粒成分数据
- /// </summary>
- private Chartdate GetPComponentData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
-
- DataTable dt = particledata.GetParticleListForParticlSize("area", filedAndParticl);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[i]["TypeName"].ToString());
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
- {
- continue;
- }
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- string name = NameList[index];
- if (listName.IndexOf(name) == -1)
- {
- listName.Add(name);
- }
- }
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["con"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- name = NameList[index];
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- /// <summary>
- /// 获取元素成分数据
- /// </summary>
- private Chartdate GetEComponentData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- DataTable dt = particledata.GetElementForArea(filedAndParticl);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listName.Add(dt.Rows[i]["name"].ToString());
- }
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["earea"].ToString();
- try
- {
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = dt.Rows[k]["name"].ToString()
- };
- listData.Add(item);
- }
- catch
- {
- Item item = new Item()
- {
- value = str,
- name = dt.Rows[k]["name"].ToString()
- };
- listData.Add(item);
- }
- }
- chart.ListData = listData;
- return chart;
- }
- /// <summary>
- /// 获取此尺寸分布图数据
- /// </summary>
- private Chartdate GetPSizeData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
- listName.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- listName.Add(d.ToString() + "~MAX");
- chart.ListName = listName;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
- //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < listName.Count; k++)
- {
- string str = listName[k];
- string d1 = str.Split('~')[0];
- string d2 = str.Split('~')[1];
- if (d2 == "MAX")
- {
- d2 = "999";
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
- Item item = new Item()
- {
- value = datas.Count().ToString(),
- name = str
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- private Chartdate GetPSizeDataCombin(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
- listName.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- listName.Add(d.ToString() + "~MAX");
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
- //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //计算分类整个表的数据
- DataTable dt = ClassificationIntegration(path, sel);
- List<string> listClassificationName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listClassificationName.Add(dt.Rows[i]["e1"].ToString());
- }
- chart.ListName = listClassificationName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- string strNameGroup = "";
- for (int j = 0; j < listClassificationName.Count; j++)
- {
- string strGroup = "";
- for (int k = 0; k < listName.Count; k++)
- {
- string str = listName[k];
- string d1 = str.Split('~')[0];
- string d2 = str.Split('~')[1];
- if (d2 == "MAX")
- {
- d2 = "999";
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po) + " and GroupName = '" + listClassificationName[j] + "'");
- strGroup += datas.Count();
- if (k != listName.Count - 1)
- {
- strGroup += ",";
- }
- }
- Item item = new Item()
- {
- value = strGroup,
- name = listClassificationName[j]
- };
- listData.Add(item);
- strNameGroup += listClassificationName[j];
- if (j != listClassificationName.Count - 1)
- {
- strNameGroup += ",";
- }
- }
- chart.Title = "[" + strNameGroup + "]";
- chart.ListData = listData;
- return chart;
- }
- private string getWhere(string max, string min, string col)
- {
- return col + ">=" + min + " and " + col + "<" + max;
- }
- #endregion
- #region echarts
- /// <summary>
- /// 通过m_list_chartstruct,组合json数据格式
- /// </summary>
- /// <returns></returns>
- private List<Chartdate> GetListJsonStrByChartStruct(int sel)
- {
- List<Chartdate> list = new List<Chartdate>();
- Chartdate chartdate = new Chartdate();
- switch (ComSel)
- {
- case "CommonlyUsedClassify":
- //chartdate = GetCommonlyUsedClassifyData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
- chartdate = GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- case "PComponent":
- chartdate = GetPComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "EComponent":
- chartdate = GetEComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "PSize":
- chartdate = GetPSizeData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "PSizeCombin":
- chartdate = GetPSizeDataCombin(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "InclusionareaRatio":
- chartdate = GetInclusionAreaRatioData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- case "InclusionareaClassRatio":
- chartdate=GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- }
- list.Add(chartdate);
- return list;
- }
- /// <summary>
- /// 通过m_list_chartstruct,组合json数据格式
- /// </summary>
- /// <returns></returns>
- private ChartdateMore GetListJsonStr()
- {
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_conditionChoose.m_conditionData.ProItemProIndex();
- string filedAndParticl = "";
- DataOperation.DataAccess.ParticleData particledata = null;
- DataTable dt = new DataTable();
- ChartdateMore chart = new ChartdateMore();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- List<string> listName = new List<string>();
- List<string> soursName = new List<string>();
- List<List<Item>> listDataMore = new List<List<Item>>();
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
- //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
- if (sou.Contains("+"))
- {
- for (int i = 0; i < sou.Split('+').Length; i++)
- {
- ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
- if (resultFile == null)
- {
- continue;
- }
- soursName.Add(resultFile.anotherFileName);
- particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
- switch (ComSel)
- {
- case "InclusionareaRatio":
- dt = particledata.GetAreaByAllIncA("");
- //设置标签名称
-
- for (int a = 0; a < dt.Rows.Count; a++)
- {
- if (Convert.ToInt32(dt.Rows[a]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[a]["TypeName"].ToString());
- }
- //设置数据
- List<Item> listData3 = new List<Item>();
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["ar"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- continue;
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["ar"].ToString()), 2).ToString(),
- name = name
- };
- listData3.Add(item);
- }
- listDataMore.Add(listData3);
- break;
- case "CommonlyUsedClassify":
- //计算分类整个表的数据
- dt = ClassificationIntegration(resultFile.FilePath,sel);
- ////List<string> listName = new List<string>();
- ////ListName
- for (int a = 0; a < dt.Rows.Count; a++)
- {
- listName.Add(dt.Rows[a]["e1"].ToString());
- }
- //chart.ListName = listName;
- ////DataTable dt
- //设置数据
- List<Item> listData2 = new List<Item>();
- ////ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["Cunt"].ToString();
- string name = dt.Rows[k]["e1"].ToString();
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData2.Add(item);
- //listData2.Add(item);
- }
- listDataMore.Add(listData2);
- break;
- case "PComponent":
- //创建新的图形数据源
- dt = particledata.GetParticleListByIncA("area");
- //设置标签名称
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- if (Convert.ToInt32(dt.Rows[j]["TypeId"]) < 100)
- {
- continue;
- }
- string name = dt.Rows[j]["TypeName"].ToString();
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- if (Convert.ToInt32(dt.Rows[j]["TypeId"]) > 100)
- {
- continue;
- }
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[j]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- string name = NameList[index];
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["con"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- if (Convert.ToInt32(dt.Rows[k]["TypeId"])==-1)
- {
- name = NameList[7];
- }
- else
- {
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
- name = NameList[index];
- }
-
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- listDataMore.Add(listData);
- break;
- case "EComponent":
- //创建新的图形数据源
- dt = particledata.GetElementForArea(filedAndParticl);
- //ListName
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- string name = dt.Rows[j]["name"].ToString();
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- //设置数据
- List<Item> listData1 = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["earea"].ToString();
- try
- {
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = dt.Rows[k]["name"].ToString()
- };
- listData1.Add(item);
- }
- catch
- {
- Item item = new Item()
- {
- value = str,
- name = dt.Rows[k]["name"].ToString()
- };
- listData1.Add(item);
- }
- }
- listDataMore.Add(listData1);
- break;
- case "PSize":
- //获取粒级表
- string pathe = m_DataMgr.m_RptConfigFile.PartSizeFileFolder + m_DataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- List<string> temp = new List<string>();
- for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
- {
- if (sizestr.Split(',')[j].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
- string name = d1.ToString() + "~" + d2.ToString();
- temp.Add(name);
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- string name1 = d.ToString() + "~MAX";
- temp.Add(name1);
- if (!listName.Contains(name1))
- {
- listName.Add(name1);
- }
- //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();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //设置数据
- List<Item> listData4 = new List<Item>();
- //ListData
- for (int k = 0; k < temp.Count; k++)
- {
- string str = temp[k];
- string d1 = str.Split('~')[0];
- string d2 = str.Split('~')[1];
- if (d2 == "MAX")
- {
- d2 = "999";
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
- Item item = new Item()
- {
- value = datas.Count().ToString(),
- name = str
- };
- listData4.Add(item);
- }
- listDataMore.Add(listData4);
- break;
- }
- }
- }
- chart.ListName = listName;
- chart.SoursName = soursName;
- chart.ListData = listDataMore;
- return chart;
- }
- class Chartdate
- {
- public string Title { get; set; }
- public string YName { get; set; }
- public List<string> ListName { get; set; }
- public List<Item> ListData { get; set; }
- }
- class ChartdateMore
- {
- public string Title { get; set; }
- public string YName { get; set; }
- public List<string> ListName { get; set; }
- public List<string> SoursName { get; set; }
- public List<List<Item>> ListData { get; set; }
- }
- class Item
- {
- public string value { get; set; }
- public string name { get; set; }
- }
- //获取图片
- private void button1_Click(object sender, EventArgs e)
- {
-
- }
- /// <summary>
- /// 加载浏览器
- /// </summary>
- public void InitBrowser()
- {
-
- //加载网页
- if (m_ReportApp.browser == null || m_ReportApp.trans)
- {
- // 获取生成路径下网页文件的绝对路径
- string fileName = Path.Combine(Directory.GetCurrentDirectory(), url);
- //加载网页
- m_ReportApp.browser = new ChromiumWebBrowser(fileName);
-
- //禁止网页
- m_ReportApp.browser.MenuHandler = new MenuHandler();
- m_ReportApp.browser.Dock = DockStyle.Fill;
- m_ReportApp.js.MessageText = "";
- //添加网页到当前自定义控件
- this.Controls.Add(m_ReportApp.browser);
- //供页面调用以传递数据
- m_ReportApp.browser.RegisterJsObject("jsObj", m_ReportApp.js, false);
-
- //网页加载结束后调用事件
- m_ReportApp.browser.FrameLoadEnd += WebBrowser_FrameLoadEnd;
- }
- else
- {
- m_ReportApp.browser.ResetText();
- m_ReportApp.browser.Reload();
- m_ReportApp.browser.Refresh();
- //供页面调用以传递数据
- this.Controls.Add(m_ReportApp.browser);
- }
- if (m_ReportApp.timerKG)
- {
- timer1.Enabled = true;
- }
- }
- /// <summary>
- /// 页面加载结束后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void WebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
- {
- if (e.Frame.IsMain)
- {
- //为页面图形提供数据参数
- string str = m_ReportApp.data;
- string strCombin = m_ReportApp.dataCombin;
- //执行网页脚本事件
- m_ReportApp.browser.ExecuteScriptAsync("showchart('" + str + "','" + strCombin + "','" + m_ReportApp.type + "')");
- }
- }
-
- //禁止网页操作,右键点击等
- class MenuHandler : CefSharp.IContextMenuHandler
- {
- void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model)
- {
- model.Clear();
- }
- bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
- {
- //throw new NotImplementedException();
- return false;
- }
- void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame)
- {
- //throw new NotImplementedException();
- }
- bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback)
- {
- return false;
- }
- }
- class JsEvent
- {
- public string MessageText { set; get; }
- public void ShowTest()
- {
- MessageBox.Show(MessageText);
- }
- }
- #endregion
- #region EChart导出图像委托调用部份
- public delegate void MyDelgate(string va);
- public event MyDelgate butclic;
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (butclic == null)
- return;
- if (m_ReportApp.js == null)
- return;
- if (m_ReportApp.js.MessageText == null)
- return;
- if (m_ReportApp.js.MessageText != "")
- {
- butclic(m_ReportApp.js.MessageText);
- timer1.Enabled = false;
- m_ReportApp.timerKG = false;
- }
- }
- #endregion
- }
- }
|