1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242 |
- using OTSIncAReportApp.Control_ECharts;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.DataOperation.Model;
- using OTSIncAReportGraph.Controls;
- using OTSIncAReportGrids;
- using OTSPeriodicTable;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- namespace OTSIncAReportApp.OTSTemplateDesigner
- {
- public class Export_ReportTemplate
- {
- #region 全局变量
- public List<DataTable> m_list_dt; //导出的各模块数据,合集
- public OTSReport_Export m_otsreport_export;
- DataTable m_bt_DBData = new DataTable();
- List<string> TemplateList;
- #endregion
- #region 构造函数
- public Export_ReportTemplate(OTSReport_Export in_export)
- {
- m_otsreport_export = in_export;
- TemplateList = new List<string>();
- //加载三元相图各项
- string pathtpf = in_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.FileFolderTrigTemp + "\\" + in_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.TriTempFile;// Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";
- TemplateList = new List<string>();
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXmlData(pathtpf, "XMLData");
- DataTable dt = ds.Tables["Member"];
- foreach (DataRow item in dt.Rows)
- {
- if (item["TemplateName"].ToString() != "")
- {
- TemplateList.Add(item["TemplateName"].ToString());
- }
- }
- m_list_dt = new List<DataTable>();
- }
- public Export_ReportTemplate()
- {
- m_list_dt = new List<DataTable>();
- }
- #endregion
- #region 插入测量结果Grid表格
- /// <summary>
- /// 向 模板设计器 中插入测量结果Grid表格
- /// </summary>
- /// <returns></returns>
- public DataTable InsertReportTemplateTable_ResultGrid()
- {
-
- //------------------加载模块,获取数据-------------------------------------------------
- ResultGrid ls_resultgrid = new ResultGrid(m_otsreport_export.m_ReportApp);
- Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid();
- //------------------加载模块,获取数据结束----------------------------------------------
- Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
- string str_CLJGMC = "";
- string str_YXSJ = "";
- string str_SCZS = "";
- string str_FLFA = "";
- string str_YJCTZ = "";
- string str_SCMJ = "";
- string str_CKBZ = "GB/T30834-2014";
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col1"].ToString(), out str_CLJGMC);//测量结果名称
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col4"].ToString(), out str_YXSJ);//运行时间
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col6"].ToString(), out str_FLFA);//分类方案
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col7"].ToString(), out str_YJCTZ);//已检测特征
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col8"].ToString(), out str_SCMJ);//视场面积
- //将获取到的数据转换成报告模板能接收的格式。
- DataTable ls_new_dt = new DataTable();
- ls_new_dt.TableName = "ResultGrid";
- ls_new_dt.Columns.Add("CLJGMC"); //测量结果名称
- ls_new_dt.Columns.Add("YXSJ"); //运行时间
- ls_new_dt.Columns.Add("SCZS"); //视场总数
- ls_new_dt.Columns.Add("FLFA"); //分类方案
- ls_new_dt.Columns.Add("YJCTZ"); //已检测特征
- ls_new_dt.Columns.Add("SCMJ"); //视场面积
- ls_new_dt.Columns.Add("CKBZ"); //参考标准
- //行转列,这里不会发生改变,所以这样写
- DataRow dr = ls_new_dt.NewRow();
- dr["CLJGMC"] = str_CLJGMC;
- dr["YXSJ"] = str_YXSJ;
- dr["SCZS"] = str_SCZS;
- dr["FLFA"] = str_FLFA;
- dr["YJCTZ"] = str_YJCTZ;
- dr["SCMJ"] = str_SCMJ;
- dr["CKBZ"] = str_CKBZ;
- ls_new_dt.Rows.Add(dr);
- m_list_dt.Add(ls_new_dt);
- return ls_new_dt;
-
- }
- #endregion
- #region 一次性读取数据所需要的数据
- public bool GetDBData()
- {
- m_bt_DBData.Clear();
- m_bt_DBData.Columns.Clear();
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
- List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.FileFolderSize + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
- 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]);
- colid.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- colid.Add(d.ToString() + "~MAX");
- for (int i=0;i< colid.Count;i++)
- {
- m_bt_DBData.Columns.Add(colid[i].ToString());
- }
- DataTable dt = fielddata.GetParticleListForParticlSize("area", "");
- DataTable AreaInformationOfAllElements = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- DataTable dtp = fielddata.GetParticleAll("");
- List<string> vs = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };
- string po = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs];
- for (int i=0;i< dt.Rows.Count;i++)
- {
- DataRow dr = m_bt_DBData.NewRow();
- dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
- dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
- dr["con"]= dt.Rows[i]["con"].ToString();
- dr["Class"] = dt.Rows[i]["GroupName"].ToString();
- dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
- for (int a=6;a< colid.Count;a++)
- {
- string d1 = colid[a].Split('~')[0];
- string d2 = colid[a].Split('~')[1];
- if (d2 == "MAX")
- {
- d2 = "999";
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
- dr[colid[a]] = datas.Count();
- }
- for (int a=0;a< AreaInformationOfAllElements.Rows.Count;a++)
- {
- if (dt.Rows[i]["TypeId"].ToString()== AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
- {
- dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
- }
- }
- m_bt_DBData.Rows.Add(dr);
- }
- return true;
- }
- private string getWhere(string max, string min, string col, string partic)
- {
- return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
- }
- #endregion
- #region 插入颗粒列表并带有帧图
- /// <summary>
- /// 颗粒列表中插入帧图,并带上颗粒分组信息
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateTable_ParticlesGridDevidePage()
- {
- int serialNumber = 1;
- //------------------加载模块,获取数据-------------------------------------------------
- m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
- DataTable dt = fielddata.GetIncaSurfaceData();
- //将颗粒大小排序(从大到小)
- DataView dv = dt.DefaultView;
- dv.Sort = "Area DESC";
- DataTable dt_ParticlesGridDevidePage = dv.ToTable();
- string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath;
- //------------------加载模块,获取数据结束----------------------------------------------
- #region 创建要插入数据库表结构
- //插入模板需父子表,结构
- //表名field_dt表:(父表) 帧图表
- DataTable DT_field_dt = new DataTable();
- DT_field_dt.TableName = "field_dt";
- DataColumn colpictid2 = new DataColumn("FieldId");
- colpictid2.DataType = typeof(int);
- DT_field_dt.Columns.Add(colpictid2);
- //图像列
- DataColumn colpict2 = new DataColumn("FieldImg");
- colpict2.DataType = System.Type.GetType("System.Byte[]");
- DT_field_dt.Columns.Add(colpict2);
- //表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
- DataTable DT_field_dt_copy = new DataTable();
- DataTable DT_Largest_frame = new DataTable();
- DT_Largest_frame.TableName = "Largest_frame";
- DT_Largest_frame.Columns.Add("pid");
- DT_Largest_frame.Columns.Add("Size");
- DT_Largest_frame.Columns.Add("Width");
- DT_Largest_frame.Columns.Add("DMAX");
- DT_Largest_frame.Columns.Add("DMIN");
- DT_Largest_frame.Columns.Add("Class");
- DT_Largest_frame.Columns.Add("ColName1");
- DT_Largest_frame.Columns.Add("ColName2");
- DT_Largest_frame.Columns.Add("ColName3");
- DT_Largest_frame.Columns.Add("ColName4");
- DT_Largest_frame.Columns.Add("ColName5");
- DT_Largest_frame.Columns.Add("ColName6");
- DT_Largest_frame.Columns.Add("ColVal1");
- DT_Largest_frame.Columns.Add("ColVal2");
- DT_Largest_frame.Columns.Add("ColVal3");
- DT_Largest_frame.Columns.Add("ColVal4");
- DT_Largest_frame.Columns.Add("ColVal5");
- DT_Largest_frame.Columns.Add("ColVal6");
- DataColumn colpictid = new DataColumn("FieldId");
- colpictid.DataType = typeof(int);
- DT_Largest_frame.Columns.Add(colpictid);
- //图像列
- DataColumn colpict = new DataColumn("p1");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- DT_Largest_frame.Columns.Add(colpict);
- //largest20表:(无关系表) 需要显示前20条带有显示能谱图像的颗粒表
- DataTable DT_Largest20 = new DataTable();
- DT_Largest20.TableName = "Largest20";
- DT_Largest20.Columns.Add("pid");
- DT_Largest20.Columns.Add("Size");
- DT_Largest20.Columns.Add("Width");
- DT_Largest20.Columns.Add("DMAX");
- DT_Largest20.Columns.Add("DMIN");
- DT_Largest20.Columns.Add("Class");
- DT_Largest20.Columns.Add("ColName1");
- DT_Largest20.Columns.Add("ColName2");
- DT_Largest20.Columns.Add("ColName3");
- DT_Largest20.Columns.Add("ColName4");
- DT_Largest20.Columns.Add("ColName5");
- DT_Largest20.Columns.Add("ColName6");
- DT_Largest20.Columns.Add("ColVal1");
- DT_Largest20.Columns.Add("ColVal2");
- DT_Largest20.Columns.Add("ColVal3");
- DT_Largest20.Columns.Add("ColVal4");
- DT_Largest20.Columns.Add("ColVal5");
- DT_Largest20.Columns.Add("ColVal6");
- // 图像列
- DataColumn colpict_20ago = new DataColumn("p1");
- colpict_20ago.DataType = System.Type.GetType("System.Byte[]");
- DT_Largest20.Columns.Add(colpict_20ago);
- DataColumn colpict2_20ago = new DataColumn("p2");
- colpict2_20ago.DataType = System.Type.GetType("System.Byte[]");
- DT_Largest20.Columns.Add(colpict2_20ago);
- DataColumn colpict3_20ago = new DataColumn("p3");
- colpict3_20ago.DataType = System.Type.GetType("System.Byte[]");
- DT_Largest20.Columns.Add(colpict3_20ago);
- #endregion
- #region 插入-前20颗粒部份
-
- for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
- {
- if (dt_ParticlesGridDevidePage.Rows[i_row].ItemArray[24].ToString()!= "Not Identified")
- {
- //获取颗粒的fieldid,和particleid
- string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
- string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
- string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
- string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
- string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
- //获取原始颗粒图像
- Bitmap bp_particle = new Bitmap(1, 1);
- string str_path = str_resultPath + "\\FIELD_FILES\\";
- string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
- if (str_fieldid == "-1")
- continue;
- if (serialNumber > 20)
- continue;
- if (str_subparticles != null && str_subparticles != "")
- {
- //合并大颗粒
- double ScanFieldSize = 1142;
- Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);
- int pixw = tempbit.Width;
- double xs = pixw / ScanFieldSize;
- bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);
- }
- else
- {
- //正常颗粒
- Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };
- Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
- bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
- bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };
- }
- //获取该颗粒的xray能谱图像
- System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
- str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
- Bitmap ls_xraybpnew = new Bitmap(1, 1);
- ls_xraybpnew = OTSIncAReportGraph.Class.DrawFunction.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理
- //获取该颗粒的二次放大处理图像
- Bitmap ls_processbitmap = new Bitmap(1, 1);
- ls_processbitmap = OTSIncAReportGraph.Class.DrawFunction.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善
- //再将图像转成二进制流-------------------------------------------------------------------
- //原图
- MemoryStream newms_p1 = new MemoryStream();
- bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_p1.Seek(0, SeekOrigin.Begin);
- byte[] newarr_p1 = new byte[newms_p1.Length];
- newms_p1.Read(newarr_p1, 0, newarr_p1.Length);
- //二次放大图
- MemoryStream newms_p2 = new MemoryStream();
- ls_processbitmap.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_p2.Seek(0, SeekOrigin.Begin);
- byte[] newarr_p2 = new byte[newms_p2.Length];
- newms_p2.Read(newarr_p2, 0, newarr_p2.Length);
- //能谱图
- MemoryStream newms_p3 = new MemoryStream();
- ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_p3.Seek(0, SeekOrigin.Begin);
- byte[] newarr_p3 = new byte[newms_p3.Length];
- newms_p3.Read(newarr_p3, 0, newarr_p3.Length);
- //---------------------------------------------------------------------------------------
- DataRow dr = DT_Largest20.NewRow();
- dr["p1"] = newarr_p1;
- dr["p2"] = newarr_p2;
- dr["p3"] = newarr_p3;
- newms_p1.Dispose();
- newms_p2.Dispose();
- newms_p3.Dispose();
- dr["pid"] = serialNumber++.ToString();
- //dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
- dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
- dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]), 2).ToString();
- dr["DMIN"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmin"]), 2).ToString();
- dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
- List<string> list_max_elementname = new List<string>();
- List<double> list_max_elementvale = new List<double>();
- GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
- //元素1
- dr["ColName1"] = list_max_elementname[0];
- dr["ColVal1"] = list_max_elementvale[0].ToString();
- //元素2
- dr["ColName2"] = list_max_elementname[1];
- dr["ColVal2"] = list_max_elementvale[1].ToString();
- //元素3
- dr["ColName3"] = list_max_elementname[2];
- dr["ColVal3"] = list_max_elementvale[2].ToString();
- //元素4
- dr["ColName4"] = list_max_elementname[3];
- dr["ColVal4"] = list_max_elementvale[3].ToString();
- //元素5
- dr["ColName5"] = list_max_elementname[4];
- dr["ColVal5"] = list_max_elementvale[4].ToString();
- //元素6
- dr["ColName6"] = list_max_elementname[5];
- dr["ColVal6"] = list_max_elementvale[5].ToString();
- DT_Largest20.Rows.Add(dr);
- }
- }
- #endregion
- #region 插入-帧图图像部份
- //首先生成标记颗粒的帧图图像文件
- m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile(dt_ParticlesGridDevidePage);
- string str_path_FIELD_FILES_MARK = str_resultPath + "\\FIELD_FILES_MARK\\";
- DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);
- if (theFolder.Exists)
- {
- //for (int i = 0; i <= theFolder.GetFiles().Count(); i++)
- //{
- // //判断i.bmp图片是否存在,如果不存在跳出当前循环
- // if (!DetermineWhetherTheFileExists(theFolder, i))
- // continue;
- // //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
- // DataRow[] datarowlist = dt_ParticlesGridDevidePage.Select(" fieldid = " + i);
- // if (datarowlist.Count() > 0)
- // {
- // Bitmap ls_bp_fieldmark = new Bitmap(theFolder.GetFiles()[i].FullName);
- // DataRow dr = DT_field_dt.NewRow();
- // MemoryStream newms_bp_fieldmark = new MemoryStream();
- // ls_bp_fieldmark.Save(newms_bp_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
- // newms_bp_fieldmark.Seek(0, SeekOrigin.Begin);
- // byte[] newarr_fieldmark = new byte[newms_bp_fieldmark.Length];
- // newms_bp_fieldmark.Read(newarr_fieldmark, 0, newarr_fieldmark.Length);
- // dr["FieldImg"] = newarr_fieldmark;
- // dr["FieldId"] = i;
- // ls_bp_fieldmark.Dispose();
- // DT_field_dt.Rows.Add(dr);
- // }
- //}
- foreach (FileInfo nextifile in theFolder.GetFiles())
- {
- if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
- {
- //确认对应的帧图名
- string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
- //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
- DataRow[] datarowlist = dt_ParticlesGridDevidePage.Select(" fieldid = " + str_fieldid);
- if (datarowlist.Count() > 0)
- {
- Bitmap ls_bp_fieldmark = new Bitmap(nextifile.FullName);
- DataRow dr = DT_field_dt.NewRow();
- MemoryStream newms_bp_fieldmark = new MemoryStream();
- ls_bp_fieldmark.Save(newms_bp_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_bp_fieldmark.Seek(0, SeekOrigin.Begin);
- byte[] newarr_fieldmark = new byte[newms_bp_fieldmark.Length];
- newms_bp_fieldmark.Read(newarr_fieldmark, 0, newarr_fieldmark.Length);
- dr["FieldImg"] = newarr_fieldmark;
- dr["FieldId"] = str_fieldid;
- ls_bp_fieldmark.Dispose();
- DT_field_dt.Rows.Add(dr);
- }
- }
- }
-
- DataView vw = DT_field_dt.DefaultView;
- vw.Sort = "FieldId ASC";
- DT_field_dt_copy = vw.ToTable();
- }
- #endregion
- #region 插入-前20颗粒外的颗粒
- for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
- {
- if (dt_ParticlesGridDevidePage.Rows[i_row]["element"].ToString() == "")
- continue;
- //获取颗粒的fieldid,和particleid
- string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
- if (Convert.ToInt32(str_fieldid) < 20)
- {
-
- string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
- string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
- string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
- string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
- //获取原始颗粒图像
- Bitmap bp_particle = new Bitmap(1, 1);
- string str_path = str_resultPath + "\\FIELD_FILES\\";
- string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
- if (str_subparticles != null && str_subparticles != "")
- {
- //合并大颗粒
- //double ScanFieldSize = 1142;
- //Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);
- //int pixw = tempbit.Width;
- //double xs = pixw / ScanFieldSize;
- //bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);
- continue;
- }
- else
- {
- //正常颗粒
- Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };
- Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
- bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
- bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };
- }
- //获取该颗粒的xray能谱图像
- System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
- str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
- //获取该颗粒的二次放大处理图像
- Bitmap ls_processbitmap = new Bitmap(1, 1);
- ls_processbitmap = (Bitmap)bp_particle.Clone();//待完善
- //再将图像转成二进制流-------------------------------------------------------------------
- //原图
- MemoryStream newms_p1 = new MemoryStream();
- bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_p1.Seek(0, SeekOrigin.Begin);
- byte[] newarr_p1 = new byte[newms_p1.Length];
- newms_p1.Read(newarr_p1, 0, newarr_p1.Length);
- //---------------------------------------------------------------------------------------
- DataRow dr = DT_Largest_frame.NewRow();
- dr["p1"] = newarr_p1;
- newms_p1.Dispose();
- dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
- dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
- dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]),2).ToString();
- dr["DMIN"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmin"]),2).ToString();
- dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
- dr["fieldid"] = str_fieldid;
- List<string> list_max_elementname = new List<string>();
- List<double> list_max_elementvale = new List<double>();
- GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
- //元素1
- dr["ColName1"] = list_max_elementname[0];
- dr["ColVal1"] = list_max_elementvale[0].ToString();
- //元素2
- dr["ColName2"] = list_max_elementname[1];
- dr["ColVal2"] = list_max_elementvale[1].ToString();
- //元素3
- dr["ColName3"] = list_max_elementname[2];
- dr["ColVal3"] = list_max_elementvale[2].ToString();
- //元素4
- dr["ColName4"] = list_max_elementname[3];
- dr["ColVal4"] = list_max_elementvale[3].ToString();
- //元素5
- dr["ColName5"] = list_max_elementname[4];
- dr["ColVal5"] = list_max_elementvale[4].ToString();
- //元素6
- dr["ColName6"] = list_max_elementname[5];
- dr["ColVal6"] = list_max_elementvale[5].ToString();
- DT_Largest_frame.Rows.Add(dr);
- }
-
- }
- #endregion
- FrameGraphParticleTable(dt_ParticlesGridDevidePage, str_resultPath, fielddata, DT_field_dt);
- m_list_dt.Add(DT_field_dt_copy);
- m_list_dt.Add(DT_Largest_frame);
- m_list_dt.Add(DT_Largest20);
- return true;
- }
- private bool JudgeWhetherItExists(int id, DataTable dt,string column)
- {
- for (int i=0;i<dt.Rows.Count;i++)
- {
- if (id == Convert.ToInt32(dt.Rows[i][column].ToString()))
- return true;
- }
- return false;
- }
-
- /// <param name="dt_ParticlesGridDevidePage">数据源</param>
- /// <param name="str_resultPath">地址</param>
- /// <param name="fielddata"></param>
- /// <param name="DT_field_dt">主表</param>
- private void FrameGraphParticleTable(DataTable dt_ParticlesGridDevidePage,string str_resultPath, ParticleData fielddata,DataTable DT_field_dt)
- {
- //表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
- DataTable FrameGraphSubTable = new DataTable();
- FrameGraphSubTable.TableName = "FrameGraphSubTable";
- FrameGraphSubTable.Columns.Add("pid");
- FrameGraphSubTable.Columns.Add("Size");
- FrameGraphSubTable.Columns.Add("Width");
- FrameGraphSubTable.Columns.Add("DMAX");
- FrameGraphSubTable.Columns.Add("DMIN");
- FrameGraphSubTable.Columns.Add("Class");
- FrameGraphSubTable.Columns.Add("ColName1");
- FrameGraphSubTable.Columns.Add("ColName2");
- FrameGraphSubTable.Columns.Add("ColName3");
- FrameGraphSubTable.Columns.Add("ColName4");
- FrameGraphSubTable.Columns.Add("ColName5");
- FrameGraphSubTable.Columns.Add("ColName6");
- FrameGraphSubTable.Columns.Add("ColVal1");
- FrameGraphSubTable.Columns.Add("ColVal2");
- FrameGraphSubTable.Columns.Add("ColVal3");
- FrameGraphSubTable.Columns.Add("ColVal4");
- FrameGraphSubTable.Columns.Add("ColVal5");
- FrameGraphSubTable.Columns.Add("ColVal6");
- DataColumn colpictid = new DataColumn("FieldId");
- colpictid.DataType = typeof(int);
- FrameGraphSubTable.Columns.Add(colpictid);
- //图像列
- DataColumn colpict = new DataColumn("p1");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- FrameGraphSubTable.Columns.Add(colpict);
- for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
- {
- if (dt_ParticlesGridDevidePage.Rows[i_row]["element"].ToString() == "")
- continue;
- //获取颗粒的fieldid,和particleid
- string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
- //if (Convert.ToInt32(str_fieldid) < 20)
- if (JudgeWhetherItExists(Convert.ToInt32(str_fieldid), DT_field_dt, "FieldId"))
- {
- string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
- string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
- string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
- string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
- //获取原始颗粒图像
- Bitmap bp_particle = new Bitmap(1, 1);
- string str_path = str_resultPath + "\\FIELD_FILES\\";
- string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
- if (str_subparticles != null && str_subparticles != "")
- {
-
- continue;
- }
- else
- {
- //正常颗粒
- Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };
- Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
- bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
- bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };
- }
- //获取该颗粒的xray能谱图像
- System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
- str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
- //获取该颗粒的二次放大处理图像
- Bitmap ls_processbitmap = new Bitmap(1, 1);
- ls_processbitmap = (Bitmap)bp_particle.Clone();//待完善
- //再将图像转成二进制流-------------------------------------------------------------------
- //原图
- MemoryStream newms_p1 = new MemoryStream();
- bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_p1.Seek(0, SeekOrigin.Begin);
- byte[] newarr_p1 = new byte[newms_p1.Length];
- newms_p1.Read(newarr_p1, 0, newarr_p1.Length);
- //---------------------------------------------------------------------------------------
- DataRow dr = FrameGraphSubTable.NewRow();
- dr["p1"] = newarr_p1;
- newms_p1.Dispose();
- dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
- dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
- dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
- dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]),2).ToString();
- dr["DMIN"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmin"]),2).ToString();
- dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
- dr["fieldid"] = str_fieldid;
- List<string> list_max_elementname = new List<string>();
- List<double> list_max_elementvale = new List<double>();
- GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
- //元素1
- dr["ColName1"] = list_max_elementname[0];
- dr["ColVal1"] = list_max_elementvale[0].ToString();
- //元素2
- dr["ColName2"] = list_max_elementname[1];
- dr["ColVal2"] = list_max_elementvale[1].ToString();
- //元素3
- dr["ColName3"] = list_max_elementname[2];
- dr["ColVal3"] = list_max_elementvale[2].ToString();
- //元素4
- dr["ColName4"] = list_max_elementname[3];
- dr["ColVal4"] = list_max_elementvale[3].ToString();
- //元素5
- dr["ColName5"] = list_max_elementname[4];
- dr["ColVal5"] = list_max_elementvale[4].ToString();
- //元素6
- dr["ColName6"] = list_max_elementname[5];
- dr["ColVal6"] = list_max_elementvale[5].ToString();
- FrameGraphSubTable.Rows.Add(dr);
- }
- }
- m_list_dt.Add(FrameGraphSubTable);
- }
- #endregion
- #region 插入颗粒尺寸表
- /// <summary>
- /// 向 模板设计器 中插入 颗粒尺寸表
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateTable_ParticleSizeGrid()
- {
- try
- {
- if (m_bt_DBData.Columns.Count==0)
- {
- GetDBData();
- }
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.FileFolderSize + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
- 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]);
- colid.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- colid.Add(d.ToString() + "~MAX");
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
- //------------------------------------------------
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- ls_partsize_dt.Columns.Add("c1");
- ls_partsize_dt.Columns.Add("c2");
- ls_partsize_dt.Columns.Add("c3");
- ls_partsize_dt.Columns.Add("c4");
- ls_partsize_dt.Columns.Add("c5");
- ls_partsize_dt.Columns.Add("c6");
- ls_partsize_dt.Columns.Add("c7");
- ls_partsize_dt.Columns.Add("c8");
- ls_partsize_dt.Columns.Add("c9");
- DataRow dr = ls_partsize_dt.NewRow();
- for (int i=1;i<10;i++)
- {
- if (colid.Count<i)
- {
- dr["c" + i.ToString()] = "";
- }
- else
- {
- dr["c" + i.ToString()] = colid[i - 1];
- }
- }
- ls_partsize_dt.Rows.Add(dr);
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- ls_Particel_dt.Columns.Add("c1", typeof(double));
- ls_Particel_dt.Columns.Add("c2", typeof(double));
- ls_Particel_dt.Columns.Add("c3", typeof(double));
- ls_Particel_dt.Columns.Add("c4", typeof(double));
- ls_Particel_dt.Columns.Add("c5", typeof(double));
- ls_Particel_dt.Columns.Add("c6", typeof(double));
- ls_Particel_dt.Columns.Add("c7", typeof(double));
- ls_Particel_dt.Columns.Add("c8", typeof(double));
- ls_Particel_dt.Columns.Add("c9", typeof(double));
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total", typeof(double));
- ls_Particel_dt.Columns.Add("TypeId");
- ls_Particel_dt.Columns.Add("Class");
- for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
- dr2["Class"] = m_bt_DBData.Rows[i]["Class"].ToString();
- dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j=1;j< 10;j++)
- {
- if (colid.Count >= j)
- {
- dr2["c" + j.ToString()] = Convert.ToDouble(m_bt_DBData.Rows[i][colid[j-1]]);
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = "0"; //求合
- double d_total = 0;
-
- for (int j = 1; j < 10; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(m_bt_DBData.Rows[i][colid[j - 1]]);
- }
- }
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = fielddata.GetAllClass();
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "NOT_INCLUTION")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //获取大分类信息
- DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
- ClassificationSort(ls_Particel_dt,ClassName, dt);
- m_list_dt.Add(ls_partsize_dt);
- return true;
- }
- catch (Exception ee)
- {
- m_otsreport_export.WriteRictBox(ee.ToString());
- return false;
- }
- }
- private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName )
- {
- DataTable dt_Class = dataTable.Copy();
- dt_Class.Clear();
- dt_Class.TableName = "Particel";
- dt_Class.Columns.Remove("Name");
- dt_Class.Columns.Remove("TypeId");
- for (int i = 0; i < ClassName.Count; i++)
- {
- //保留当前循环中大类物质,去除其他物质
- DataTable dt = dataTable.Copy();
- dt.Clear();
- for (int a = 0; a < dataTable.Rows.Count; a++)
- {
- if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(dataTable.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count == 0)
- continue;
- DataTable dt_2 = new DataTable();
- dt_2 = dataTable.Copy();
- dt_2.Clear();
- DataRow row = dt_2.NewRow();
- dt_2.Rows.Add(row);
- for (int a=0;a< dt.Columns.Count;a++)
- {
- if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class"&&dt.Columns[a].ToString()!= "TypeId")
- {
- bool bl = false;
- for (int b = 0; b < dt.Rows.Count; b++)
- {
- if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
- {
- bl = true;
- }
- }
- if (bl)
- {
- dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
- }
- }
- }
- dt_2.Columns.Remove("Name");
- dt_2.Columns.Remove("TypeId");
- dt_2.Rows[0]["Class"] = ClassName[i];
- //dt_2.Rows[0]["TypeId"] = dt.Rows[0]["TypeId"].ToString();
- dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
- }
- m_list_dt.Add(dt_Class);
- return dt_Class;
- }
- private void ClassificationSort(DataTable dataTable,List<string> ClassName,DataTable data)
- {
- DataTable dt = new DataTable();
- dt = dataTable.Copy();
- dt.Clear();
- dt.TableName = "Particel_subdivision";
- //循环list中每个类型
- for (int i=0;i< ClassName.Count();i++)
- {
- DataTable data1 = dt.Copy();
- data1.Clear();
- data1.Rows.Add();
- for (int a=0;a< data.Rows.Count;a++)
- {
- if (data.Rows[a]["Class"].ToString()== ClassName[i].ToString())
- {
- for (int b=1;b<10;b++)
- {
- data1.Rows[0]["c"+b.ToString()] = data.Rows[a]["c"+b.ToString()];
- }
- data1.Rows[0]["total"] = data.Rows[a]["total"];
- data1.Rows[0]["Class"] = data.Rows[a]["Class"];
- dt.Rows.Add(data1.Rows[0].ItemArray);
- }
- }
- DataTable dt_1 = new DataTable();
- dt_1 = dt.Copy();
- dt_1.Clear();
- //循环DataTable中每个分类的数据
- for (int a=0;a< dataTable.Rows.Count;a++)
- {
- if (dataTable.Rows[a]["Class"].ToString()== ClassName[i])
- {
- dataTable.Rows[a]["Class"] = "";
- dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
- }
- }
- //将颗粒数量排序(从大到小)
- DataView dv = dt_1.DefaultView;
- dv.Sort = "total DESC";
- DataTable dt_1_sort = dv.ToTable();
- for (int a = 0; a < dt_1_sort.Rows.Count; a++)
- {
- dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
- }
- }
- dt.Columns.Remove("TypeId");
-
- m_list_dt.Add(dt);
- }
- #endregion
- #region 插入平均元素含量表
- /// <summary>
- /// 向 模板设计器 中插入 平均元素含量表
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateTable_ElementCompositionAvgGrid()
- {
- try
- {
- //加载模块
- ElementCompositionAvgGrid ls_elementcompositionavggrid = new ElementCompositionAvgGrid(m_otsreport_export.m_ReportApp);
- m_otsreport_export.panel_container.Controls.Clear();
- m_otsreport_export.panel_container.Controls.Add(ls_elementcompositionavggrid);
- DataGridView ls_gv = new DataGridView();
- DataTable ls_dt = new DataTable();
- ls_elementcompositionavggrid.GetDataTableAndGridView(out ls_dt, out ls_gv);
- //------------------------------------------------
- DataTable ls_elementname_dt = new DataTable();
- ls_elementname_dt.TableName = "ElementName";
- ls_elementname_dt.Columns.Add("e1");
- ls_elementname_dt.Columns.Add("e2");
- ls_elementname_dt.Columns.Add("e3");
- ls_elementname_dt.Columns.Add("e4");
- ls_elementname_dt.Columns.Add("e5");
- ls_elementname_dt.Columns.Add("e6");
- ls_elementname_dt.Columns.Add("e7");
- ls_elementname_dt.Columns.Add("e8");
- ls_elementname_dt.Columns.Add("e9");
- ls_elementname_dt.Columns.Add("e10");
- ls_elementname_dt.Columns.Add("e11");
- ls_elementname_dt.Columns.Add("e12");
- ls_elementname_dt.Columns.Add("e13");
- ls_elementname_dt.Columns.Add("e14");
- DataRow dr = ls_elementname_dt.NewRow();
- int col = 4;
- for (int i = 1; i < 15; i++)
- {
- if (ls_gv.Columns.Count > col)
- dr["e" + i.ToString()] = ls_gv.Columns[col++].Name;
- }
- ls_elementname_dt.Rows.Add(dr);
- DataTable ls_element_dt = new DataTable();
- ls_element_dt.TableName = "ElementValue";
- ls_element_dt.Columns.Add("e1");
- ls_element_dt.Columns.Add("e2");
- ls_element_dt.Columns.Add("e3");
- ls_element_dt.Columns.Add("e4");
- ls_element_dt.Columns.Add("e5");
- ls_element_dt.Columns.Add("e6");
- ls_element_dt.Columns.Add("e7");
- ls_element_dt.Columns.Add("e8");
- ls_element_dt.Columns.Add("e9");
- ls_element_dt.Columns.Add("e10");
- ls_element_dt.Columns.Add("e11");
- ls_element_dt.Columns.Add("e12");
- ls_element_dt.Columns.Add("e13");
- ls_element_dt.Columns.Add("e14");
- ls_element_dt.Columns.Add("PName");
- ls_element_dt.Columns.Add("Count");
- ls_element_dt.Columns.Add("AllElements");
- for (int i = 0; i < ls_gv.Rows.Count; i++)
- {
- DataRow dr2 = ls_element_dt.NewRow();
- dr2["PName"] = ls_gv.Rows[i].Cells[1].Value.ToString();
- dr2["Count"] = ls_gv.Rows[i].Cells[2].Value.ToString();
- int colq = 4;
- for (int j = 1; j < 15; j++)
- {
- if (ls_gv.Columns.Count > colq)
- dr2["e" + j.ToString()] = ls_gv.Rows[i].Cells[colq++].Tag.ToString();
- }
- colq = 4;
- string AllElements=null;
- for (int j = 0; j < ls_gv.Rows[i].Cells.Count; j++)
- {
- if (ls_gv.Columns.Count > colq)
- {
- AllElements = AllElements+ ls_gv.Columns[colq].Name + "%="+ ls_gv.Rows[i].Cells[colq++].Tag.ToString()+"; ";
- }
- }
- dr2["AllElements"] = AllElements;
- ls_element_dt.Rows.Add(dr2);
- }
-
- //把用户设置感兴趣的元素显示在前边
- for (int i=0;i< m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Count(); i++)
- {
- if (i > 13)
- continue;
- for (int a=0;a< ls_elementname_dt.Rows[0].ItemArray.Count(); a++)
- {
- if (m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]== ls_elementname_dt.Rows[0][a].ToString())
- {
- string str_elementname = "";
-
- str_elementname = ls_elementname_dt.Rows[0][i].ToString();
- ls_elementname_dt.Rows[0][i] = ls_elementname_dt.Rows[0][a];
- ls_elementname_dt.Rows[0][a] = str_elementname;
- for (int j=0;j< ls_element_dt.Rows.Count;j++)
- {
- string str_element = "0";
- str_element = ls_element_dt.Rows[j][i].ToString();
- ls_element_dt.Rows[j][i] = ls_element_dt.Rows[j][a];
- ls_element_dt.Rows[j][a] = str_element;
- }
-
- }
-
- }
- }
- m_list_dt.Add(ls_elementname_dt);
- m_list_dt.Add(ls_element_dt);
- List<string> elementColumn= m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys;
- return true;
- }
- catch (Exception ee)
- {
- m_otsreport_export.WriteRictBox(ee.ToString());
- return false;
- }
- }
- public bool InsertReportTemplateTable_ElementAvgGrid()
- {
- if (m_bt_DBData.Columns.Count == 0)
- {
- GetDBData();
- }
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
-
- DataTable AllAnalysisDetails = new DataTable();
- AllAnalysisDetails.TableName = "ElementValue";
- AllAnalysisDetails.Columns.Add("Name");
- AllAnalysisDetails.Columns.Add("TypeId");
- AllAnalysisDetails.Columns.Add("Area",typeof(double));
- AllAnalysisDetails.Columns.Add("Class");
- for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
- {
- DataRow dr2 = AllAnalysisDetails.NewRow();
- dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
- dr2["Area"] = Convert.ToDouble(m_bt_DBData.Rows[i]["ar"]);
- dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();
- dr2["Class"]= m_bt_DBData.Rows[i]["Class"].ToString();
- AllAnalysisDetails.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt= fielddata.GetAllClass();
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "NOT_INCLUTION")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //统计元素物质大类的元素信息和面积占比
- DataTable dt_ElementalSubstance= ElementalSubstance(AllAnalysisDetails, ClassName, fielddata);
- //统计元素并按照Class Name自定义列表进行排序,大类中的小类元素信息按照面积从大到小排序
- DataTable dt_ElementSorting= ElementSorting( AllAnalysisDetails, ClassName, fielddata);
- //生成最后导出时物质元素成分表
- DataTable dt= MaterialElementComposition(dt_ElementalSubstance,13);//导出14个元素成分信息
- //生成最后导出时物质元素细分表
- SubdivisionOfMaterialElements(dt_ElementSorting, 13, ClassName, dt);
- //夹杂物面积比添加大类
- DataTable RawParticleData = InclusionAreaRatio();
- //夹杂物面积比计算大类占比
- ProportionOfParticleArea(RawParticleData, ClassName);
- return true;
- }
- private bool ProportionOfParticleArea(DataTable dataTable, List<string> ClassName)
- {
-
- DataTable AllAnalysisDetails = dataTable.Copy();
- AllAnalysisDetails.Clear();
- AllAnalysisDetails.TableName = "InclusionAreaRatio";
- for (int i=0;i< ClassName.Count;i++)
- {
- DataTable dt = dataTable.Copy();
- dt.Clear();
- for (int a=0;a< dataTable.Rows.Count;a++)
- {
- if (dataTable.Rows[a]["e1"].ToString()== ClassName[i].ToString())
- {
- dt.Rows.Add(dataTable.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count>0)
- {
- double totalInclusionArea = Convert.ToDouble(decimal.Parse(dataTable.Compute("sum(e3)", "").ToString()));
- double Area= Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- DataRow dr = AllAnalysisDetails.NewRow();
- dr["e1"] = ClassName[i].ToString();
- dr["e3"] = Math.Round(Area, 2);
- //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- dr["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea) * 100, 2);
- dr["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(m_list_dt.Where(aa => aa.TableName.Contains("ResultGrid")).ToList()[0].Rows[0][5])) * 100, 4);
- AllAnalysisDetails.Rows.Add(dr);
- DataView dv = dt.DefaultView;
- dv.Sort = "e3 DESC";
- DataTable dt_Area = dv.ToTable();
- for (int a=0;a< dt_Area.Rows.Count;a++)
- {
- dt_Area.Rows[a]["e1"] = "";
- dt_Area.Rows[a]["e3"] = Math.Round(Convert.ToDouble(dt_Area.Rows[a]["e3"]), 2);
- AllAnalysisDetails.Rows.Add(dt_Area.Rows[a].ItemArray);
- }
- }
-
- }
- m_list_dt.Add(AllAnalysisDetails);
- return true;
- }
-
- private DataTable ElementSorting( DataTable AllAnalysisDetails, List<string> ClassName , ParticleData fielddata)
- {
- DataTable dte = fielddata.GetAllElement();
- DataTable ElementSorting_dt = AllAnalysisDetails.Copy();
- ElementSorting_dt.Clear();
- for (int i=0; i< ClassName.Count;i++)
- {
- DataTable dt = AllAnalysisDetails.Copy();
- dt.Clear();
- for (int a=0;a< AllAnalysisDetails.Rows.Count;a++)
- {
- if (AllAnalysisDetails.Rows[a]["Class"].ToString()== ClassName[i].ToString())
- {
- dt.Rows.Add(AllAnalysisDetails.Rows[a].ItemArray);
- }
- }
- //将颗粒大小排序(从大到小)
- DataView dv = dt.DefaultView;
- dv.Sort = "Area DESC";
- DataTable dt_Element = dv.ToTable();
- for (int a=0;a< dt_Element.Rows.Count;a++)
- {
- ElementSorting_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
- }
- }
- //循环创建元素列(类型定义为double,为以后计算做准备)
- for (int a = 0; a < dte.Rows.Count; a++)
- {
- ElementSorting_dt.Columns.Add(dte.Rows[a]["Name"].ToString(), typeof(double));
- }
- for (int a = 0; a < ElementSorting_dt.Rows.Count; a++)
- {
- DataTable ClassificationDetails = fielddata.GetAreaByIncA(ElementSorting_dt.Rows[a]["TypeId"].ToString(), "");//获取单个分类的元素信息
- //DataRow dr2 = ElementSorting_dt.NewRow();
- foreach (DataRow dr in ClassificationDetails.Rows)
- {
- double doe = Convert.ToDouble(dr["pc"]);
- ElementSorting_dt.Rows[a][dr["Name"].ToString()] = Math.Round( doe/Convert.ToDouble(ElementSorting_dt.Rows[a]["Area"]),2);
- }
- }
- return ElementSorting_dt;
- }
- private DataTable ElementalSubstance(DataTable AllAnalysisDetails, List<string> ClassName, ParticleData fielddata)
- {
- //当前元素物质类面积的总和
- double ElementalSubstance = 0;
- DataTable dte = fielddata.GetAllElement();
- DataTable dt_Class = new DataTable();
- dt_Class.Columns.Add("Name");
- dt_Class.Columns.Add("Area");
- //循环创建元素列(类型定义为double,为以后计算做准备)
- for (int a = 0; a < dte.Rows.Count; a++)
- {
- dt_Class.Columns.Add(dte.Rows[a]["Name"].ToString(), typeof(double));
- }
- //循环大类物质列表
- for (int i = 0; i < ClassName.Count; i++)
- {
- //保留当前循环中大类物质,去除其他物质
- DataTable dt = AllAnalysisDetails.Copy();
- dt.Clear();
- for (int a = 0; a < AllAnalysisDetails.Rows.Count; a++)
- {
- if (AllAnalysisDetails.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AllAnalysisDetails.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count == 0)
- continue;
- //计算出当前循环中大类物质的面积
- ElementalSubstance=Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
- DataTable ta = new DataTable();
- ta = dt_Class.Copy();
- ta.Clear();
-
- for (int a = 0; a < dt.Rows.Count; a++)
- {
- DataTable ClassificationDetails = fielddata.GetAreaByIncA(dt.Rows[a]["TypeId"].ToString(), "");//获取单个分类的元素信息
- DataRow dr2 = ta.NewRow();
-
- foreach (DataRow dr in ClassificationDetails.Rows)
- {
- double doe = Convert.ToDouble(dr["pc"]);
- dr2[dr["Name"].ToString()] = doe;
- }
- ta.Rows.Add(dr2);
- }
- DataTable dataTable = ta.Copy();
- dataTable.Clear();
- DataRow row = dataTable.NewRow();
- dataTable.Rows.Add(row);
- for (int a=0;a< ta.Columns.Count;a++)
- {
- if (ta.Columns[a].ToString()!="Name"&& ta.Columns[a].ToString() !="Class")
- {
- bool bl = false;
- for (int b=0;b<ta.Rows.Count;b++)
- {
- if (!ta.Rows[b].IsNull(ta.Columns[a].ToString()))
- {
- bl = true;
- }
- }
- if (bl)
- dataTable.Rows[0][ta.Columns[a].ToString()] = Math.Round( Convert.ToDouble(decimal.Parse(ta.Compute("sum(" + ta.Columns[a].ToString() + ")", "").ToString()))/ ElementalSubstance,2);
- }
- }
- dataTable.Rows[0]["Name"] = ClassName[i].ToString();
- dataTable.Rows[0]["Area"] = ElementalSubstance;
- dt_Class.Rows.Add(dataTable.Rows[0].ItemArray);
-
- }
- return dt_Class;
- }
- private DataTable MaterialElementComposition(DataTable a_ElementalSubstance,int NumberOfColumns)
- {
- DataTable dt_ElementalSubstance = new DataTable();
- dt_ElementalSubstance.TableName = "ElementalSubstance_Value";
- dt_ElementalSubstance.Columns.Add("Name");
- dt_ElementalSubstance.Columns.Add("Area");
- for (int i=0;i< a_ElementalSubstance.Rows.Count;i++)
- {
- dt_ElementalSubstance.Rows.Add(a_ElementalSubstance.Rows[i]["Name"]);
- dt_ElementalSubstance.Rows[i]["Area"]=Math.Round(Convert.ToDouble(a_ElementalSubstance.Rows[i]["Area"]),2) ;
- }
- int cunt = 1;
- for (int i=0;i< NumberOfColumns; i++)
- {
-
- if (i< m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Count())
- {
- dt_ElementalSubstance.Columns.Add(m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]);
- for (int a=0;a< a_ElementalSubstance.Rows.Count;a++)
- {
- if (a_ElementalSubstance.Columns.Contains(m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]))
- {
- if (a_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]].ToString() == "")
- {
- dt_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]] = 0;
- }
- else
- {
- dt_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]] = a_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]];
- }
- }
- else
- {
- dt_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]] = 0;
- }
- }
- }
- else
- {
- dt_ElementalSubstance.Columns.Add("Null"+ cunt.ToString());
- cunt = cunt + 1;
- for (int a = 0; a < a_ElementalSubstance.Rows.Count; a++)
- {
- dt_ElementalSubstance.Rows[a][i+2] = "-";
- }
- }
- }
- DataTable dataTable = new DataTable();
- dataTable = dt_ElementalSubstance.Copy();
- dataTable.Clear();
- DataRow row = dataTable.NewRow();
- dataTable.Rows.Add(row);
- dataTable.TableName = "ElementalSubstance_Name";
- for (int i=0;i< dataTable.Columns.Count;i++)
- {
- dataTable.Rows[0][dataTable.Columns[i].ToString()] = dataTable.Columns[i].ToString();
- }
- m_list_dt.Add(dataTable);
- m_list_dt.Add(dt_ElementalSubstance);
- return dt_ElementalSubstance;
- }
- private bool SubdivisionOfMaterialElements(DataTable a_ElementalSubstance, int NumberOfColumns, List<string> ClassName,DataTable data)
- {
- DataTable dt_ElementalSubstance = new DataTable();
- dt_ElementalSubstance= data.Copy();
- dt_ElementalSubstance.Clear();
- dt_ElementalSubstance.TableName = "ElementSubdivision_Value";
- dt_ElementalSubstance.Columns["Name"].ColumnName = "Class";
- dt_ElementalSubstance.Columns.Add("Name");
- //处理元素面积保留小数点后两位
- for (int i=0;i< a_ElementalSubstance.Rows.Count;i++)
- {
- a_ElementalSubstance.Rows[i]["Area"] = Math.Round(Convert.ToDouble(a_ElementalSubstance.Rows[i]["Area"].ToString()), 2);
- }
- //循环元素物质大类
- for (int i = 0; i < ClassName.Count; i++)
- {
- DataTable dt_1 = new DataTable();
- dt_1 = data.Copy();
- dt_1.Clear();
- for (int a = 0; a < data.Rows.Count; a++)
- {
- if (data.Rows[a]["Name"].ToString() == ClassName[i].ToString())
- {
- dt_1.Rows.Add(data.Rows[a].ItemArray);
- }
- }
- dt_1.Columns["Name"].ColumnName = "Class";
- dt_1.Columns.Add("Name");
- DataTable dt_2 = new DataTable();
- dt_2 = dt_1.Copy();
- dt_2.Clear();
- dt_2.Rows.Add();
- //循环整个表筛选出当前的物质
- for (int a = 0; a < a_ElementalSubstance.Rows.Count; a++)
- {
- if (ClassName[i].ToString() == a_ElementalSubstance.Rows[a]["Class"].ToString())
- {
- for (int b=0;b< dt_1.Columns.Count;b++)
- {
- if (dt_2.Columns[b].ToString()!="Class")
- {
- if (a_ElementalSubstance.Columns.Contains(dt_2.Columns[b].ToString()))
- {
- if (a_ElementalSubstance.Rows[a][dt_2.Columns[b].ToString()].ToString() == "")
- {
- dt_2.Rows[0][dt_2.Columns[b].ToString()] = 0;
- }
- else
- {
- dt_2.Rows[0][dt_2.Columns[b].ToString()] = a_ElementalSubstance.Rows[a][dt_2.Columns[b].ToString()];
- }
- }
- else
- {
- dt_2.Rows[0][dt_2.Columns[b].ToString()] = 0;
- }
-
- }
- }
- dt_1.Rows.Add(dt_2.Rows[0].ItemArray);
- }
- }
- for (int a=0;a< dt_1.Rows.Count;a++)
- {
- dt_ElementalSubstance.Rows.Add(dt_1.Rows[a].ItemArray);
- }
- }
- DataTable dataTable = new DataTable();
- dataTable = dt_ElementalSubstance.Copy();
- dataTable.Clear();
- DataRow row = dataTable.NewRow();
- dataTable.Rows.Add(row);
- dataTable.TableName = "ElementSubdivision_Name";
- for (int i = 0; i < dataTable.Columns.Count; i++)
- {
- dataTable.Rows[0][dataTable.Columns[i].ToString()] = dataTable.Columns[i].ToString();
- }
- m_list_dt.Add(dataTable);
- m_list_dt.Add(dt_ElementalSubstance);
- return true;
- }
- #endregion
- private DataTable InclusionAreaRatio()
- {
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
- DataTable AreaInformationOfAllElements = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- DataTable AllAnalysisDetails = new DataTable();
- //AllAnalysisDetails.TableName = "ElementValue";
- 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++)
- {
- //if (Convert.ToInt32(AreaInformationOfAllElements.Rows[i]["TypeId"]) < 100)
- // continue;
- 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<string> ClassName = new List<string>();
- DataTable getClass_dt = fielddata.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");
- //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
- double totalInclusionArea = 0;
- //for (int i = 0; i < ls_gv.Rows.Count - 1; i++)
- //{
- // totalInclusionArea = totalInclusionArea + Convert.ToDouble(ls_gv.Rows[i].Cells[2].Value.ToString());
- //}
- totalInclusionArea= Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
- for (int i=0;i< AllAnalysisDetails.Rows.Count;i++)
- {
- DataRow dr = AreaRatio.NewRow();
- dr["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
- dr["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
- dr["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
- dr["e4"]= Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
- dr["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(m_list_dt.Where(aa => aa.TableName.Contains("ResultGrid")).ToList()[0].Rows[0][5])) * 100, 4);
- AreaRatio.Rows.Add(dr);
- }
- 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);
- }
- }
- return AreaRatio_dt;
- //m_list_dt.Add(AreaRatio_dt);
- }
- #region 插入颗粒图chart
- /// <summary>
- /// 用于颗粒图chart
- /// </summary>
- /// <returns></returns>
- private DataTable GetPicDataTable_PicKL()
- {
- if (m_list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList().Count == 0)
- {
- //创建二进制列的数据表
- DataTable ls_dt = new DataTable();
- ls_dt.TableName = "PicKL";
- DataColumn colpict = new DataColumn("pict");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict);
- m_list_dt.Add(ls_dt);
- return ls_dt;
- }
- else
- {
- return m_list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList()[0];
- }
- }
- #endregion
- private DataTable GetPicDataTable_InclusionAreaRatio(string str)
- {
- if (m_list_dt.Where(aa => aa.TableName.Contains(str)).ToList().Count == 0)
- {
- //创建二进制列的数据表
- DataTable ls_dt = new DataTable();
- ls_dt.TableName = str;
- DataColumn colpict = new DataColumn("pict");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict);
- m_list_dt.Add(ls_dt);
- return ls_dt;
- }
- else
- {
- return m_list_dt.Where(aa => aa.TableName.Contains(str)).ToList()[0];
- }
- }
- #region 插入元素图chart
- /// <summary>
- /// 用于元素图chart
- /// </summary>
- /// <returns></returns>
- private DataTable GetPicDataTable_PicYS()
- {
- if (m_list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList().Count == 0)
- {
- //创建二进制列的数据表
- DataTable ls_dt = new DataTable();
- ls_dt.TableName = "PicYS";
- DataColumn colpict = new DataColumn("pict");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict);
- m_list_dt.Add(ls_dt);
- return ls_dt;
- }
- else
- {
- return m_list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList()[0];
- }
- }
- #endregion
- #region 插入大分类夹杂物面积比图
- public bool InsertReportTemplateChart_InclusionAreaClassRatio(string a_GraphicStyle)
- {
- //加载模块
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "InclusionareaClassRatio");
- m_otsreport_export.m_ReportApp.m_reportname = "";
- m_otsreport_export.m_ReportApp.type = a_GraphicStyle;
- m_otsreport_export.m_ReportApp.timerKG = true;
- m_otsreport_export.m_ReportApp.m_ChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);
- //弹出加载图片窗体
- OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();
- //将EChart委托事件注册给加载图片窗体的方法
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;
- og.ShowDialog();
- //获取图片数据
- string str = og.PicStr;
- //将Base64String转为图片并保存
- byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
- MemoryStream ms = new MemoryStream(arr);
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
- //再将图转成流,流再转二进制-------------------------------------------
- MemoryStream newms = new MemoryStream();
- bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);
- newms.Seek(0, SeekOrigin.Begin);
- byte[] newarr = new byte[newms.Length];
- newms.Read(newarr, 0, newarr.Length);
- newms.Dispose();
- DataTable ls_dt = GetPicDataTable_InclusionAreaRatio("Pic_InclusionareaClassRatio");
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = newarr;//图像二进制
- ls_dt.Rows.Add(dr);
- return true;
- }
- #endregion
- #region 插入夹杂物面积比图
- public bool InsertReportTemplateChart_InclusionAreaRatio(string a_GraphicStyle)
- {
- //加载模块
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "InclusionareaRatio");
- m_otsreport_export.m_ReportApp.m_reportname = "";
- m_otsreport_export.m_ReportApp.type = a_GraphicStyle;
- m_otsreport_export.m_ReportApp.timerKG = true;
- m_otsreport_export.m_ReportApp.m_ChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);
- //弹出加载图片窗体
- OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();
- //将EChart委托事件注册给加载图片窗体的方法
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;
- og.ShowDialog();
- //获取图片数据
- string str = og.PicStr;
- //将Base64String转为图片并保存
- byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
- MemoryStream ms = new MemoryStream(arr);
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
- //再将图转成流,流再转二进制-------------------------------------------
- MemoryStream newms = new MemoryStream();
- bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);
- newms.Seek(0, SeekOrigin.Begin);
- byte[] newarr = new byte[newms.Length];
- newms.Read(newarr, 0, newarr.Length);
- newms.Dispose();
- DataTable ls_dt = GetPicDataTable_InclusionAreaRatio("Pic_InclusionAreaRatio");
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = newarr;//图像二进制
- ls_dt.Rows.Add(dr);
- return true;
- }
- #endregion
- #region 插入颗粒成份图
- /// <summary>
- /// 向 模板设计器 中插入 颗粒成份图
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateChart_ParticlesCompositionChart(string a_GraphicStyle)
- {
- try
- {
- //-----------------------------------颗粒成份图-----------------------------------------------------------------------------------------------
- //加载模块
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "PComponent");
- m_otsreport_export.m_ReportApp.m_reportname = "InclusionClassification";
- m_otsreport_export.m_ReportApp.type = a_GraphicStyle;
- m_otsreport_export.m_ReportApp.timerKG = true;
- m_otsreport_export.m_ReportApp.m_ChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);
- //弹出加载图片窗体
- OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();
- //将EChart委托事件注册给加载图片窗体的方法
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;
- og.ShowDialog();
- //获取图片数据
- string str = og.PicStr;
- //将Base64String转为图片并保存
- byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
- MemoryStream ms = new MemoryStream(arr);
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
- //再将图转成流,流再转二进制-------------------------------------------
- MemoryStream newms = new MemoryStream();
- bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);
- newms.Seek(0, SeekOrigin.Begin);
- byte[] newarr = new byte[newms.Length];
- newms.Read(newarr, 0, newarr.Length);
- newms.Dispose();
- //创建二进制列的数据表
- DataTable ls_dt = GetPicDataTable_PicKL();
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = newarr;//图像二进制
- ls_dt.Rows.Add(dr);
- return true;
- }
- catch (Exception ee)
- {
- m_otsreport_export.WriteRictBox(ee.ToString());
- return false;
- }
- }
- #endregion
- #region 插入元素成份图
- /// <summary>
- /// 向 模板设计器 中插入 元素成份图
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateChart_ElementCompositionChart(string a_GraphicStyle)
- {
- try
- {
- //-----------------------------------元素成份图-----------------------------------------------------------------------------------------------
- //加载模块
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "EComponent");
- m_otsreport_export.m_ReportApp.m_reportname = "ElementComposition";
- m_otsreport_export.m_ReportApp.type = a_GraphicStyle;
- m_otsreport_export.m_ReportApp.timerKG = true;
- m_otsreport_export.m_ReportApp.m_ChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);
- //弹出加载图片窗体
- OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();
- //将EChart委托事件注册给加载图片窗体的方法
- m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;
- og.ShowDialog();
- //获取图片数据
- string str = og.PicStr;
- //将Base64String转为图片并保存
- byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
- MemoryStream ms = new MemoryStream(arr);
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
- //再将图转成流,流再转二进制-------------------------------------------
- MemoryStream newms = new MemoryStream();
- bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);
- newms.Seek(0, SeekOrigin.Begin);
- byte[] newarr = new byte[newms.Length];
- newms.Read(newarr, 0, newarr.Length);
- newms.Dispose();
- //创建二进制列的数据表
- DataTable ls_dt = GetPicDataTable_PicYS();
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = newarr;//图像二进制
- ls_dt.Rows.Add(dr);
- return true;
- }
- catch (Exception ee)
- {
- m_otsreport_export.WriteRictBox(ee.ToString());
- return false;
- }
- }
- #endregion
- #region 插入三元相图
- /// <summary>
- /// 获取或创建pic表格,用于三元相图
- /// </summary>
- /// <returns></returns>
- private DataTable GetPicDataTable_PicSYXT2T()
- {
- if (m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList().Count == 0)
- {
- //创建二进制列的数据表
- DataTable ls_dt = new DataTable();
- ls_dt.TableName = "PicSYXT2T";
- DataColumn colpict = new DataColumn("pict");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict);
- DataColumn colpict2 = new DataColumn("pict2");
- colpict2.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict2);
- m_list_dt.Add(ls_dt);
- return ls_dt;
- }
- else
- {
- return m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList()[0];
- }
- }
- /// <summary>
- /// 获取或创建pic表格,用于三元相图,3个列的
- /// </summary>
- /// <returns></returns>
- private DataTable GetPicDataTable_PicSYXT3T()
- {
- if (m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT3T")).ToList().Count == 0)
- {
- //创建二进制列的数据表
- DataTable ls_dt = new DataTable();
- ls_dt.TableName = "PicSYXT3T";
- DataColumn colpict = new DataColumn("pict");
- colpict.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict);
- DataColumn colpict2 = new DataColumn("pict2");
- colpict2.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict2);
- DataColumn colpict3 = new DataColumn("pict3");
- colpict3.DataType = System.Type.GetType("System.Byte[]");
- ls_dt.Columns.Add(colpict3);
- m_list_dt.Add(ls_dt);
- return ls_dt;
- }
- else
- {
- return m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT")).ToList()[0];
- }
- }
- /// <summary>
- /// 获取三元相图二进制数据
- /// </summary>
- /// <param name="selectindex"></param>
- /// <returns></returns>
- private byte[] GetByte_InsertReportTemplateChart_Trianglediagram(int selectindex)
- {
- byte[] newarr = new byte[0];
- //加载模块
- m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram = new EChart_Trianglediagram(m_otsreport_export.m_ReportApp, TemplateList[selectindex]);
- m_otsreport_export.m_ReportApp.timerKG = true;
- m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram.condition = m_otsreport_export.m_mbszclass.M_SYXT.index_cb_syxt_jsfs;
- m_otsreport_export.m_ReportApp.m_ChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram);
- //ls_echart_trianglediagram.
- //弹出加载图片窗体
- OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();
- //将EChart委托事件注册给加载图片窗体的方法
- m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram.butclic += og.get_ParticalesCompositionChart;
- og.ShowDialog();
- //获取图片数据
- string str = og.PicStr;
- //将Base64String转为图片并保存
- byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));
- MemoryStream ms = new MemoryStream(arr);
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
- //再将图转成流,流再转二进制-------------------------------------------
- MemoryStream newms = new MemoryStream();
- bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);
- newms.Seek(0, SeekOrigin.Begin);
- newarr = new byte[newms.Length];
- newms.Read(newarr, 0, newarr.Length);
- newms.Dispose();
- return newarr;
- }
- /// <summary>
- /// 向 模板设计器 中插入 三元相图
- /// </summary>
- /// <returns></returns>
- public bool InsertReportTemplateChart_Trianglediagram()
- {
- try
- {
- //创建二进制列的数据表,循环插入三元选择的模板
- DataTable ls_dt = GetPicDataTable_PicSYXT2T();
- DataTable ls_dt3t = GetPicDataTable_PicSYXT3T();
- //这里要校验一下,总数必须要是2的整倍数,不可有余数
- if (m_otsreport_export.m_mbszclass.M_SYXT.str_cb_syxt_mhxssl == "2" && m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count % 2 == 0)
- {
- for (int i = 0; i < m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count; i = i + 2)
- {
- byte[] newarr, newarr2;
- newarr = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);
- newarr2 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 1]);
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = newarr;//图像二进制
- dr["pict2"] = newarr2;//图像二进制
- ls_dt.Rows.Add(dr);
- }
- }
- else
- {
- DataRow dr = ls_dt.NewRow();
- dr["pict"] = null;//图像二进制
- dr["pict2"] = null;//图像二进制
- ls_dt.Rows.Add(dr);
- }
- if (m_otsreport_export.m_mbszclass.M_SYXT.str_cb_syxt_mhxssl == "3" && m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count % 3 == 0)
- {
- for (int i = 0; i < m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count; i = i + 3)
- {
- byte[] newarr, newarr2, newarr3;
- newarr = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);
- newarr2 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 1]);
- newarr3 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 2]);
- DataRow dr = ls_dt3t.NewRow();
- dr["pict"] = newarr;//图像二进制
- dr["pict2"] = newarr2;//图像二进制
- dr["pict3"] = newarr3;//图像二进制
- ls_dt3t.Rows.Add(dr);
- }
- }
- else
- {
- DataRow dr = ls_dt3t.NewRow();
- dr["pict"] = null;//图像二进制
- dr["pict2"] = null;//图像二进制
- dr["pict3"] = null;//图像二进制
- ls_dt3t.Rows.Add(dr);
- }
- return true;
- }
- catch (Exception ee)
- {
- m_otsreport_export.WriteRictBox(ee.ToString());
- return false;
- }
- }
- #endregion
- #region 其它部份
-
- /// <summary>
- /// 输入颗粒的所在帧图id,颗粒id,颗粒类型id,获取对应的XRay能谱数据图
- /// </summary>
- /// <returns></returns>
- public Bitmap ExportXRayBitmap(string in_fieldid, string in_particleid, int in_stdtypeid, string TypeName, ParticleData particleData)
- {
- Bitmap ret_bp;
- //显示xray相关信息
- uint[] Search_xray = new uint[2000];
- uint[] Analysis_xray = new uint[2000];
- //
- int i_xray_id = 0;
- List<Element> list_celementchemistryclr = new List<Element>();
- //获取Xray数据
- list_celementchemistryclr = new List<Element>();
- Particle list = particleData.GetParticleByFidAndPid(in_fieldid, in_particleid);
- if (list == null)
- {
- return null;
- }
- Particle particle = list;
- if (particle.XrayId > -1)
- {
- for (int i = 0; i < 2000; i++)
- {
- if (particle.XRayData!=null)
- {
- Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
- }
-
- }
- Search_xray = Analysis_xray;
- i_xray_id = particle.XrayId;
- list_celementchemistryclr = particle.ElementList;
- }
- //get CElementChemistryClr list
- List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
- for (int i = 0; i < list_celementchemistryclr.Count; i++)
- {
- ShowElementInfo ls_sei = new ShowElementInfo();
- ls_sei.ElementName = list_celementchemistryclr[i].Name;
- ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
- ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByYsm(CListPeriodic.GetListPeriodic(), ls_sei.ElementName).SX1);
- list_showelementinfo.Add(ls_sei);
- }
- //获取使用标准库的名称
- string str_stdname = "";
- string str_IncALibName = "";
- if (in_stdtypeid < 1000)
- {
- //小于1000,使用系统默认分类
- str_IncALibName = TypeName;
- str_stdname = "Default standard library";
- }
- else if (in_stdtypeid >= 1000 && in_stdtypeid < 10000)
- {
- //大于等于1000,并且小于10000时,使用系统数据库中夹杂物来分析
- str_IncALibName = TypeName;
- str_stdname = "User defined standard library";
- }
- else if (in_stdtypeid > 10000)
- {
- //大于10000时,使用用户标准库来分析夹杂物名称
- str_IncALibName = TypeName;
- str_stdname = "System standard library";
- }
- //获取数据后,需要对xraytable设置
- OTSIncAReportGraph.Controls.Control_XRayTable control_XRayTable1 = new Control_XRayTable();
- control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);
- //颗粒国标信息
- //control_XRayTable1.GBInfoStr = in_dparticle.GBContent;
- control_XRayTable1.MaterialName = str_IncALibName;//杂夹物
- control_XRayTable1.STDName = str_stdname;//标准库
- control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
- control_XRayTable1.Visible = true;
- control_XRayTable1.Invalidate();
- control_XRayTable1.Refresh();
- ret_bp = control_XRayTable1.ExportXRayImage();
- return ret_bp;
- }
-
- /// <summary>
- /// 传入DataTable,和行号,返回该Row行中,返回6个靠前的元素,不足6个返回空
- /// </summary>
- /// <param name="in_dt"></param>
- /// <param name="row_index"></param>
- /// <returns></returns>
- private void GetMaxElementFromDataTable(DataTable in_dt, int row_index, out List<string> out_list_elementname, out List<double> out_list_elementvalue)
- {
- out_list_elementname = new List<string>();
- out_list_elementvalue = new List<double>();
- //分别排出元素名,元素值列表
- List<string> list_elementname = new List<string>();
- List<double> list_elementvalue = new List<double>();
- string str_element = in_dt.Rows[row_index]["Element"].ToString();
- //防止取出的元素信息为空
- if (str_element != "")
- {
- string[] strcbo = str_element.Split(';');
- for (int i = 0; i < strcbo.Length-1; i++)
- {
- string[] str = strcbo[i].Split('-');
- list_elementname.Add(str[0]);
- list_elementvalue.Add(Math.Round(Convert.ToDouble(str[1]), 2));
- }
- }
- //循环6次,得到最大的6个元素信息
- for (int geti = 0; geti < 6; geti++)
- {
- double max_elementvalue = -1;
- string max_elementname = "";
- int max_index = -1;
- if (list_elementvalue.Count > 0)
- {
- for (int i = 0; i < list_elementvalue.Count; i++)
- {
- if (list_elementvalue[i] > max_elementvalue)
- {
- max_elementvalue = list_elementvalue[i];
- max_elementname = list_elementname[i];
- max_index = i;
- }
- }
- //移除掉最大的元素
- list_elementname.RemoveAt(max_index);
- list_elementvalue.RemoveAt(max_index);
- //将最大的元素添加到list中
- if (max_elementvalue > 0)
- {
- out_list_elementname.Add(max_elementname);
- out_list_elementvalue.Add(max_elementvalue);
- }
- else
- {
- out_list_elementname.Add(" ");
- out_list_elementvalue.Add(0);
- }
- }
- else
- {
- //如果元素数量已经不够,则添加空
- out_list_elementname.Add(" ");
- out_list_elementvalue.Add(0);
- }
- }
- }
- #endregion
- /// <summary>
- /// 国标一
- /// </summary>
- /// <returns></returns>
- public List<DataTable> InsertReportTemplateTable_ChineseStandardABCDDS(OTSCLRINTERFACE.CPropParamClr cPropParamClr)
- {
- //得到国标一的DataTable表格
-
- cPropParamClr.SetDataSourceId(0);//
- cPropParamClr.SetType(1);//table
- cPropParamClr.SetCalTableType(6);//国标1
- List<OTSCLRINTERFACE.CGridDataClr> listGriddataclr = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GridDataTransfer(cPropParamClr);
- m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS = new OTSIncAReportGB.ChineseStandardABCDDS(m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr, listGriddataclr);
- m_otsreport_export.m_ReportApp.m_TablesWindow.Controls.Clear();
- //List<DataTable> GB_1 = m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS.ChineseStandardABCD_GetDataTable();
- //string s = GB_1[0].Rows[0][0].ToString();
- return m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS.ChineseStandardABCD_GetDataTable(); ;
- }
- /// <summary>
- /// 国标二
- /// </summary>
- /// <returns></returns>
- public List<DataTable> InsertReportTemplateTable_NationalStandardMethodTwo(OTSCLRINTERFACE.CPropParamClr cPropParamClr)
- {
- //得到国标二的DataTable表格
-
- cPropParamClr.SetDataSourceId(0);//
- cPropParamClr.SetType(1);//table
- cPropParamClr.SetCalTableType(7);//国标2
- List<OTSCLRINTERFACE.CGridDataClr> listGriddataclr2 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GridDataTransfer(cPropParamClr);//
- m_otsreport_export.m_ReportApp.m_TablesWindow.Controls.Clear();
- m_otsreport_export.m_ReportApp.im_NationalStandardMethodTwo = new OTSIncAReportGB.NationalStandardMethodTwo(m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr, listGriddataclr2);
- return m_otsreport_export.m_ReportApp.im_NationalStandardMethodTwo.ChineseStandardABCD_GetDataTable();
- }
- }
- }
|