12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891 |
- using OTSIncAReportApp._1_UI;
- using OTSIncAReportApp.Control_ECharts;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSCommon.Model;
- using OTSIncAReportGraph.Controls;
- using OTSIncAReportGrids;
- using OTSRptPeriodicTable;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- using System.Xml;
- using static OTSIncAReportApp.OTSReport_Export;
- using OTSIncAReportApp.ReportTemplate;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSPeriodicTable;
- namespace OTSIncAReportApp.OTSTemplateDesigner
- {
- public class Export_ReportTemplate
- {
- #region 全局变量
- public List<DataTable> m_list_dt; //导出的各模块数据,合集
- public OTSReport_Export m_otsreport_export;
- UserLibraryData userLibrary;
- DataTable userLibraryData;
- DataTable m_bt_DBData = new DataTable();
- /// <summary>
- /// 三元图列表
- /// </summary>
- List<string> TemplateList;
- frmReportConditionChoose m_condition;
- public int condition = -1;
- #endregion
- #region 构造函数
- public Export_ReportTemplate(OTSReport_Export in_export)
- {
- m_otsreport_export = in_export;
- TemplateList = new List<string>();
- m_condition = in_export.m_ReportApp.m_conditionChoose;
- //加载三元相图各项
- string pathtpf = in_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.TrigTemplateFileFolder + "\\" + 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_Report();
- //------------------加载模块,获取数据结束----------------------------------------------
- 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 Magnification = "";
- 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);//视场面积
- keyValues_ResultGrid.TryGetValue("Magnification", out Magnification);//放大倍数
- //将获取到的数据转换成报告模板能接收的格式。
- 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"); //参考标准
- ls_new_dt.Columns.Add("FDBS");
- //行转列,这里不会发生改变,所以这样写
- 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;
- dr["FDBS"] = Magnification;
- ls_new_dt.Rows.Add(dr);
- m_list_dt.Add(ls_new_dt);
- return ls_new_dt;
-
- }
- #endregion
- #region 读取选择颗粒数据
- private void SelectParticleData(out DataTable dt)
- {
- List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
-
- #region Datatable数据表格式
- DataTable dtUelect = new DataTable();
- dtUelect.Columns.Add("fieldid");
- dtUelect.Columns.Add("particleid");
- dtUelect.Columns.Add("AveGray");
- dtUelect.Columns.Add("RectLeft");
- dtUelect.Columns.Add("RectTop");
- dtUelect.Columns.Add("RectWidth");
- dtUelect.Columns.Add("RectHeight");
- dtUelect.Columns.Add("Area");
- dtUelect.Columns.Add("PosX");
- dtUelect.Columns.Add("PosY");
- dtUelect.Columns.Add("TypeId");
- dtUelect.Columns.Add("SegmentNum");
- dtUelect.Columns.Add("SEMPosX");
- dtUelect.Columns.Add("SEMPosY");
- dtUelect.Columns.Add("XrayId");
- dtUelect.Columns.Add("DMAX");
- dtUelect.Columns.Add("DMIN");
- dtUelect.Columns.Add("DPERP");
- dtUelect.Columns.Add("PERIMETER");
- dtUelect.Columns.Add("ORIENTATION");
- dtUelect.Columns.Add("DINSCR");
- dtUelect.Columns.Add("DMEAN");
- dtUelect.Columns.Add("DELONG");
- dtUelect.Columns.Add("DFERET");
- dtUelect.Columns.Add("TypeName");
- dtUelect.Columns.Add("TypeColor");
-
- #endregion
- for (int i = 0; i < selectParticles.Count; i++)
- {
- dtUelect.Rows.Add(selectParticles[i].FieldId, selectParticles[i].ParticleId, selectParticles[i].AveGray, selectParticles[i].RectLeft, selectParticles[i].RectTop, selectParticles[i].RectWidth, selectParticles[i].RectHeight, selectParticles[i].Area, selectParticles[i].PosX, selectParticles[i].PosX, selectParticles[i].TypeId, /*selectParticles[i].ElementNum,*/ selectParticles[i].SegmentNum, selectParticles[i].SEMPosX, selectParticles[i].SEMPosY, selectParticles[i].ParticleId, selectParticles[i].DMAX, selectParticles[i].DMIN, selectParticles[i].DPERP, selectParticles[i].PERIMETER, selectParticles[i].ORIENTATION, selectParticles[i].DINSCR, selectParticles[i].DMEAN, selectParticles[i].DELONG, selectParticles[i].DFERET, selectParticles[i].TypeName, selectParticles[i].TypeColor);
- }
- dt = dtUelect.Copy();
- }
- #endregion
- #region 读取标准库所需要的数据
- private bool GetSTL(string str ,out DataTable data)
- {
- if (str.ToLower() == "nostddb")
- {
- data = null;
- return false;
- }
- DataTable dt = new DataTable();
- dt.Columns.Add("TypeId");
- dt.Columns.Add("Hardness", typeof(double));
- dt.Columns.Add("Hardness_detailed");
-
-
- OTSCommon.SqLiteHelper sh = null;
- string fullPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.CurResultFile.FilePath + "\\" + str + ".db";
- string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + str + ".db";
- if (System.IO.File.Exists(fullPath))
- {
- sh = new OTSCommon.SqLiteHelper ("data source='" + fullPath + "'");
- }
- else if (System.IO.File.Exists(fullPath2))
- {
- sh = new OTSCommon.SqLiteHelper("data source='" + fullPath2 + "'");
- }
- else
- {
- sh = null;
- data = null;
- return false;
- }
- DataTable dt_stl= sh.ExecuteQuery("select * from ClassifySTD");
- for (int i=0;i< dt_stl.Rows.Count;i++)
- {
- DataRow dr = dt.NewRow();
- dr["TypeId"] = dt_stl.Rows[i]["StrName"].ToString();
- dr["Hardness_detailed"] = dt_stl.Rows[i]["Hardness"].ToString();
- if (System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", "").ToString()!="")
- {
-
- if (System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", "")== "o. Def.")
- {
- dr["Hardness"] = 0;
- }
- else
- {
- dr["Hardness"] = Convert.ToDouble(System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", ""));
- }
-
- }else
- {
- dr["Hardness"] = 0;
- }
- dt.Rows.Add(dr);
- }
- data = dt;
- return true;
- }
- public bool GetDBData(c_TemplateClass m_mbszclass)
- {
- //GetSTL();
-
- 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.getSelectedIndex()].FilePath);
- List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + 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 =InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""), "TypeName");
- DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""), "TypeName");
- DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""), "GroupName");
- //选择颗粒信息
- DataTable data;
- SelectParticleData(out data);
- //选择颗粒整理成表
- DataTable Partic_dt = new DataTable();
- if (data.Rows.Count >0)
- {
- Partic_dt = GetParticleListForParticlSize(data, dtp);
- }
-
-
- List<string> vs = new List<string>() { "DMAX", "DMIN", "FERET", "Area" };
- string po = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs];
- switch (po)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- //如果是全部颗粒(0)
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- 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);
- }
- }
- else//选择颗粒(1)
- {
- for (int i = 0; i < Partic_dt.Rows.Count; i++)
- {
- DataRow dr = m_bt_DBData.NewRow();
- dr["TypeName"] = Partic_dt.Rows[i]["TypeName"].ToString();
- dr["TypeId"] = Partic_dt.Rows[i]["TypeId"].ToString();
- dr["con"] = Partic_dt.Rows[i]["con"].ToString();
- dr["Class"] = Partic_dt.Rows[i]["GroupName"].ToString();
- dr["Largest"] = Math.Round(Convert.ToDouble(Partic_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, Partic_dt.Rows[i]["TypeId"].ToString()));
- dr[colid[a]] = datas.Count();
- }
- dr["ar"] = Partic_dt.Rows[i]["Area"];
- m_bt_DBData.Rows.Add(dr);
- }
- }
-
- return true;
- }
- 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("ar");
- dt_Partick.Columns.Add("max");
- dt_Partick.Columns.Add("Area",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["Area"] = 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["ar"] = dt.Compute("min(Area)", "");
- dr["max"] = dt.Compute("Max(Area)", "");
- dr["Area"] = dt.Compute("SUM(Area)", "");
- 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 InvalidRemoval(DataTable dt ,string str)
- {
- DataTable dataTable = dt.Copy();
- dataTable.Clear();
- for (int i=0;i<dt.Rows.Count;i++)
- {
- if (dt.Rows[i][str].ToString() != "Invalid" && dt.Rows[i][str].ToString()!= "Not Identified" && dt.Rows[i][str].ToString()!= "NOT_INCLUTION")
- {
- dataTable.Rows.Add(dt.Rows[i].ItemArray);
- }
-
- }
- return dataTable;
- }
-
- private string getWhere(string max, string min, string col, string partic)
- {
- return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
- }
- #endregion
- #region 插入颗粒列表并带有帧图
- private string datatable_data(DataTable dt,int it,string str)
- {
- if (str == "Hardness")
- {
- return dt.Rows[it]["Hardness_detailed"].ToString();
- }
- else
- if (str == "Area")
- {
- return Convert.ToDouble(dt.Rows[it][str]).ToString("#0.00");
-
- }
- else
- if (str== "DMAX")
- {
- return Math.Round(Convert.ToDouble(dt.Rows[it][str]), 2).ToString();
- }
- else
- {
- return dt.Rows[it][str].ToString();
- }
- }
- 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;
- }
- #endregion
- #region 插入颗粒尺寸表
- 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;
- }
- #endregion
- #region 插入平均元素含量表
- 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)
- //datatSuncolumn(ta, ta.Columns[a].ToString());
- dataTable.Rows[0][ta.Columns[a].ToString()] = Math.Round(datatSuncolumn(ta, ta.Columns[a].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 double datatSuncolumn(DataTable dt ,string str)
- {
- double sum=0;
- for (int i=0;i<dt.Rows.Count;i++)
- {
- if (dt.Rows[i][str].ToString()=="")
- {
- dt.Rows[i][str] = 0;
- }
- sum = sum+Convert.ToDouble(dt.Rows[i][str].ToString());
- }
- return sum;
- }
- 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;
- }
- #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.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
- 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 < 11; 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, List<string> datasourcelist , int DataSourceId ,int GB_index)
- {
- //得到国标一的DataTable表格
- cPropParamClr.SetDataSourceList(datasourcelist);
- cPropParamClr.SetDataSourceId(DataSourceId);//
- cPropParamClr.SetType((int)OTSSampleReportInfo.DisplayPicutureType.AnalyzeDataTable);//table
- cPropParamClr.SetCalTableType(GB_index);//国标1
- if (GB_index == (int)OTSSampleReportInfo.CALCULATE_TABLE_TYPE.GB_Method1)
- {
- 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();
- return m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS.ChineseStandardABCD_GetDataTable(); ;
- }
- else
- {
- 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();
- }
-
- }
-
- //-------------------------------------------------dev----------------------------------------------------------
- /// <summary>
- /// DEV颗粒列表颗粒前20个谱图排序
- /// </summary>
- /// <param name="m_mbszclass"></param>
- /// <returns></returns>
- public DataTable Get_dev_kllb_data(c_TemplateClass m_mbszclass)
- {
- int serialNumber = 1;
- //------------------加载模块,获取数据-------------------------------------------------
- m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
- DataTable SelectParticleTable = new DataTable();
- SelectParticleData(out SelectParticleTable);
- int sel = 0;
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- sel = 0;
- }
- else
- {
- sel = 1;
- }
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- DataTable dt = InvalidRemoval(fielddata.GetIncaSurfaceData(SelectParticleTable, sel, m_mbszclass.M_KLLBXX.list_str_kllb_qcys), "TypeName");
- ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
- //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resfile.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
- string str_libraryName = resfile.GetSTDName();
- //string str_libraryName = resfile.GetSTDName();
- //float PixelSize = resfile.GetPixelSize();
- if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.CleannessA)
- {
- dt.Columns.Add("Hardness", typeof(double));
- dt.Columns.Add("Hardness_detailed");
- DataTable dt_stl = new DataTable();
- if (GetSTL(str_libraryName, out dt_stl))
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- for (int a = 0; a < dt_stl.Rows.Count; a++)
- {
- if (dt.Rows[i]["TypeName"].ToString() == dt_stl.Rows[a]["TypeId"].ToString())
- {
- dt.Rows[i]["Hardness"] = Convert.ToDouble(dt_stl.Rows[a]["Hardness"]);
- dt.Rows[i]["Hardness_detailed"] = dt_stl.Rows[a]["Hardness_detailed"];
- break;
- }
- }
- }
- }
- }
- //去除物质分类(非夹杂物分类)
- for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
- {
- for (int i = dt.Rows.Count-1; i >=0; i--)
- {
- if (dt.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
- {
- dt.Rows.RemoveAt(i);
-
- }
- }
- }
- //将颗粒大小排序(从大到小)
- DataView dv = dt.DefaultView;
- dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1.ToString() + " DESC";
- DataTable dt_ParticlesGridDevidePage = dv.ToTable();
- string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].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);
- //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("ColName7");
- DT_Largest20.Columns.Add("ColName8");
- DT_Largest20.Columns.Add("ColName9");
- DT_Largest20.Columns.Add("ColName10");
- 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");
- DT_Largest20.Columns.Add("ColVal7");
- DT_Largest20.Columns.Add("ColVal8");
- DT_Largest20.Columns.Add("ColVal9");
- DT_Largest20.Columns.Add("ColVal10");
- // 图像列
- DT_Largest20.Columns.Add("p1", typeof(Bitmap));
- DT_Largest20.Columns.Add("p2", typeof(Bitmap));
- DT_Largest20.Columns.Add("p3", typeof(Bitmap));
- #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)
- if (serialNumber > m_mbszclass.M_KLLBXX.list_int_kllb_number)
- continue;
- 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);
- //二次放大图
- MemoryStream newms_p2 = new MemoryStream();
- ls_processbitmap.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
- //能谱图
- MemoryStream newms_p3 = new MemoryStream();
- ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
- //---------------------------------------------------------------------------------------
- DataRow dr = DT_Largest20.NewRow();
- dr["p1"] = bp_particle;
- dr["p2"] = ls_processbitmap;
- dr["p3"] = ls_xraybpnew;
- newms_p1.Dispose();
- newms_p2.Dispose();
- newms_p3.Dispose();
- dr["pid"] = serialNumber++.ToString();
- //颗粒列表列中第一个可选参数
- dr["Size"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1);
- //这个参数没有用
- dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
- //颗粒列表列中第二个可选参数
- dr["DMAX"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p2);
- //颗粒列表列中第三个可选参数
- dr["DMIN"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p3);
- //颗粒列表列中显示分类不可以选择
- dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
- GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
- double colVal = 0;
- for (int i=0;i< list_max_elementvale.Count;i++)
- {
- colVal = colVal + Convert.ToDouble(list_max_elementvale[i]);
- }
- //元素1
- dr["ColName1"] = list_max_elementname[0];
- dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
- //元素2
- dr["ColName2"] = list_max_elementname[1];
- dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
- //元素3
- dr["ColName3"] = list_max_elementname[2] ;
- dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
- //元素4
- dr["ColName4"] = list_max_elementname[3] ;
- dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
- //元素5
- dr["ColName5"] = list_max_elementname[4] ;
- dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
- //元素6
- dr["ColName6"] = list_max_elementname[5] ;
- dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
- //元素7
- dr["ColName7"] = list_max_elementname[6];
- dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
- //元素8
- dr["ColName8"] = list_max_elementname[7] ;
- dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
- //元素6
- dr["ColName9"] = list_max_elementname[8] ;
- dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
- //元素6
- dr["ColName9"] = list_max_elementname[9] ;
- dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[9]);
- DT_Largest20.Rows.Add(dr);
- }
- }
- #endregion
- return DT_Largest20;
- }
- /// <summary>
- /// 参数归一化
- /// </summary>
- /// <param name="a_mi">总数</param>
- /// <param name="m">传参</param>
- /// <returns></returns>
- public string ParameterNormalization(double a_mi,double m)
- {
- double ColVal = Convert.ToDouble(m / a_mi * 100);
- if (ColVal == 0)
- {
- return "";
- }
- else
- {
-
- return Math.Round(ColVal, 2).ToString();
- }
- }
- public void Get_dev_kllb_data_frame(c_TemplateClass m_mbszclass, out DataTable file_pic, out List<DataTable> list_dt)
- {
- //------------------加载模块,获取数据-------------------------------------------------
- m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
- SelectParticleData(out DataTable SelectParticleTable);
- int sel = 0;
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- sel = 0;
- }
- else
- {
- sel = 1;
- }
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- DataTable dt = InvalidRemoval(fielddata.GetIncaSurfaceData(SelectParticleTable, sel, m_mbszclass.M_KLLBXX.list_str_kllb_qcys), "TypeName");
- ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
- //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resfile.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
- string str_libraryName = resfile.GetSTDName();
- if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.CleannessA)
- {
- dt.Columns.Add("Hardness", typeof(double));
- dt.Columns.Add("Hardness_detailed");
- DataTable dt_stl = new DataTable();
- if (GetSTL(str_libraryName, out dt_stl))
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- for (int a = 0; a < dt_stl.Rows.Count; a++)
- {
- if (dt.Rows[i]["TypeName"].ToString() == dt_stl.Rows[a]["TypeId"].ToString())
- {
- dt.Rows[i]["Hardness"] = Convert.ToDouble(dt_stl.Rows[a]["Hardness"]);
- dt.Rows[i]["Hardness_detailed"] = dt_stl.Rows[a]["Hardness_detailed"];
- break;
- }
- }
- }
- }
- }
- //去除物质分类(非夹杂物分类)
- for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
- {
- for (int i = dt.Rows.Count - 1; i >= 0; i--)
- {
- if (dt.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
- {
- dt.Rows.RemoveAt(i);
- }
- }
- }
- //将颗粒大小排序(从大到小)
- DataView dv = dt.DefaultView;
- dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1.ToString() + " DESC";
- DataTable dt_ParticlesGridDevidePage = dv.ToTable();
- string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath;
- DataTable DT_field_dt = new DataTable();
- DT_field_dt.TableName = "field_dt";
- DT_field_dt.Columns.Add("FieldId", typeof(int));
- //图像列
- DT_field_dt.Columns.Add("FieldImg", typeof(Bitmap));
- //首先生成标记颗粒的帧图图像文件
- DataTable dt_GridDevidePage = dt_ParticlesGridDevidePage.Copy();
- dt_GridDevidePage.Clear();
- for (int i = 0; i < dt_ParticlesGridDevidePage.Rows.Count; i++)
- {
- if (dt_ParticlesGridDevidePage.Rows[i]["TypeName"].ToString() != "Not Identified")
- {
- dt_GridDevidePage.Rows.Add(dt_ParticlesGridDevidePage.Rows[i].ItemArray);
- }
- }
- m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.Out_MarkParticleRectangleOnFieldFile(str_resultPath, dt_GridDevidePage, out List<string> vs, out DataTable data);
- FrameGraphParticleTableDatat(dt_ParticlesGridDevidePage, fielddata, data, m_mbszclass, out DataTable data_A);
- List<DataTable> listData = new List<DataTable>();
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataTable dataTable = data_A.Clone();
- //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
- DataRow[] datarowlist = data_A.Select(data.Rows[i]["fieldid"].ToString());
- if (datarowlist.Count() > 0)
- {
- for (int a = 0; a < data_A.Rows.Count; a++)
- {
- if (data.Rows[i]["id"].ToString() == data_A.Rows[a]["FieldId"].ToString())
- {
- dataTable.Rows.Add(data_A.Rows[a].ItemArray);
- }
- }
- listData.Add(dataTable);
- }
- }
- file_pic = data.Copy();
- list_dt = listData;
- }
- private void FrameGraphParticleTableDatat(DataTable dt_ParticlesGridDevidePage, ParticleData fielddata, DataTable DT_field_dt, c_TemplateClass m_mbszclass, out DataTable data_A)
- {
- //将颗粒大小排序(从大到小)
- DataView dv = dt_ParticlesGridDevidePage.DefaultView;
- dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p1.ToString() + " DESC";
- DataTable dt = dv.ToTable();
- //表名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("ColName7");
- FrameGraphSubTable.Columns.Add("ColName8");
- FrameGraphSubTable.Columns.Add("ColName9");
- FrameGraphSubTable.Columns.Add("ColName10");
- FrameGraphSubTable.Columns.Add("ColVal1");
- FrameGraphSubTable.Columns.Add("ColVal2");
- FrameGraphSubTable.Columns.Add("ColVal3");
- FrameGraphSubTable.Columns.Add("ColVal4");
- FrameGraphSubTable.Columns.Add("ColVal5");
- FrameGraphSubTable.Columns.Add("ColVal6");
- FrameGraphSubTable.Columns.Add("ColVal7");
- FrameGraphSubTable.Columns.Add("ColVal8");
- FrameGraphSubTable.Columns.Add("ColVal9");
- FrameGraphSubTable.Columns.Add("ColVal10");
- FrameGraphSubTable.Columns.Add("pic", typeof(Bitmap));
- FrameGraphSubTable.Columns.Add("FieldId", typeof(int));
- ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
-
-
-
- for (int i_row = 0; i_row < dt.Rows.Count; i_row++)
- {
- if (dt.Rows[i_row]["element"].ToString() == "")
- continue;
- if (dt.Rows[i_row]["TypeName"].ToString() == "Not Identified")
- continue;
- string str_fieldid = dt.Rows[i_row]["fieldid"].ToString();
- if (JudgeWhetherItExists(Convert.ToInt32(str_fieldid), DT_field_dt, "id"))
- {
- //获取原始颗粒图像
- Bitmap bp_particle = new Bitmap(1, 1);
- Bitmap bp_field = new Bitmap(1, 1);
- Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt.Rows[i_row]["RectHeight"]) };
- for (int i = 0; i < DT_field_dt.Rows.Count; i++)
- {
- if (dt.Rows[i_row]["FieldId"].ToString() == DT_field_dt.Rows[i]["id"].ToString())
- {
- bp_field = new Bitmap(DT_field_dt.Rows[i]["fieldFullName"].ToString());
- }
- }
- bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
- bp_particle.Tag = new List<string>() { dt.Rows[i_row]["FieldId"].ToString(), dt.Rows[i_row]["ParticleId"].ToString(), dt.Rows[i_row]["TypeId"].ToString() };
- DataRow dr = FrameGraphSubTable.NewRow();
- //var bitmap = DrawRuler(bp_particle, (int)RulerPixels, 2);
- //bitmap.Save("D:\\图片\\asd.bmp");
- dr["pic"] = bp_particle;
- //帧图列表列第一个字段的可选参数
- dr["pid"] = datatable_data(dt, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p1);
- //帧图列表列第二个字段的可选参数
- dr["Size"] = datatable_data(dt, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p2);
- dr["Width"] = dt.Rows[i_row]["rectwidth"].ToString();
- dr["DMAX"] = Math.Round(Convert.ToDouble(dt.Rows[i_row]["dmax"]), 2).ToString();
- dr["DMIN"] = Math.Round(Convert.ToDouble(dt.Rows[i_row]["dmin"]), 2).ToString();
- dr["Class"] = dt.Rows[i_row]["typename"].ToString();
- dr["fieldid"] = str_fieldid;
- GetMaxElementFromDataTable(dt, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
- double colVal = 0;
- for (int i = 0; i < list_max_elementvale.Count; i++)
- {
- colVal = colVal + Convert.ToDouble(list_max_elementvale[i]);
- }
- //元素1
- dr["ColName1"] = list_max_elementname[0] ;
- dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
- //元素2
- dr["ColName2"] = list_max_elementname[1] ;
- dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
- //元素3
- dr["ColName3"] = list_max_elementname[2] ;
- dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
- //元素4
- dr["ColName4"] = list_max_elementname[3] ;
- dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
- //元素5
- dr["ColName5"] = list_max_elementname[4] ;
- dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
- //元素6
- dr["ColName6"] = list_max_elementname[5] ;
- dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
- //元素6
- dr["ColName7"] = list_max_elementname[6] ;
- dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
- //元素6
- dr["ColName8"] = list_max_elementname[7] ;
- dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
- //元素6
- dr["ColName9"] = list_max_elementname[8] ;
- dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
- //元素6
- dr["ColName10"] = list_max_elementname[9] ;
- dr["ColVal10"] = ParameterNormalization(colVal, list_max_elementvale[9]);
- FrameGraphSubTable.Rows.Add(dr);
- }
- }
- data_A = FrameGraphSubTable.Copy();
- }
-
-
- public void ParticleSizeTable(c_TemplateClass m_mbszclass, out DataTable surface_dt, out DataTable partsize_dt, out DataTable class_dt, out DataTable subdivide_dt, out DataTable colid_data)
- {
- //全部大类
- DataTable dt_addCalss = new DataTable();
- DataTable dt_allSubdivision = new DataTable();
- //全部小类
- if (m_bt_DBData.Columns.Count == 0)
- {
- GetDBData(m_mbszclass);
- }
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + 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.getSelectedIndex()].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);
- }
- dt_allSubdivision = ls_Particel_dt.Copy();
- //按照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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //颗粒尺寸数据(例 1.5有多少,2.0有多少)
- colid_data = new DataTable();
- colid_data.Columns.Add("name");
- colid_data.Columns.Add("quantity",typeof(double));
- for (int i=0;i< ls_Particel_dt.Columns.Count;i++)
- {
-
- if (ls_Particel_dt.Columns[i].ColumnName=="c"+(i+1).ToString())
- {
- if (i< colid.Count)
- {
- DataRow dr1 = colid_data.NewRow();
- dr1["name"] = colid[i].ToString();
- int quantity = 0;
- for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
- {
- quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
- }
- dr1["quantity"] = quantity.ToString();
- colid_data.Rows.Add(dr1);
- }
- }
- }
- //获取大分类信息
- DataTable dt = InvalidRemoval(QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName), "Class");
- dt_addCalss = dt.Copy();
- DataTable data = classIfIcationSort(ls_Particel_dt, ClassName, dt);
- surface_dt = data.Copy();
- class_dt = dt_addCalss.Copy();
- subdivide_dt = dt_allSubdivision.Copy();
- partsize_dt = ls_partsize_dt.Copy();
- }
- public DataTable ParticleResults(c_TemplateClass m_mbszclass)
- {
- if (m_bt_DBData.Columns.Count == 0)
- {
- GetDBData(m_mbszclass);
- }
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + 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.getSelectedIndex()].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");
- ls_partsize_dt.Columns.Add("c10");
- DataRow dr = ls_partsize_dt.NewRow();
- for (int i = 1; i < 11; 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");
- ls_Particel_dt.Columns.Add("c2");
- ls_Particel_dt.Columns.Add("c3");
- ls_Particel_dt.Columns.Add("c4");
- ls_Particel_dt.Columns.Add("c5");
- ls_Particel_dt.Columns.Add("c6");
- ls_Particel_dt.Columns.Add("c7");
- ls_Particel_dt.Columns.Add("c8");
- ls_Particel_dt.Columns.Add("c9");
- ls_Particel_dt.Columns.Add("c10");
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total");
- ls_Particel_dt.Columns.Add("TypeId");
-
- 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["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < 11; j++)
- {
- if (colid.Count >= j)
- {
- double de = Convert.ToDouble(m_bt_DBData.Rows[i][colid[j - 1]]);
- if (de == 0)
- dr2["c" + j.ToString()] = " ";
- else
- dr2["c" + j.ToString()] = de.ToString();
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = " "; //求合
- double d_total = 0;
- for (int j = 1; j < 11; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(m_bt_DBData.Rows[i][colid[j - 1]]);
- }
- }
- if (d_total == 0)
- {
- continue;
- dr2["total"] = " ";
- }
- else
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- return ls_Particel_dt;
- }
- public DataTable TypeRange()
- {
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + 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() + "≤ X<" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- colid.Add(d.ToString() + "≤ X<MAX");
- 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");
- ls_partsize_dt.Columns.Add("c10");
- ls_partsize_dt.Columns.Add("c11");
- ls_partsize_dt.Columns.Add("c12");
- DataRow dr = ls_partsize_dt.NewRow();
- for (int i = 1; i < 13; i++)
- {
- if (colid.Count < i)
- {
- dr["c" + i.ToString()] = "";
- }
- else
- {
- dr["c" + i.ToString()] = colid[i - 1];
- }
- }
- ls_partsize_dt.Rows.Add(dr);
- return ls_partsize_dt;
- }
- public void ChemistryTable(c_TemplateClass m_mbszclass, out DataTable b1,out DataTable b2)
- {
- if (m_bt_DBData.Columns.Count == 0)
- {
- GetDBData(m_mbszclass);
- }
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].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");
- AllAnalysisDetails.Columns.Add("con");
- double total = 0;
- 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();
- dr2["con"] = m_bt_DBData.Rows[i]["con"].ToString();
- total += Convert.ToInt32(m_bt_DBData.Rows[i]["con"]);
- 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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
- 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, out DataTable dt1, out DataTable dt2);
- dt2.Columns.Add("con");
- dt2.Columns.Add("per");
- dt1.Columns.Add("con");
- dt1.Columns.Add("per");
- DataTable table = dt2.Copy();
- table.Clear();
- //table.Columns.Add("con");
- int inxe = 0;
- for(int i=0;i< dt2.Rows.Count;i++)
- {
- if(string.IsNullOrWhiteSpace(dt2.Rows[i]["Class"].ToString()))
- {
-
- for (int a=0;a< AllAnalysisDetails.Rows.Count;a++)
- {
- if(dt2.Rows[i]["Name"].ToString()== AllAnalysisDetails.Rows[a]["Name"].ToString())
- {
- dt2.Rows[i]["con"] = AllAnalysisDetails.Rows[a]["con"];
- dt2.Rows[i]["per"] = (Convert.ToDouble(AllAnalysisDetails.Rows[a]["con"]) / total) * 100;
- }
- }
- table.Rows.Add(dt2.Rows[i].ItemArray);
- }
- inxe++;
- }
- b1 = dt1.Copy();
- b2 = table.Copy();
- //return dt;
- }
-
- private DataTable 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 (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
- if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- 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");
- return dt;
- }
- public bool InsertReportTemplateTable_ElementAvgGrid(c_TemplateClass m_mbszclass, out DataTable dt1, out DataTable dt2,out DataTable allElement_dt)
- {
- if (m_bt_DBData.Columns.Count == 0)
- {
- GetDBData(m_mbszclass);
- }
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
- 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, out dt1, out dt2);
- allElement_dt = dt_ElementSorting.Copy();
- return true;
- }
- private bool SubdivisionOfMaterialElements(DataTable a_ElementalSubstance, int NumberOfColumns, List<string> ClassName, DataTable data, out DataTable dt1, out DataTable dt2)
- {
- 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();
- }
- dt1 = dataTable.Copy();
- dt2 = dt_ElementalSubstance.Copy();
-
- return true;
- }
- #region 三元图
-
- //手动绘制的三元图
- public Bitmap DrawATernaryPicture(int selectindex, c_TemplateClass m_mbszclass, List<Color> Color_list)
- {
- int sel = 0;
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- sel = 0;
- }
- else
- {
- sel = 1;
- }
- ResultFile resultFile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
- string template = TemplateList[selectindex];
- if (template == "")
- { //三元相图模板
- template = m_condition.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.TRIO_CHART_TYPE).ToString();
- }
- //获取粒级表
- string pathtpf = Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";
- List<string> nameList = new List<string>();
- DataSet ds = XMLoperate.GetXmlData(pathtpf, "XMLData");
- DataTable dt = ds.Tables["Member"];
- string TemplateName = "";
- //遍历第一层节点
- foreach (DataRow element in dt.Rows)
- {
- TemplateName = element["TemplateName"].ToString();
- if (TemplateName == template)
- {
- string Element = element["Element"].ToString();
- nameList.Add(Element.Split('.')[0]);
- nameList.Add(Element.Split('.')[1]);
- nameList.Add(Element.Split('.')[2]);
- break;
- }
- }
-
- DataTable dt_point_sort = new DataTable();
- dt_point_sort.Columns.Add("X", typeof(double));
- dt_point_sort.Columns.Add("Y", typeof(double));
- dt_point_sort.Columns.Add("Color_position");
- DataTable particles = GetParticles(resultFile.FilePath, nameList, sel);
- foreach (DataRow item in particles.Rows)
- {
- if (item["particleLocation"].ToString() == "0,0,0")
- {
- continue;
- }
- double top = Convert.ToDouble(item["top"]);
- double left = Convert.ToDouble(item["left"]);
- double right = Convert.ToDouble(item["right"]);
- //x=right+top/2,y=(√3/2)*top
- double Y = 0.866 * top * 500;
- double X = (right + top / 2) * 500;
- double[] point_ = { Math.Round(X, 2), Math.Round(Y) };
- DataRow dr = dt_point_sort.NewRow();
- dr["X"] = Math.Round(X, 2);
- dr["Y"] = Math.Round(Y);
- dr["Color_position"] = item["Color_position"];
- dt_point_sort.Rows.Add(dr);
- }
- #region 图形
- int Line = 500;
- Bitmap map = new Bitmap(530, 530);
- Graphics g = Graphics.FromImage(map);
- SolidBrush sbrush_White = new SolidBrush(Color.White);
- g.FillRectangle(sbrush_White, 0, 0, 530, 530);
- Pen mypen = new Pen(Color.Black, 1);
- g.DrawImage(map, 0, 0, map.Width, map.Height);
- g.DrawLine(mypen, new Point(Line + 10, Line), new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))));//"\"
- g.DrawLine(mypen, new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))), new Point(0 + 10, Line));//"/"
- g.DrawLine(mypen, new Point(0 + 10, Line), new Point(Line + 10, Line));//"_"
- mypen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
- mypen.DashPattern = new float[] { 2, 2 };
- mypen = new Pen(Color.FromArgb(212, 212, 212), 1);
- int point = Line / 10;
- for (int i = 1; i < 10; i++)
- {
- //"\"
- int x1_a = point / 2 + ((point / 2) * (i - 1));
- int x2_a = Line - (43 * i);
- int y1_a = point * i;
- g.DrawLine(mypen, new Point(x1_a + 10, x2_a), new Point(y1_a + 10, Line));
-
- //"/"
- int x1_b = Line - (point / 2 + ((point / 2) * (i - 1)));
- int x2_b = Line - (43 * i);
- int y1_b = Line - (point * i);
- g.DrawLine(mypen, new Point(x1_b + 10, x2_b), new Point(y1_b + 10, Line));
-
- //"_"
- int x1_c = point / 2 + ((point / 2) * (i - 1));
- int x2_c = Line - (43 * i);
- int y1_c = Line - (point / 2 + ((point / 2) * (i - 1)));
- int y2_c = Line - (43 * i);
- g.DrawLine(mypen, new Point(x1_c + 10, x2_c), new Point(y1_c + 10, y2_c));
-
- g.DrawLine(mypen, new Point(y1_a + 10, Line + 10), new Point(y1_a + 10, Line));
- g.DrawLine(mypen, new Point(x1_b + 10, x2_b), new Point(x1_b + 10 + 10, x2_b));
- g.DrawLine(mypen, new Point(x1_c + 10 - 10, x2_c), new Point(y1_c + 10, y2_c));
- g.DrawString((i * 10).ToString(), new Font("Arial Unicode MS", 8, FontStyle.Bold), new SolidBrush(Color.Black), new Point(x1_c - 20, x2_c-5));
- g.DrawString((i * 10).ToString(), new Font("Arial Unicode MS", 8, FontStyle.Bold), new SolidBrush(Color.Black), new Point(y1_b , Line+8));
- g.DrawString(((10-i) * 10).ToString(), new Font("Arial Unicode MS", 8, FontStyle.Bold), new SolidBrush(Color.Black), new Point(x1_b + 20, x2_b-5));
- }
- for (int i = 0; i < dt_point_sort.Rows.Count; i++)
- {
- mypen = new Pen(Color.Black, 1);
- SolidBrush mysbrush = new SolidBrush(Color_list[Convert.ToInt32(dt_point_sort.Rows[i]["Color_position"])]);
- g.FillRectangle(mysbrush, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 8, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 4, 5);
- g.DrawRectangle(mypen, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 7, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 5, 5);
- }
- Font myFont = new Font("Arial Unicode MS", 13, FontStyle.Bold);
- Font Font_features = new Font("Arial Unicode MS", 10, FontStyle.Bold);
- SolidBrush sbrush = new SolidBrush(Color.Black);
- g.DrawString("features:" + dt_point_sort.Rows.Count.ToString(), Font_features, sbrush, 400, 200);
- g.DrawString(TemplateName, myFont, sbrush, 265 - (TemplateName.Length * 10 / 2), 10);
- g.DrawString(TemplateName.Split('.')[0].ToString(), myFont, sbrush, 265 - (TemplateName.Split('.')[0].ToString().Length * 10 / 2), 45);//顶点名字
- g.DrawString(TemplateName.Split('.')[1].ToString(), myFont, sbrush, 0, 510);//左侧名字
- g.DrawString(TemplateName.Split('.')[2].ToString(), myFont, sbrush, 500 - (TemplateName.Split('.')[0].ToString().Length * 10), 510);//左侧名字
- //map.Save("D:\\1.bmp");
- #endregion
- return map;
- }
- //绘制图例
- public Bitmap DrawATernaryDiagramLegend(List<Color> Color_list)
- {
- Bitmap map = new Bitmap(450, 115);
- Graphics g = Graphics.FromImage(map);
- SolidBrush sbrush_White = new SolidBrush(Color.White);
- SolidBrush sbrush = new SolidBrush(Color.Black);
- g.FillRectangle(sbrush_White, 0, 0, 450, 115);
- Font myFont = new Font("Arial Unicode MS", 10, FontStyle.Bold);
- Font myFont2 = new Font("Arial Unicode MS", 10, FontStyle.Regular);
- g.DrawString("legend(length,μm)", myFont, sbrush, 140, 3);
- //legend(length,microns)
- Pen mypen = new Pen(Color.Black, 1);
- g.DrawLine(mypen, 100, 19, 350, 19);
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = 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 PositionJeight = 27;
- string str_unit = " μm";
- for (int i=0;i< listName.Count;i=i+3)
- {
- if (i< listName.Count)
- {
- SolidBrush sbrush_Color = new SolidBrush(Color_list[i]);
- g.DrawRectangle(mypen, 26, PositionJeight, 8, 8);
- g.FillRectangle(sbrush_Color, 27, PositionJeight + 1, 7, 7);
- g.DrawString(listName[i].ToString()+ str_unit, myFont2, sbrush, 38, PositionJeight-2);
- }
- if (i+1 < listName.Count)
- {
- SolidBrush sbrush_Color = new SolidBrush(Color_list[i+1]);
- g.DrawRectangle(mypen, 170, PositionJeight, 8, 8);
- g.FillRectangle(sbrush_Color, 171, PositionJeight + 1, 7, 7);
- g.DrawString(listName[i+1].ToString()+ str_unit, myFont2, sbrush, 182, PositionJeight - 2);
- }
- if (i + 2 < listName.Count)
- {
- SolidBrush sbrush_Color = new SolidBrush(Color_list[i + 2]);
- g.DrawRectangle(mypen, 314, PositionJeight, 8, 8);
- g.FillRectangle(sbrush_Color, 315, PositionJeight + 1, 7, 7);
- g.DrawString(listName[i + 2].ToString()+ str_unit, myFont2, sbrush, 326, PositionJeight - 2);
- }
- PositionJeight = PositionJeight + 15;
- }
-
- return map;
- }
- private DataTable GetParticles(string filepath, List<string> nameList, int sel)
- {
- ParticleData particledata = new ParticleData(filepath);
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = 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");
- string filedAndParticl = "";
- if (sel == 1)
- {
- List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
- foreach (var item in selectParticles)
- {
- filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
- }
- if (filedAndParticl != "")
- {
- filedAndParticl = filedAndParticl + ",";
- }
- }
- string po = "";
- string con = "";
- int row = m_condition.m_conditionData.ConditionItemList.Count;
- if (condition != -1)
- {
- List<string> li = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };
- con = li[condition];
- }
- else
- {
- if (row < 4)
- {
- con = "DMAX";
- }
- else
- {
- con = m_condition.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- }
- }
- 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.GetParticleAllHaveXray(filedAndParticl);
- //DataTable dtp = particledata.GetParticleHaveXray(filedAndParticl);
- for (int i=0;i<dtp.Rows.Count;i++)
- {
- if (Convert.ToInt32( dtp.Rows[i]["TypeId"])< 0 || dtp.Rows[i]["TypeName"].ToString()== "Invalid")
- {
- dtp.Rows[i].Delete();
- }
- }
- dtp.AcceptChanges();
- //创建一个临时表
- DataTable ret_dt = new DataTable();
- //然后额外存放三列,用于存放拆分后三个顶点的值
- ret_dt.Columns.Add("sizeLevel");
- ret_dt.Columns.Add("particleLocation");
- ret_dt.Columns.Add("top");
- ret_dt.Columns.Add("left");
- ret_dt.Columns.Add("right");
- ret_dt.Columns.Add("Color_position");
- 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));
- foreach (var item in datas)
- {
- DataRow dr = ret_dt.NewRow();
- dr["sizeLevel"] = str;
- string element = item["Element"].ToString();
- string strRet = getStrRet(nameList, element);
- dr["particleLocation"] = strRet;
- dr["top"] = strRet.Split(',')[0];
- dr["left"] = strRet.Split(',')[1];
- dr["right"] = strRet.Split(',')[2];
- dr["Color_position"] = k.ToString();
- ret_dt.Rows.Add(dr);
- }
- }
- return ret_dt;
- }
- private string getWhere(string max, string min, string col)
- {
- return col + ">=" + min + " and " + col + "<=" + max;
- }
- private string getStrRet(List<string> template, string element)
- {
- List<string> name = new List<string>()
- { "h","he",
- "li","be","b","c","n","o","f","ne",
- "na","mg","al","si","p","s","cl","ar",
- "k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr",
- "rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe",
- "cs","ba","la",
- "ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu",
- "hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn",
- "fr","ra","ac",
- "th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr"
- };
- List<double> value = new List<double>()
- { 1.008,4.003,
- 6.941,9.012,10.811,12.011,14.007,15.999,18.998,20.180,
- 22.990,24.305,26.982,28.086,30.974,32.066,35.453,39.948,
- 39.098,40.08,44.956,47.88,50.942,51.996,54.938,55.847,58.933,58.70,63.546,65.39,69.72,72.61,74.922,78.96,79.904,83.80,
- 85.468,87.62,88.906,91.22,92.906,95.94,98.00,101.07,102.906,106.42,107.868,112.41,114.82,118.71,121.76,127.60,126.905,131.29,
- 132.905,137.33,138.906,
- 140.12,140.908,144.24,145.0,150.36,151.97,157.25,158.925,162.50,64.93,167.26,168.934,173.04,174.967,
- 178.49,180.948,183.85,186.207,190.20,192.22,195.08,196.967,200.59,204.38,207.2,208.980,209.00,210.00,222.00,
- 223.00,226.025,227.028,
- 232.038,231.036,238.029,237.048,244.00,243.00,247.00,247.00,251.00,252.00,257.00,258.00,259.00,260.00
- };
- double d_ASum = 0;
- double d_BSum = 0;
- double d_CSum = 0;
- string aElements = template[0];
- string bElements = template[1];
- string cElements = template[2];
- foreach (var item in element.Split(';'))
- {
- if (item.Contains(aElements + "-"))
- {
- if (aElements != "")
- {
- d_ASum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(aElements.ToLower())];
- }
- }
- for (int i = 0; i < bElements.Split(',').Length; i++)
- {
- string e = bElements.Split(',')[i];
- if (item.Contains(e + "-"))
- {
- d_BSum = d_BSum + Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(e.ToLower())];
- }
- }
- if (item.Contains(cElements + "-"))
- {
- if (cElements != "")
- d_CSum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(cElements.ToLower())];
- }
- }
- double allNums = d_ASum + d_BSum + d_CSum;
- string strRet = "";
- if ((allNums) == 0)
- {
- strRet = "0,0,0";
- }
- else
- {
- double aPercent = 0, bPercent = 0, cPercent = 0;
- if (d_ASum != 0)
- {
- aPercent = d_ASum / allNums;
- }
- if (d_BSum != 0)
- {
- bPercent = d_BSum / allNums;
- }
- if (d_CSum != 0)
- {
- cPercent = d_CSum / allNums;
- }
- strRet = aPercent.ToString() + "," + bPercent.ToString() + "," + cPercent.ToString();
- }
- return strRet;
- }
- #endregion
- /// <summary>
- /// 大分类数据
- /// </summary>
- /// <param name="m_mbszclass"></param>
- /// <returns></returns>
- public DataTable ClassificationIntegration(c_TemplateClass m_mbszclass,string str)
- {
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- DataTable data = new DataTable();
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- data = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- }
- else
- {
- DataTable AllInca = fielddata.GetAreaByAllIncA("");
- DataTable SelectParticl = SelectParticleData();
- data = GetParticleListForParticlSize(SelectParticl, AllInca);
- }
- 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 = 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("Class");
- AreaRatio.Columns.Add("Name");
- AreaRatio.Columns.Add("Area", typeof(double));
- AreaRatio.Columns.Add("inca_proportion");
- AreaRatio.Columns.Add("inca_FieldRatio");
- AreaRatio.Columns.Add("Cunt", typeof(int));
- //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
- double totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
- for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
- {
- DataRow dr2 = AreaRatio.NewRow();
- dr2["Class"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
- dr2["Name"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
- dr2["Area"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
- dr2["inca_proportion"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
- dr2["inca_FieldRatio"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str)) * 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]["Class"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio.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++)
- {
- 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]["Class"].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(Area)", "").ToString()));
- double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
- int cunt = Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
- DataRow dr3 = AllAnalysisDetails1.NewRow();
- dr3["Class"] = ClassName[i].ToString();
- dr3["Area"] = Math.Round(Area, 2);
- dr3["inca_proportion"] = Math.Round((Convert.ToDouble(dt.Rows[0]["Area"]) / totalInclusionArea2) * 100, 2);
- dr3["inca_FieldRatio"] = Math.Round((Convert.ToDouble(dt.Rows[0]["Area"]) / Convert.ToDouble(str)) * 100, 4);
- dr3["Cunt"] = cunt;
- AllAnalysisDetails1.Rows.Add(dr3);
- }
- }
- return AllAnalysisDetails1;
- }
- private DataTable SelectParticleData()
- {
- List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
- #region Datatable数据表格式
- DataTable dtUelect = new DataTable();
- dtUelect.Columns.Add("fieldid");
- dtUelect.Columns.Add("particleid");
- dtUelect.Columns.Add("AveGray");
- dtUelect.Columns.Add("RectLeft");
- dtUelect.Columns.Add("RectTop");
- dtUelect.Columns.Add("RectWidth");
- dtUelect.Columns.Add("RectHeight");
- dtUelect.Columns.Add("Area");
- dtUelect.Columns.Add("PosX");
- dtUelect.Columns.Add("PosY");
- dtUelect.Columns.Add("TypeId");
- dtUelect.Columns.Add("SegmentNum");
- dtUelect.Columns.Add("SEMPosX");
- dtUelect.Columns.Add("SEMPosY");
- dtUelect.Columns.Add("XrayId");
- dtUelect.Columns.Add("DMAX");
- dtUelect.Columns.Add("DMIN");
- dtUelect.Columns.Add("DPERP");
- dtUelect.Columns.Add("PERIMETER");
- dtUelect.Columns.Add("ORIENTATION");
- dtUelect.Columns.Add("DINSCR");
- dtUelect.Columns.Add("DMEAN");
- dtUelect.Columns.Add("DELONG");
- dtUelect.Columns.Add("DFERET");
- dtUelect.Columns.Add("TypeName");
- dtUelect.Columns.Add("TypeColor");
- #endregion
- for (int i = 0; i < selectParticles.Count; i++)
- {
- dtUelect.Rows.Add(selectParticles[i].FieldId, selectParticles[i].ParticleId, selectParticles[i].AveGray, selectParticles[i].RectLeft, selectParticles[i].RectTop, selectParticles[i].RectWidth, selectParticles[i].RectHeight, selectParticles[i].Area, selectParticles[i].PosX, selectParticles[i].PosX, selectParticles[i].TypeId, /*selectParticles[i].ElementNum,*/ selectParticles[i].SegmentNum, selectParticles[i].SEMPosX, selectParticles[i].SEMPosY, selectParticles[i].ParticleId, selectParticles[i].DMAX, selectParticles[i].DMIN, selectParticles[i].DPERP, selectParticles[i].PERIMETER, selectParticles[i].ORIENTATION, selectParticles[i].DINSCR, selectParticles[i].DMEAN, selectParticles[i].DELONG, selectParticles[i].DFERET, selectParticles[i].TypeName, selectParticles[i].TypeColor);
- }
- return dtUelect;
- }
- 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>
- /// <param name="m_mbszclass"></param>
- /// <returns></returns>
- public DataTable subdivisionIntegration(c_TemplateClass m_mbszclass)
- {
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- DataTable data = new DataTable();
- if (m_mbszclass.M_SY.int_xzkl == 0)
- {
- data = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- }
- else
- {
- DataTable AllInca = fielddata.GetAreaByAllIncA("");
- DataTable SelectParticl = SelectParticleData();
- data = GetParticleListForParticlSize(SelectParticl, AllInca);
- }
- return ConSolidateInvalid(data);
- }
- public void GenerateINCAtable(string str,out DataTable dt)
- {
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- //按照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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //夹杂物面积比添加大类
- DataTable RawParticleData = InclusionAreaRatio_2(str);
- //夹杂物面积比计算大类占比
- ProportionOfParticleArea(RawParticleData, ClassName, str, out dt);
- }
- private bool ProportionOfParticleArea(DataTable dataTable, List<string> ClassName,string str, out DataTable dt_out)
- {
- 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]["Class"].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(Area)", "").ToString()));
- double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
- DataRow dr = AllAnalysisDetails.NewRow();
- dr["Class"] = ClassName[i].ToString();
- dr["Area"] = Math.Round(Area, 2);
- //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- dr["inca_proportion"] = Math.Round((Convert.ToDouble(Area) / totalInclusionArea) * 100, 2);
- dr["inca_FieldRatio"] = Math.Round((Convert.ToDouble(Area) / Convert.ToDouble(str)) * 100, 4);
- AllAnalysisDetails.Rows.Add(dr);
- DataView dv = dt.DefaultView;
- dv.Sort = "Area DESC";
- DataTable dt_Area = dv.ToTable();
- for (int a = 0; a < dt_Area.Rows.Count; a++)
- {
- dt_Area.Rows[a]["Class"] = "";
- dt_Area.Rows[a]["Area"] = Math.Round(Convert.ToDouble(dt_Area.Rows[a]["Area"]), 2);
- AllAnalysisDetails.Rows.Add(dt_Area.Rows[a].ItemArray);
- }
- }
- }
- dt_out = AllAnalysisDetails.Copy();
- return true;
- }
- private DataTable InclusionAreaRatio_2(string str)
- {
- //根据sql条件,查询获取颗粒信息数据
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
- DataTable AreaInformationOfAllElements = InvalidRemoval(InvalidRemoval(fielddata.GetAreaByAllIncA(""), "GroupName"), "TypeName");
- 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<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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- DataTable AreaRatio = new DataTable();
- AreaRatio.TableName = "InclusionAreaRatio";
- AreaRatio.Columns.Add("Class");
- AreaRatio.Columns.Add("subdivision");
- AreaRatio.Columns.Add("Area", typeof(double));
- AreaRatio.Columns.Add("inca_proportion");
- AreaRatio.Columns.Add("inca_FieldRatio");
- //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
- int sumArea = 0;
- for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
- {
- sumArea = sumArea + Convert.ToInt32(AllAnalysisDetails.Rows[i]["Area"]);
- }
- for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
- {
- DataRow dr = AreaRatio.NewRow();
- dr["Class"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
- dr["subdivision"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
- dr["Area"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
- dr["inca_proportion"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / sumArea) * 100, 2);
- dr["inca_FieldRatio"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str)) * 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]["Class"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio.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++)
- {
- AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
- }
- }
- return AreaRatio_dt;
- }
- public void criterion_out(GBReport GB_Report, OTSReport_Export in_export,int Index,DataTable dev_internationalLanguage,bool gb_1,bool gb_2,bool AmericanStandard,bool GermanStandard)
- {
- //首页信息
- GB_Report = new GBReport(in_export);
- GB_Report.setResultGrid(m_otsreport_export.m_mbszclass);
- GB_Report.International_language(dev_internationalLanguage);
- for (int i = 0; i < m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
- {
- string anothername = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
- string resultfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath.ToString() + "\\" + m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName_real.ToString();
- m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
- }
- OTSCLRINTERFACE.CPropParamClr clr_prop = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
- List<string> datasourcelist = m_otsreport_export.m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
- if (gb_1)
- {
- List<DataTable> GB1 = InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop, datasourcelist, Index, (int)CALCULATE_TABLE_TYPE.GB_Method1);
- DataView dv_gb1 = GB1[4].DefaultView;
- dv_gb1.Sort = "Grade desc";
- DataTable dt_gb1 = dv_gb1.ToTable();
- for (int i=0; i < GB1[4].Rows.Count;i++)
- {
- for(int a=0;a< GB1[4].Columns.Count;a++)
- {
- GB1[4].Rows[i][a] = dt_gb1.Rows[i][a];
- }
-
- }
- List<string> GB1NameList = new List<string>();
- GB1NameList.Add("A类");
- GB1NameList.Add("B类");
- GB1NameList.Add("C类");
- GB1NameList.Add("D类");
- GB1NameList.Add("DS类");
- GB_Report.set_GB_Method(GB1, GB1NameList, "方法一");
- }
- if (gb_2)
- {
- List<DataTable> GB2 = InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop, datasourcelist, Index, (int)CALCULATE_TABLE_TYPE.GB_Method2);
- DataView dv_gb1 = GB2[5].DefaultView;
- dv_gb1.Sort = "Grade desc";
- DataTable dt_gb1 = dv_gb1.ToTable();
- for (int i = 0; i < GB2[5].Rows.Count; i++)
- {
- for (int a = 0; a < GB2[5].Columns.Count; a++)
- {
- GB2[5].Rows[i][a] = dt_gb1.Rows[i][a];
- }
- }
- List<string> GB2NameList = new List<string>();
- GB2NameList.Add("A类");
- GB2NameList.Add("B类");
- GB2NameList.Add("C类");
- GB2NameList.Add("D类");
- GB2NameList.Add("D硫化物类");
- GB2NameList.Add("DS类");
- GB_Report.set_GB_Method(GB2, GB2NameList, "方法二");
- }
- DevExpress.XtraReports.UI.ReportPrintTool tool = new DevExpress.XtraReports.UI.ReportPrintTool(GB_Report);
- tool.ShowPreview();
- }
- }
- }
|