Export_ReportTemplate.cs 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916
  1. using OTSIncAReportApp._1_UI;
  2. using OTSIncAReportApp.Control_ECharts;
  3. using OTSIncAReportApp.DataOperation.DataAccess;
  4. using OTSCommon.Model;
  5. using OTSIncAReportGraph.Controls;
  6. using OTSIncAReportGrids;
  7. using OTSRptPeriodicTable;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Windows.Forms;
  15. using System.Xml;
  16. using static OTSIncAReportApp.OTSReport_Export;
  17. using OTSIncAReportApp.ReportTemplate;
  18. using OTSIncAReportApp.OTSSampleReportInfo;
  19. using OTSPeriodicTable;
  20. namespace OTSIncAReportApp.OTSTemplateDesigner
  21. {
  22. public class Export_ReportTemplate
  23. {
  24. #region 全局变量
  25. public List<DataTable> m_list_dt; //导出的各模块数据,合集
  26. public OTSReport_Export m_otsreport_export;
  27. UserLibraryData userLibrary;
  28. DataTable userLibraryData;
  29. DataTable m_bt_DBData = new DataTable();
  30. /// <summary>
  31. /// 三元图列表
  32. /// </summary>
  33. List<string> TemplateList;
  34. frmReportConditionChoose m_condition;
  35. public int condition = -1;
  36. #endregion
  37. #region 构造函数
  38. public Export_ReportTemplate(OTSReport_Export in_export)
  39. {
  40. m_otsreport_export = in_export;
  41. TemplateList = new List<string>();
  42. m_condition = in_export.m_ReportApp.m_conditionChoose;
  43. //加载三元相图各项
  44. 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";
  45. TemplateList = new List<string>();
  46. DataSet ds = DataOperation.DataAccess.XMLoperate.GetXmlData(pathtpf, "XMLData");
  47. DataTable dt = ds.Tables["Member"];
  48. foreach (DataRow item in dt.Rows)
  49. {
  50. if (item["TemplateName"].ToString() != "")
  51. {
  52. TemplateList.Add(item["TemplateName"].ToString());
  53. }
  54. }
  55. m_list_dt = new List<DataTable>();
  56. }
  57. public Export_ReportTemplate()
  58. {
  59. m_list_dt = new List<DataTable>();
  60. }
  61. #endregion
  62. #region 插入测量结果Grid表格
  63. /// <summary>
  64. /// 向 模板设计器 中插入测量结果Grid表格
  65. /// </summary>
  66. /// <returns></returns>
  67. public DataTable InsertReportTemplateTable_ResultGrid()
  68. {
  69. //------------------加载模块,获取数据-------------------------------------------------
  70. ResultGrid ls_resultgrid = new ResultGrid(m_otsreport_export.m_ReportApp);
  71. Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid_Report();
  72. //------------------加载模块,获取数据结束----------------------------------------------
  73. Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
  74. string str_CLJGMC = "";
  75. string str_YXSJ = "";
  76. string str_SCZS = "";
  77. string str_FLFA = "";
  78. string str_YJCTZ = "";
  79. string str_SCMJ = "";
  80. string Magnification = "";
  81. string str_CKBZ = "GB/T30834-2014";
  82. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col1"].ToString(), out str_CLJGMC);//测量结果名称
  83. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col4"].ToString(), out str_YXSJ);//运行时间
  84. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
  85. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col6"].ToString(), out str_FLFA);//分类方案
  86. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col7"].ToString(), out str_YJCTZ);//已检测特征
  87. keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col8"].ToString(), out str_SCMJ);//视场面积
  88. keyValues_ResultGrid.TryGetValue("Magnification", out Magnification);//放大倍数
  89. //将获取到的数据转换成报告模板能接收的格式。
  90. DataTable ls_new_dt = new DataTable();
  91. ls_new_dt.TableName = "ResultGrid";
  92. ls_new_dt.Columns.Add("CLJGMC"); //测量结果名称
  93. ls_new_dt.Columns.Add("YXSJ"); //运行时间
  94. ls_new_dt.Columns.Add("SCZS"); //视场总数
  95. ls_new_dt.Columns.Add("FLFA"); //分类方案
  96. ls_new_dt.Columns.Add("YJCTZ"); //已检测特征
  97. ls_new_dt.Columns.Add("SCMJ"); //视场面积
  98. ls_new_dt.Columns.Add("CKBZ"); //参考标准
  99. ls_new_dt.Columns.Add("FDBS");
  100. //行转列,这里不会发生改变,所以这样写
  101. DataRow dr = ls_new_dt.NewRow();
  102. dr["CLJGMC"] = str_CLJGMC;
  103. dr["YXSJ"] = str_YXSJ;
  104. dr["SCZS"] = str_SCZS;
  105. dr["FLFA"] = str_FLFA;
  106. dr["YJCTZ"] = str_YJCTZ;
  107. dr["SCMJ"] = str_SCMJ;
  108. dr["CKBZ"] = str_CKBZ;
  109. dr["FDBS"] = Magnification;
  110. ls_new_dt.Rows.Add(dr);
  111. m_list_dt.Add(ls_new_dt);
  112. return ls_new_dt;
  113. }
  114. #endregion
  115. #region 读取选择颗粒数据
  116. private void SelectParticleData(out DataTable dt)
  117. {
  118. List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
  119. #region Datatable数据表格式
  120. DataTable dtUelect = new DataTable();
  121. dtUelect.Columns.Add("fieldid");
  122. dtUelect.Columns.Add("particleid");
  123. dtUelect.Columns.Add("AveGray");
  124. dtUelect.Columns.Add("RectLeft");
  125. dtUelect.Columns.Add("RectTop");
  126. dtUelect.Columns.Add("RectWidth");
  127. dtUelect.Columns.Add("RectHeight");
  128. dtUelect.Columns.Add("Area");
  129. dtUelect.Columns.Add("PosX");
  130. dtUelect.Columns.Add("PosY");
  131. dtUelect.Columns.Add("TypeId");
  132. dtUelect.Columns.Add("SegmentNum");
  133. dtUelect.Columns.Add("SEMPosX");
  134. dtUelect.Columns.Add("SEMPosY");
  135. dtUelect.Columns.Add("XrayId");
  136. dtUelect.Columns.Add("DMAX");
  137. dtUelect.Columns.Add("DMIN");
  138. dtUelect.Columns.Add("DPERP");
  139. dtUelect.Columns.Add("PERIMETER");
  140. dtUelect.Columns.Add("ORIENTATION");
  141. dtUelect.Columns.Add("DINSCR");
  142. dtUelect.Columns.Add("DMEAN");
  143. dtUelect.Columns.Add("DELONG");
  144. dtUelect.Columns.Add("DFERET");
  145. dtUelect.Columns.Add("TypeName");
  146. dtUelect.Columns.Add("TypeColor");
  147. #endregion
  148. for (int i = 0; i < selectParticles.Count; i++)
  149. {
  150. 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);
  151. }
  152. dt = dtUelect.Copy();
  153. }
  154. #endregion
  155. #region 读取标准库所需要的数据
  156. private bool GetSTL(string str ,out DataTable data)
  157. {
  158. if (str.ToLower() == "nostddb")
  159. {
  160. data = null;
  161. return false;
  162. }
  163. DataTable dt = new DataTable();
  164. dt.Columns.Add("TypeId");
  165. dt.Columns.Add("Hardness", typeof(double));
  166. dt.Columns.Add("Hardness_detailed");
  167. OTSCommon.SqLiteHelper sh = null;
  168. string fullPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.CurResultFile.FilePath + "\\" + str + ".db";
  169. string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + str + ".db";
  170. if (System.IO.File.Exists(fullPath))
  171. {
  172. sh = new OTSCommon.SqLiteHelper ("data source='" + fullPath + "'");
  173. }
  174. else if (System.IO.File.Exists(fullPath2))
  175. {
  176. sh = new OTSCommon.SqLiteHelper("data source='" + fullPath2 + "'");
  177. }
  178. else
  179. {
  180. sh = null;
  181. data = null;
  182. return false;
  183. }
  184. DataTable dt_stl= sh.ExecuteQuery("select * from ClassifySTD");
  185. for (int i=0;i< dt_stl.Rows.Count;i++)
  186. {
  187. DataRow dr = dt.NewRow();
  188. dr["TypeId"] = dt_stl.Rows[i]["StrName"].ToString();
  189. dr["Hardness_detailed"] = dt_stl.Rows[i]["Hardness"].ToString();
  190. if (System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", "").ToString()!="")
  191. {
  192. if (System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", "")== "o. Def.")
  193. {
  194. dr["Hardness"] = 0;
  195. }
  196. else
  197. {
  198. dr["Hardness"] = Convert.ToDouble(System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", ""));
  199. }
  200. }else
  201. {
  202. dr["Hardness"] = 0;
  203. }
  204. dt.Rows.Add(dr);
  205. }
  206. data = dt;
  207. return true;
  208. }
  209. public bool GetDBData(c_TemplateClass m_mbszclass)
  210. {
  211. //GetSTL();
  212. m_bt_DBData.Clear();
  213. m_bt_DBData.Columns.Clear();
  214. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  215. List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
  216. //获取粒级表
  217. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  218. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  219. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  220. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  221. {
  222. if (sizestr.Split(',')[i].Length > 0)
  223. {
  224. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  225. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  226. colid.Add(d1.ToString() + "~" + d2.ToString());
  227. }
  228. }
  229. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  230. colid.Add(d.ToString() + "~MAX");
  231. for (int i=0;i< colid.Count;i++)
  232. {
  233. m_bt_DBData.Columns.Add(colid[i].ToString());
  234. }
  235. DataTable dt =InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""), "TypeName");
  236. DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""), "TypeName");
  237. DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""), "GroupName");
  238. //选择颗粒信息
  239. DataTable data;
  240. SelectParticleData(out data);
  241. //选择颗粒整理成表
  242. DataTable Partic_dt = new DataTable();
  243. if (data.Rows.Count >0)
  244. {
  245. Partic_dt = GetParticleListForParticlSize(data, dtp);
  246. }
  247. List<string> vs = new List<string>() { "DMAX", "DMIN", "FERET", "Area" };
  248. string po = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs];
  249. switch (po)
  250. {
  251. case "DMAX":
  252. po = "DMAX";
  253. break;
  254. case "DMIN":
  255. po = "DMIN";
  256. break;
  257. case "ECD":
  258. po = "Area";
  259. break;
  260. case "FERET":
  261. po = "DFERET";
  262. break;
  263. }
  264. //如果是全部颗粒(0)
  265. if (m_mbszclass.M_SY.int_xzkl == 0)
  266. {
  267. for (int i = 0; i < dt.Rows.Count; i++)
  268. {
  269. DataRow dr = m_bt_DBData.NewRow();
  270. dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
  271. dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
  272. dr["con"] = dt.Rows[i]["con"].ToString();
  273. if (dt.Rows[i]["GroupName"].ToString() == "")
  274. dr["Class"] = "NULL";
  275. else
  276. dr["Class"] = dt.Rows[i]["GroupName"].ToString();
  277. //continue;
  278. dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
  279. for (int a = 6; a < colid.Count; a++)
  280. {
  281. string d1 = colid[a].Split('~')[0];
  282. string d2 = colid[a].Split('~')[1];
  283. if (d2 == "MAX")
  284. {
  285. d2 = "999";
  286. }
  287. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  288. dr[colid[a]] = datas.Count();
  289. }
  290. for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
  291. {
  292. if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  293. {
  294. dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
  295. }
  296. }
  297. m_bt_DBData.Rows.Add(dr);
  298. }
  299. }
  300. else//选择颗粒(1)
  301. {
  302. for (int i = 0; i < Partic_dt.Rows.Count; i++)
  303. {
  304. DataRow dr = m_bt_DBData.NewRow();
  305. dr["TypeName"] = Partic_dt.Rows[i]["TypeName"].ToString();
  306. dr["TypeId"] = Partic_dt.Rows[i]["TypeId"].ToString();
  307. dr["con"] = Partic_dt.Rows[i]["con"].ToString();
  308. dr["Class"] = Partic_dt.Rows[i]["GroupName"].ToString();
  309. dr["Largest"] = Math.Round(Convert.ToDouble(Partic_dt.Rows[i]["max"]), 2);
  310. for (int a = 6; a < colid.Count; a++)
  311. {
  312. string d1 = colid[a].Split('~')[0];
  313. string d2 = colid[a].Split('~')[1];
  314. if (d2 == "MAX")
  315. {
  316. d2 = "999";
  317. }
  318. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, Partic_dt.Rows[i]["TypeId"].ToString()));
  319. dr[colid[a]] = datas.Count();
  320. }
  321. dr["ar"] = Partic_dt.Rows[i]["Area"];
  322. m_bt_DBData.Rows.Add(dr);
  323. }
  324. }
  325. return true;
  326. }
  327. private DataTable GetParticleListForParticlSize(DataTable data,DataTable table)
  328. {
  329. DataTable dt_Partick = new DataTable();
  330. dt_Partick.Columns.Add("TypeId");
  331. dt_Partick.Columns.Add("TypeName");
  332. dt_Partick.Columns.Add("TypeColor");
  333. dt_Partick.Columns.Add("con");
  334. dt_Partick.Columns.Add("ar");
  335. dt_Partick.Columns.Add("max");
  336. dt_Partick.Columns.Add("Area",typeof(double));
  337. dt_Partick.Columns.Add("GroupName");
  338. List<string> typeName = new List<string>();
  339. for (int i=0;i<data.Rows.Count;i++)
  340. {
  341. typeName.Add(data.Rows[i]["TypeId"].ToString());
  342. }
  343. typeName = typeName.Distinct().ToList();
  344. for (int i = 0; i < typeName.Count; i++)
  345. {
  346. DataTable dt = dt_Partick.Clone();
  347. for (int j = 0; j < data.Rows.Count; j++)
  348. {
  349. if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
  350. {
  351. DataRow row = dt.NewRow();
  352. row["TypeId"] = data.Rows[j]["TypeId"];
  353. row["TypeName"] = data.Rows[j]["TypeName"];
  354. row["TypeColor"] = data.Rows[j]["TypeColor"];
  355. row["Area"] = data.Rows[j]["Area"];
  356. dt.Rows.Add(row);
  357. }
  358. }
  359. DataRow dr = dt_Partick.NewRow();
  360. dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
  361. dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
  362. dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
  363. dr["con"] = dt.Rows.Count;
  364. dr["ar"] = dt.Compute("min(Area)", "");
  365. dr["max"] = dt.Compute("Max(Area)", "");
  366. dr["Area"] = dt.Compute("SUM(Area)", "");
  367. dt_Partick.Rows.Add(dr);
  368. }
  369. for (int i=0;i< dt_Partick.Rows.Count;i++)
  370. {
  371. for (int j=0;j< table.Rows.Count;j++)
  372. {
  373. if (dt_Partick.Rows[i]["TypeId"].ToString()== table.Rows[j]["TypeId"].ToString())
  374. {
  375. dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
  376. break;
  377. }
  378. }
  379. }
  380. return dt_Partick;
  381. }
  382. private DataTable InvalidRemoval(DataTable dt ,string str)
  383. {
  384. DataTable dataTable = dt.Copy();
  385. dataTable.Clear();
  386. for (int i=0;i<dt.Rows.Count;i++)
  387. {
  388. if (dt.Rows[i][str].ToString() != "Invalid" && dt.Rows[i][str].ToString()!= "Not Identified" && dt.Rows[i][str].ToString()!= "NOT_INCLUTION")
  389. {
  390. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  391. }
  392. }
  393. return dataTable;
  394. }
  395. private string getWhere(string max, string min, string col, string partic)
  396. {
  397. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  398. }
  399. #endregion
  400. #region 插入颗粒列表并带有帧图
  401. private string datatable_data(DataTable dt,int it,string str)
  402. {
  403. if (str == "Hardness")
  404. {
  405. return dt.Rows[it]["Hardness_detailed"].ToString();
  406. }
  407. else
  408. if (str == "Area")
  409. {
  410. return Convert.ToDouble(dt.Rows[it][str]).ToString("#0.00");
  411. }
  412. else
  413. if (str== "DMAX")
  414. {
  415. return Math.Round(Convert.ToDouble(dt.Rows[it][str]), 2).ToString();
  416. }
  417. else
  418. {
  419. return dt.Rows[it][str].ToString();
  420. }
  421. }
  422. private bool JudgeWhetherItExists(int id, DataTable dt,string column)
  423. {
  424. for (int i=0;i<dt.Rows.Count;i++)
  425. {
  426. if (id == Convert.ToInt32(dt.Rows[i][column].ToString()))
  427. return true;
  428. }
  429. return false;
  430. }
  431. #endregion
  432. #region 插入颗粒尺寸表
  433. private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName )
  434. {
  435. DataTable dt_Class = dataTable.Copy();
  436. dt_Class.Clear();
  437. dt_Class.TableName = "Particel";
  438. dt_Class.Columns.Remove("Name");
  439. dt_Class.Columns.Remove("TypeId");
  440. for (int i = 0; i < ClassName.Count; i++)
  441. {
  442. //保留当前循环中大类物质,去除其他物质
  443. DataTable dt = dataTable.Copy();
  444. dt.Clear();
  445. for (int a = 0; a < dataTable.Rows.Count; a++)
  446. {
  447. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  448. {
  449. dt.Rows.Add(dataTable.Rows[a].ItemArray);
  450. }
  451. }
  452. if (dt.Rows.Count == 0)
  453. continue;
  454. DataTable dt_2 = new DataTable();
  455. dt_2 = dataTable.Copy();
  456. dt_2.Clear();
  457. DataRow row = dt_2.NewRow();
  458. dt_2.Rows.Add(row);
  459. for (int a=0;a< dt.Columns.Count;a++)
  460. {
  461. if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class"&&dt.Columns[a].ToString()!= "TypeId")
  462. {
  463. bool bl = false;
  464. for (int b = 0; b < dt.Rows.Count; b++)
  465. {
  466. if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
  467. {
  468. bl = true;
  469. }
  470. }
  471. if (bl)
  472. {
  473. dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
  474. }
  475. }
  476. }
  477. dt_2.Columns.Remove("Name");
  478. dt_2.Columns.Remove("TypeId");
  479. dt_2.Rows[0]["Class"] = ClassName[i];
  480. //dt_2.Rows[0]["TypeId"] = dt.Rows[0]["TypeId"].ToString();
  481. dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
  482. }
  483. m_list_dt.Add(dt_Class);
  484. return dt_Class;
  485. }
  486. #endregion
  487. #region 插入平均元素含量表
  488. private DataTable ElementSorting( DataTable AllAnalysisDetails, List<string> ClassName , ParticleData fielddata)
  489. {
  490. DataTable dte = fielddata.GetAllElement();
  491. DataTable ElementSorting_dt = AllAnalysisDetails.Copy();
  492. ElementSorting_dt.Clear();
  493. for (int i=0; i< ClassName.Count;i++)
  494. {
  495. DataTable dt = AllAnalysisDetails.Copy();
  496. dt.Clear();
  497. for (int a=0;a< AllAnalysisDetails.Rows.Count;a++)
  498. {
  499. if (AllAnalysisDetails.Rows[a]["Class"].ToString()== ClassName[i].ToString())
  500. {
  501. dt.Rows.Add(AllAnalysisDetails.Rows[a].ItemArray);
  502. }
  503. }
  504. //将颗粒大小排序(从大到小)
  505. DataView dv = dt.DefaultView;
  506. dv.Sort = "Area DESC";
  507. DataTable dt_Element = dv.ToTable();
  508. for (int a=0;a< dt_Element.Rows.Count;a++)
  509. {
  510. ElementSorting_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  511. }
  512. }
  513. //循环创建元素列(类型定义为double,为以后计算做准备)
  514. for (int a = 0; a < dte.Rows.Count; a++)
  515. {
  516. ElementSorting_dt.Columns.Add(dte.Rows[a]["Name"].ToString(), typeof(double));
  517. }
  518. for (int a = 0; a < ElementSorting_dt.Rows.Count; a++)
  519. {
  520. DataTable ClassificationDetails = fielddata.GetAreaByIncA(ElementSorting_dt.Rows[a]["TypeId"].ToString(), "");//获取单个分类的元素信息
  521. //DataRow dr2 = ElementSorting_dt.NewRow();
  522. foreach (DataRow dr in ClassificationDetails.Rows)
  523. {
  524. double doe = Convert.ToDouble(dr["pc"]);
  525. ElementSorting_dt.Rows[a][dr["Name"].ToString()] = Math.Round( doe/Convert.ToDouble(ElementSorting_dt.Rows[a]["Area"]),2);
  526. }
  527. }
  528. return ElementSorting_dt;
  529. }
  530. private DataTable ElementalSubstance(DataTable AllAnalysisDetails, List<string> ClassName, ParticleData fielddata)
  531. {
  532. //当前元素物质类面积的总和
  533. double ElementalSubstance = 0;
  534. DataTable dte = fielddata.GetAllElement();
  535. DataTable dt_Class = new DataTable();
  536. dt_Class.Columns.Add("Name");
  537. dt_Class.Columns.Add("Area");
  538. //循环创建元素列(类型定义为double,为以后计算做准备)
  539. for (int a = 0; a < dte.Rows.Count; a++)
  540. {
  541. dt_Class.Columns.Add(dte.Rows[a]["Name"].ToString(), typeof(double));
  542. }
  543. //循环大类物质列表
  544. for (int i = 0; i < ClassName.Count; i++)
  545. {
  546. //保留当前循环中大类物质,去除其他物质
  547. DataTable dt = AllAnalysisDetails.Copy();
  548. dt.Clear();
  549. for (int a = 0; a < AllAnalysisDetails.Rows.Count; a++)
  550. {
  551. if (AllAnalysisDetails.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  552. {
  553. dt.Rows.Add(AllAnalysisDetails.Rows[a].ItemArray);
  554. }
  555. }
  556. if (dt.Rows.Count == 0)
  557. continue;
  558. //计算出当前循环中大类物质的面积
  559. ElementalSubstance=Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
  560. DataTable ta = new DataTable();
  561. ta = dt_Class.Copy();
  562. ta.Clear();
  563. for (int a = 0; a < dt.Rows.Count; a++)
  564. {
  565. DataTable ClassificationDetails = fielddata.GetAreaByIncA(dt.Rows[a]["TypeId"].ToString(), "");//获取单个分类的元素信息
  566. DataRow dr2 = ta.NewRow();
  567. foreach (DataRow dr in ClassificationDetails.Rows)
  568. {
  569. double doe = Convert.ToDouble(dr["pc"]);
  570. dr2[dr["Name"].ToString()] = doe;
  571. }
  572. ta.Rows.Add(dr2);
  573. }
  574. DataTable dataTable = ta.Copy();
  575. dataTable.Clear();
  576. DataRow row = dataTable.NewRow();
  577. dataTable.Rows.Add(row);
  578. for (int a=0;a< ta.Columns.Count;a++)
  579. {
  580. if (ta.Columns[a].ToString()!="Name"&& ta.Columns[a].ToString() !="Class")
  581. {
  582. bool bl = false;
  583. for (int b=0;b<ta.Rows.Count;b++)
  584. {
  585. if (!ta.Rows[b].IsNull(ta.Columns[a].ToString()))
  586. {
  587. bl = true;
  588. }
  589. }
  590. if (bl)
  591. //datatSuncolumn(ta, ta.Columns[a].ToString());
  592. dataTable.Rows[0][ta.Columns[a].ToString()] = Math.Round(datatSuncolumn(ta, ta.Columns[a].ToString()) / ElementalSubstance,2);
  593. }
  594. }
  595. dataTable.Rows[0]["Name"] = ClassName[i].ToString();
  596. dataTable.Rows[0]["Area"] = ElementalSubstance;
  597. dt_Class.Rows.Add(dataTable.Rows[0].ItemArray);
  598. }
  599. return dt_Class;
  600. }
  601. private double datatSuncolumn(DataTable dt ,string str)
  602. {
  603. double sum=0;
  604. for (int i=0;i<dt.Rows.Count;i++)
  605. {
  606. if (dt.Rows[i][str].ToString()=="")
  607. {
  608. dt.Rows[i][str] = 0;
  609. }
  610. sum = sum+Convert.ToDouble(dt.Rows[i][str].ToString());
  611. }
  612. return sum;
  613. }
  614. private DataTable MaterialElementComposition(DataTable a_ElementalSubstance,int NumberOfColumns)
  615. {
  616. DataTable dt_ElementalSubstance = new DataTable();
  617. dt_ElementalSubstance.TableName = "ElementalSubstance_Value";
  618. dt_ElementalSubstance.Columns.Add("Name");
  619. dt_ElementalSubstance.Columns.Add("Area");
  620. for (int i=0;i< a_ElementalSubstance.Rows.Count;i++)
  621. {
  622. dt_ElementalSubstance.Rows.Add(a_ElementalSubstance.Rows[i]["Name"]);
  623. dt_ElementalSubstance.Rows[i]["Area"]=Math.Round(Convert.ToDouble(a_ElementalSubstance.Rows[i]["Area"]),2) ;
  624. }
  625. int cunt = 1;
  626. for (int i=0;i< NumberOfColumns; i++)
  627. {
  628. if (i< m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Count())
  629. {
  630. dt_ElementalSubstance.Columns.Add(m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]);
  631. for (int a=0;a< a_ElementalSubstance.Rows.Count;a++)
  632. {
  633. if (a_ElementalSubstance.Columns.Contains(m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]))
  634. {
  635. if (a_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]].ToString() == "")
  636. {
  637. dt_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]] = 0;
  638. }
  639. else
  640. {
  641. 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]];
  642. }
  643. }
  644. else
  645. {
  646. dt_ElementalSubstance.Rows[a][m_otsreport_export.m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys[i]] = 0;
  647. }
  648. }
  649. }
  650. else
  651. {
  652. dt_ElementalSubstance.Columns.Add("Null"+ cunt.ToString());
  653. cunt = cunt + 1;
  654. for (int a = 0; a < a_ElementalSubstance.Rows.Count; a++)
  655. {
  656. dt_ElementalSubstance.Rows[a][i+2] = "-";
  657. }
  658. }
  659. }
  660. DataTable dataTable = new DataTable();
  661. dataTable = dt_ElementalSubstance.Copy();
  662. dataTable.Clear();
  663. DataRow row = dataTable.NewRow();
  664. dataTable.Rows.Add(row);
  665. dataTable.TableName = "ElementalSubstance_Name";
  666. for (int i=0;i< dataTable.Columns.Count;i++)
  667. {
  668. dataTable.Rows[0][dataTable.Columns[i].ToString()] = dataTable.Columns[i].ToString();
  669. }
  670. m_list_dt.Add(dataTable);
  671. m_list_dt.Add(dt_ElementalSubstance);
  672. return dt_ElementalSubstance;
  673. }
  674. #endregion
  675. #region 其它部份
  676. /// <summary>
  677. /// 输入颗粒的所在帧图id,颗粒id,颗粒类型id,获取对应的XRay能谱数据图
  678. /// </summary>
  679. /// <returns></returns>
  680. public Bitmap ExportXRayBitmap(string in_fieldid, string in_particleid, int in_stdtypeid, string TypeName, ParticleData particleData)
  681. {
  682. Bitmap ret_bp;
  683. //显示xray相关信息
  684. uint[] Search_xray = new uint[2000];
  685. uint[] Analysis_xray = new uint[2000];
  686. //
  687. int i_xray_id = 0;
  688. List<Element> list_celementchemistryclr = new List<Element>();
  689. //获取Xray数据
  690. list_celementchemistryclr = new List<Element>();
  691. Particle list = particleData.GetParticleByFidAndPid(in_fieldid, in_particleid);
  692. if (list == null)
  693. {
  694. return null;
  695. }
  696. Particle particle = list;
  697. if (particle.XrayId > -1)
  698. {
  699. for (int i = 0; i < 2000; i++)
  700. {
  701. if (particle.XRayData!=null)
  702. {
  703. Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
  704. }
  705. }
  706. Search_xray = Analysis_xray;
  707. i_xray_id = particle.XrayId;
  708. list_celementchemistryclr = particle.ElementList;
  709. }
  710. //get CElementChemistryClr list
  711. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  712. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  713. {
  714. ShowElementInfo ls_sei = new ShowElementInfo();
  715. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  716. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  717. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  718. list_showelementinfo.Add(ls_sei);
  719. }
  720. //获取使用标准库的名称
  721. string str_stdname = "";
  722. string str_IncALibName = "";
  723. if (in_stdtypeid < 1000)
  724. {
  725. //小于1000,使用系统默认分类
  726. str_IncALibName = TypeName;
  727. str_stdname = "Default standard library";
  728. }
  729. else if (in_stdtypeid >= 1000 && in_stdtypeid < 10000)
  730. {
  731. //大于等于1000,并且小于10000时,使用系统数据库中夹杂物来分析
  732. str_IncALibName = TypeName;
  733. str_stdname = "User defined standard library";
  734. }
  735. else if (in_stdtypeid > 10000)
  736. {
  737. //大于10000时,使用用户标准库来分析夹杂物名称
  738. str_IncALibName = TypeName;
  739. str_stdname = "System standard library";
  740. }
  741. //获取数据后,需要对xraytable设置
  742. OTSIncAReportGraph.Controls.Control_XRayTable control_XRayTable1 = new Control_XRayTable();
  743. control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);
  744. //颗粒国标信息
  745. //control_XRayTable1.GBInfoStr = in_dparticle.GBContent;
  746. control_XRayTable1.MaterialName = str_IncALibName;//杂夹物
  747. control_XRayTable1.STDName = str_stdname;//标准库
  748. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  749. control_XRayTable1.Visible = true;
  750. control_XRayTable1.Invalidate();
  751. control_XRayTable1.Refresh();
  752. ret_bp = control_XRayTable1.ExportXRayImage();
  753. return ret_bp;
  754. }
  755. /// <summary>
  756. /// 传入DataTable,和行号,返回该Row行中,返回6个靠前的元素,不足6个返回空
  757. /// </summary>
  758. /// <param name="in_dt"></param>
  759. /// <param name="row_index"></param>
  760. /// <returns></returns>
  761. private void GetMaxElementFromDataTable(DataTable in_dt, int row_index, out List<string> out_list_elementname, out List<double> out_list_elementvalue)
  762. {
  763. out_list_elementname = new List<string>();
  764. out_list_elementvalue = new List<double>();
  765. //分别排出元素名,元素值列表
  766. List<string> list_elementname = new List<string>();
  767. List<double> list_elementvalue = new List<double>();
  768. string str_element = in_dt.Rows[row_index]["Element"].ToString();
  769. //防止取出的元素信息为空
  770. if (str_element != "")
  771. {
  772. string[] strcbo = str_element.Split(';');
  773. for (int i = 0; i < strcbo.Length-1; i++)
  774. {
  775. string[] str = strcbo[i].Split('-');
  776. list_elementname.Add(str[0]);
  777. list_elementvalue.Add(Math.Round(Convert.ToDouble(str[1]), 2));
  778. }
  779. }
  780. //循环6次,得到最大的6个元素信息
  781. for (int geti = 0; geti < 11; geti++)
  782. {
  783. double max_elementvalue = -1;
  784. string max_elementname = " ";
  785. int max_index = -1;
  786. if (list_elementvalue.Count > 0)
  787. {
  788. for (int i = 0; i < list_elementvalue.Count; i++)
  789. {
  790. if (list_elementvalue[i] > max_elementvalue)
  791. {
  792. max_elementvalue = list_elementvalue[i];
  793. max_elementname = list_elementname[i];
  794. max_index = i;
  795. }
  796. }
  797. //移除掉最大的元素
  798. list_elementname.RemoveAt(max_index);
  799. list_elementvalue.RemoveAt(max_index);
  800. //将最大的元素添加到list中
  801. if (max_elementvalue > 0)
  802. {
  803. out_list_elementname.Add(max_elementname);
  804. out_list_elementvalue.Add(max_elementvalue);
  805. }
  806. else
  807. {
  808. out_list_elementname.Add(" ");
  809. out_list_elementvalue.Add(0);
  810. }
  811. }
  812. else
  813. {
  814. //如果元素数量已经不够,则添加空
  815. out_list_elementname.Add(" ");
  816. out_list_elementvalue.Add(0);
  817. }
  818. }
  819. }
  820. #endregion
  821. /// <summary>
  822. /// 国标一
  823. /// </summary>
  824. /// <returns></returns>
  825. public List<DataTable> InsertReportTemplateTable_ChineseStandardABCDDS(OTSCLRINTERFACE.CPropParamClr cPropParamClr, List<string> datasourcelist , int DataSourceId ,int GB_index)
  826. {
  827. //得到国标一的DataTable表格
  828. cPropParamClr.SetDataSourceList(datasourcelist);
  829. cPropParamClr.SetDataSourceId(DataSourceId);//
  830. cPropParamClr.SetType((int)OTSSampleReportInfo.DisplayPicutureType.AnalyzeDataTable);//table
  831. cPropParamClr.SetCalTableType(GB_index);//国标1
  832. if (GB_index == (int)OTSSampleReportInfo.CALCULATE_TABLE_TYPE.GB_Method1)
  833. {
  834. List<OTSCLRINTERFACE.CGridDataClr> listGriddataclr = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GridDataTransfer(cPropParamClr);
  835. m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS = new OTSIncAReportGB.ChineseStandardABCDDS(m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr, listGriddataclr);
  836. m_otsreport_export.m_ReportApp.m_TablesWindow.Controls.Clear();
  837. return m_otsreport_export.m_ReportApp.im_ChineseStandardABCDDS.ChineseStandardABCD_GetDataTable(); ;
  838. }
  839. else
  840. {
  841. List<OTSCLRINTERFACE.CGridDataClr> listGriddataclr2 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GridDataTransfer(cPropParamClr);//
  842. m_otsreport_export.m_ReportApp.m_TablesWindow.Controls.Clear();
  843. m_otsreport_export.m_ReportApp.im_NationalStandardMethodTwo = new OTSIncAReportGB.NationalStandardMethodTwo(m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr, listGriddataclr2);
  844. return m_otsreport_export.m_ReportApp.im_NationalStandardMethodTwo.ChineseStandardABCD_GetDataTable();
  845. }
  846. }
  847. //-------------------------------------------------dev----------------------------------------------------------
  848. /// <summary>
  849. /// DEV颗粒列表颗粒前20个谱图排序
  850. /// </summary>
  851. /// <param name="m_mbszclass"></param>
  852. /// <returns></returns>
  853. public DataTable Get_dev_kllb_data(c_TemplateClass m_mbszclass)
  854. {
  855. int serialNumber = 1;
  856. //------------------加载模块,获取数据-------------------------------------------------
  857. m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
  858. DataTable SelectParticleTable = new DataTable();
  859. SelectParticleData(out SelectParticleTable);
  860. int sel = 0;
  861. if (m_mbszclass.M_SY.int_xzkl == 0)
  862. {
  863. sel = 0;
  864. }
  865. else
  866. {
  867. sel = 1;
  868. }
  869. //根据sql条件,查询获取颗粒信息数据
  870. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  871. DataTable dt = InvalidRemoval(fielddata.GetIncaSurfaceData(SelectParticleTable, sel, m_mbszclass.M_KLLBXX.list_str_kllb_qcys), "TypeName");
  872. ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
  873. //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resfile.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
  874. string str_libraryName = resfile.GetSTDName();
  875. //string str_libraryName = resfile.GetSTDName();
  876. //float PixelSize = resfile.GetPixelSize();
  877. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.CleannessA)
  878. {
  879. dt.Columns.Add("Hardness", typeof(double));
  880. dt.Columns.Add("Hardness_detailed");
  881. DataTable dt_stl = new DataTable();
  882. if (GetSTL(str_libraryName, out dt_stl))
  883. {
  884. for (int i = 0; i < dt.Rows.Count; i++)
  885. {
  886. for (int a = 0; a < dt_stl.Rows.Count; a++)
  887. {
  888. if (dt.Rows[i]["TypeName"].ToString() == dt_stl.Rows[a]["TypeId"].ToString())
  889. {
  890. dt.Rows[i]["Hardness"] = Convert.ToDouble(dt_stl.Rows[a]["Hardness"]);
  891. dt.Rows[i]["Hardness_detailed"] = dt_stl.Rows[a]["Hardness_detailed"];
  892. break;
  893. }
  894. }
  895. }
  896. }
  897. }
  898. //去除物质分类(非夹杂物分类)
  899. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
  900. {
  901. for (int i = dt.Rows.Count-1; i >=0; i--)
  902. {
  903. if (dt.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
  904. {
  905. dt.Rows.RemoveAt(i);
  906. }
  907. }
  908. }
  909. //将颗粒大小排序(从大到小)
  910. DataView dv = dt.DefaultView;
  911. dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1.ToString() + " DESC";
  912. DataTable dt_ParticlesGridDevidePage = dv.ToTable();
  913. string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath;
  914. //------------------加载模块,获取数据结束----------------------------------------------
  915. #region 创建要插入数据库表结构
  916. //插入模板需父子表,结构
  917. //表名field_dt表:(父表) 帧图表
  918. DataTable DT_field_dt = new DataTable();
  919. DT_field_dt.TableName = "field_dt";
  920. DataColumn colpictid2 = new DataColumn("FieldId");
  921. colpictid2.DataType = typeof(int);
  922. DT_field_dt.Columns.Add(colpictid2);
  923. //图像列
  924. DataColumn colpict2 = new DataColumn("FieldImg");
  925. colpict2.DataType = System.Type.GetType("System.Byte[]");
  926. DT_field_dt.Columns.Add(colpict2);
  927. //largest20表:(无关系表) 需要显示前20条带有显示能谱图像的颗粒表
  928. DataTable DT_Largest20 = new DataTable();
  929. DT_Largest20.TableName = "Largest20";
  930. DT_Largest20.Columns.Add("pid");
  931. DT_Largest20.Columns.Add("Size");
  932. DT_Largest20.Columns.Add("Width");
  933. DT_Largest20.Columns.Add("DMAX");
  934. DT_Largest20.Columns.Add("DMIN");
  935. DT_Largest20.Columns.Add("Class");
  936. DT_Largest20.Columns.Add("ColName1");
  937. DT_Largest20.Columns.Add("ColName2");
  938. DT_Largest20.Columns.Add("ColName3");
  939. DT_Largest20.Columns.Add("ColName4");
  940. DT_Largest20.Columns.Add("ColName5");
  941. DT_Largest20.Columns.Add("ColName6");
  942. DT_Largest20.Columns.Add("ColName7");
  943. DT_Largest20.Columns.Add("ColName8");
  944. DT_Largest20.Columns.Add("ColName9");
  945. DT_Largest20.Columns.Add("ColName10");
  946. DT_Largest20.Columns.Add("ColVal1");
  947. DT_Largest20.Columns.Add("ColVal2");
  948. DT_Largest20.Columns.Add("ColVal3");
  949. DT_Largest20.Columns.Add("ColVal4");
  950. DT_Largest20.Columns.Add("ColVal5");
  951. DT_Largest20.Columns.Add("ColVal6");
  952. DT_Largest20.Columns.Add("ColVal7");
  953. DT_Largest20.Columns.Add("ColVal8");
  954. DT_Largest20.Columns.Add("ColVal9");
  955. DT_Largest20.Columns.Add("ColVal10");
  956. // 图像列
  957. DT_Largest20.Columns.Add("p1", typeof(Bitmap));
  958. DT_Largest20.Columns.Add("p2", typeof(Bitmap));
  959. DT_Largest20.Columns.Add("p3", typeof(Bitmap));
  960. #endregion
  961. #region 插入-前20颗粒部份
  962. for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
  963. {
  964. if (dt_ParticlesGridDevidePage.Rows[i_row].ItemArray[24].ToString() != "Not Identified")
  965. {
  966. //获取颗粒的fieldid,和particleid
  967. string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
  968. string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
  969. //string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
  970. string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
  971. string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
  972. string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
  973. //获取原始颗粒图像
  974. Bitmap bp_particle = new Bitmap(1, 1);
  975. string str_path = str_resultPath + "\\FIELD_FILES\\";
  976. string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
  977. if (str_fieldid == "-1")
  978. continue;
  979. //if (serialNumber > 20)
  980. if (serialNumber > m_mbszclass.M_KLLBXX.list_int_kllb_number)
  981. continue;
  982. 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"]) };
  983. Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
  984. bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
  985. 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() };
  986. //}
  987. //获取该颗粒的xray能谱图像
  988. System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
  989. str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
  990. Bitmap ls_xraybpnew = new Bitmap(1, 1);
  991. ls_xraybpnew = OTSIncAReportGraph.Class.DrawFunction.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理
  992. //获取该颗粒的二次放大处理图像
  993. Bitmap ls_processbitmap = new Bitmap(1, 1);
  994. ls_processbitmap = OTSIncAReportGraph.Class.DrawFunction.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善
  995. //再将图像转成二进制流-------------------------------------------------------------------
  996. //原图
  997. MemoryStream newms_p1 = new MemoryStream();
  998. bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
  999. //二次放大图
  1000. MemoryStream newms_p2 = new MemoryStream();
  1001. ls_processbitmap.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
  1002. //能谱图
  1003. MemoryStream newms_p3 = new MemoryStream();
  1004. ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
  1005. //---------------------------------------------------------------------------------------
  1006. DataRow dr = DT_Largest20.NewRow();
  1007. dr["p1"] = bp_particle;
  1008. dr["p2"] = ls_processbitmap;
  1009. dr["p3"] = ls_xraybpnew;
  1010. newms_p1.Dispose();
  1011. newms_p2.Dispose();
  1012. newms_p3.Dispose();
  1013. dr["pid"] = serialNumber++.ToString();
  1014. //颗粒列表列中第一个可选参数
  1015. dr["Size"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1);
  1016. //这个参数没有用
  1017. dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
  1018. //颗粒列表列中第二个可选参数
  1019. dr["DMAX"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p2);
  1020. //颗粒列表列中第三个可选参数
  1021. dr["DMIN"] = datatable_data(dt_ParticlesGridDevidePage, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p3);
  1022. //颗粒列表列中显示分类不可以选择
  1023. dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
  1024. GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
  1025. double colVal = 0;
  1026. for (int i=0;i< list_max_elementvale.Count;i++)
  1027. {
  1028. colVal = colVal + Convert.ToDouble(list_max_elementvale[i]);
  1029. }
  1030. //元素1
  1031. dr["ColName1"] = list_max_elementname[0];
  1032. dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
  1033. //元素2
  1034. dr["ColName2"] = list_max_elementname[1];
  1035. dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
  1036. //元素3
  1037. dr["ColName3"] = list_max_elementname[2] ;
  1038. dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
  1039. //元素4
  1040. dr["ColName4"] = list_max_elementname[3] ;
  1041. dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
  1042. //元素5
  1043. dr["ColName5"] = list_max_elementname[4] ;
  1044. dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
  1045. //元素6
  1046. dr["ColName6"] = list_max_elementname[5] ;
  1047. dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
  1048. //元素7
  1049. dr["ColName7"] = list_max_elementname[6];
  1050. dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
  1051. //元素8
  1052. dr["ColName8"] = list_max_elementname[7] ;
  1053. dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
  1054. //元素6
  1055. dr["ColName9"] = list_max_elementname[8] ;
  1056. dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
  1057. //元素6
  1058. dr["ColName9"] = list_max_elementname[9] ;
  1059. dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[9]);
  1060. DT_Largest20.Rows.Add(dr);
  1061. }
  1062. }
  1063. #endregion
  1064. return DT_Largest20;
  1065. }
  1066. /// <summary>
  1067. /// 参数归一化
  1068. /// </summary>
  1069. /// <param name="a_mi">总数</param>
  1070. /// <param name="m">传参</param>
  1071. /// <returns></returns>
  1072. public string ParameterNormalization(double a_mi,double m)
  1073. {
  1074. double ColVal = Convert.ToDouble(m / a_mi * 100);
  1075. if (ColVal == 0)
  1076. {
  1077. return "";
  1078. }
  1079. else
  1080. {
  1081. return Math.Round(ColVal, 2).ToString();
  1082. }
  1083. }
  1084. public void Get_dev_kllb_data_frame(c_TemplateClass m_mbszclass, out DataTable file_pic, out List<DataTable> list_dt)
  1085. {
  1086. //------------------加载模块,获取数据-------------------------------------------------
  1087. m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
  1088. SelectParticleData(out DataTable SelectParticleTable);
  1089. int sel = 0;
  1090. if (m_mbszclass.M_SY.int_xzkl == 0)
  1091. {
  1092. sel = 0;
  1093. }
  1094. else
  1095. {
  1096. sel = 1;
  1097. }
  1098. //根据sql条件,查询获取颗粒信息数据
  1099. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  1100. DataTable dt = InvalidRemoval(fielddata.GetIncaSurfaceData(SelectParticleTable, sel, m_mbszclass.M_KLLBXX.list_str_kllb_qcys), "TypeName");
  1101. ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
  1102. //string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resfile.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
  1103. string str_libraryName = resfile.GetSTDName();
  1104. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.CleannessA)
  1105. {
  1106. dt.Columns.Add("Hardness", typeof(double));
  1107. dt.Columns.Add("Hardness_detailed");
  1108. DataTable dt_stl = new DataTable();
  1109. if (GetSTL(str_libraryName, out dt_stl))
  1110. {
  1111. for (int i = 0; i < dt.Rows.Count; i++)
  1112. {
  1113. for (int a = 0; a < dt_stl.Rows.Count; a++)
  1114. {
  1115. if (dt.Rows[i]["TypeName"].ToString() == dt_stl.Rows[a]["TypeId"].ToString())
  1116. {
  1117. dt.Rows[i]["Hardness"] = Convert.ToDouble(dt_stl.Rows[a]["Hardness"]);
  1118. dt.Rows[i]["Hardness_detailed"] = dt_stl.Rows[a]["Hardness_detailed"];
  1119. break;
  1120. }
  1121. }
  1122. }
  1123. }
  1124. }
  1125. //去除物质分类(非夹杂物分类)
  1126. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
  1127. {
  1128. for (int i = dt.Rows.Count - 1; i >= 0; i--)
  1129. {
  1130. if (dt.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
  1131. {
  1132. dt.Rows.RemoveAt(i);
  1133. }
  1134. }
  1135. }
  1136. //将颗粒大小排序(从大到小)
  1137. DataView dv = dt.DefaultView;
  1138. dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1.ToString() + " DESC";
  1139. DataTable dt_ParticlesGridDevidePage = dv.ToTable();
  1140. string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath;
  1141. DataTable DT_field_dt = new DataTable();
  1142. DT_field_dt.TableName = "field_dt";
  1143. DT_field_dt.Columns.Add("FieldId", typeof(int));
  1144. //图像列
  1145. DT_field_dt.Columns.Add("FieldImg", typeof(Bitmap));
  1146. //首先生成标记颗粒的帧图图像文件
  1147. DataTable dt_GridDevidePage = dt_ParticlesGridDevidePage.Copy();
  1148. dt_GridDevidePage.Clear();
  1149. for (int i = 0; i < dt_ParticlesGridDevidePage.Rows.Count; i++)
  1150. {
  1151. if (dt_ParticlesGridDevidePage.Rows[i]["TypeName"].ToString() != "Not Identified")
  1152. {
  1153. dt_GridDevidePage.Rows.Add(dt_ParticlesGridDevidePage.Rows[i].ItemArray);
  1154. }
  1155. }
  1156. m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.Out_MarkParticleRectangleOnFieldFile(str_resultPath, dt_GridDevidePage, out List<string> vs, out DataTable data);
  1157. FrameGraphParticleTableDatat(dt_ParticlesGridDevidePage, fielddata, data, m_mbszclass, out DataTable data_A);
  1158. List<DataTable> listData = new List<DataTable>();
  1159. for (int i = 0; i < data.Rows.Count; i++)
  1160. {
  1161. DataTable dataTable = data_A.Clone();
  1162. //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
  1163. DataRow[] datarowlist = data_A.Select(data.Rows[i]["fieldid"].ToString());
  1164. if (datarowlist.Count() > 0)
  1165. {
  1166. for (int a = 0; a < data_A.Rows.Count; a++)
  1167. {
  1168. if (data.Rows[i]["id"].ToString() == data_A.Rows[a]["FieldId"].ToString())
  1169. {
  1170. dataTable.Rows.Add(data_A.Rows[a].ItemArray);
  1171. }
  1172. }
  1173. listData.Add(dataTable);
  1174. }
  1175. }
  1176. file_pic = data.Copy();
  1177. list_dt = listData;
  1178. }
  1179. private void FrameGraphParticleTableDatat(DataTable dt_ParticlesGridDevidePage, ParticleData fielddata, DataTable DT_field_dt, c_TemplateClass m_mbszclass, out DataTable data_A)
  1180. {
  1181. //将颗粒大小排序(从大到小)
  1182. DataView dv = dt_ParticlesGridDevidePage.DefaultView;
  1183. dv.Sort = m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p1.ToString() + " DESC";
  1184. DataTable dt = dv.ToTable();
  1185. //表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
  1186. DataTable FrameGraphSubTable = new DataTable();
  1187. FrameGraphSubTable.TableName = "FrameGraphSubTable";
  1188. FrameGraphSubTable.Columns.Add("pid");
  1189. FrameGraphSubTable.Columns.Add("Size");
  1190. FrameGraphSubTable.Columns.Add("Width");
  1191. FrameGraphSubTable.Columns.Add("DMAX");
  1192. FrameGraphSubTable.Columns.Add("DMIN");
  1193. FrameGraphSubTable.Columns.Add("Class");
  1194. FrameGraphSubTable.Columns.Add("ColName1");
  1195. FrameGraphSubTable.Columns.Add("ColName2");
  1196. FrameGraphSubTable.Columns.Add("ColName3");
  1197. FrameGraphSubTable.Columns.Add("ColName4");
  1198. FrameGraphSubTable.Columns.Add("ColName5");
  1199. FrameGraphSubTable.Columns.Add("ColName6");
  1200. FrameGraphSubTable.Columns.Add("ColName7");
  1201. FrameGraphSubTable.Columns.Add("ColName8");
  1202. FrameGraphSubTable.Columns.Add("ColName9");
  1203. FrameGraphSubTable.Columns.Add("ColName10");
  1204. FrameGraphSubTable.Columns.Add("ColVal1");
  1205. FrameGraphSubTable.Columns.Add("ColVal2");
  1206. FrameGraphSubTable.Columns.Add("ColVal3");
  1207. FrameGraphSubTable.Columns.Add("ColVal4");
  1208. FrameGraphSubTable.Columns.Add("ColVal5");
  1209. FrameGraphSubTable.Columns.Add("ColVal6");
  1210. FrameGraphSubTable.Columns.Add("ColVal7");
  1211. FrameGraphSubTable.Columns.Add("ColVal8");
  1212. FrameGraphSubTable.Columns.Add("ColVal9");
  1213. FrameGraphSubTable.Columns.Add("ColVal10");
  1214. FrameGraphSubTable.Columns.Add("pic", typeof(Bitmap));
  1215. FrameGraphSubTable.Columns.Add("FieldId", typeof(int));
  1216. ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
  1217. for (int i_row = 0; i_row < dt.Rows.Count; i_row++)
  1218. {
  1219. if (dt.Rows[i_row]["element"].ToString() == "")
  1220. continue;
  1221. if (dt.Rows[i_row]["TypeName"].ToString() == "Not Identified")
  1222. continue;
  1223. string str_fieldid = dt.Rows[i_row]["fieldid"].ToString();
  1224. if (JudgeWhetherItExists(Convert.ToInt32(str_fieldid), DT_field_dt, "id"))
  1225. {
  1226. //获取原始颗粒图像
  1227. Bitmap bp_particle = new Bitmap(1, 1);
  1228. Bitmap bp_field = new Bitmap(1, 1);
  1229. 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"]) };
  1230. for (int i = 0; i < DT_field_dt.Rows.Count; i++)
  1231. {
  1232. if (dt.Rows[i_row]["FieldId"].ToString() == DT_field_dt.Rows[i]["id"].ToString())
  1233. {
  1234. bp_field = new Bitmap(DT_field_dt.Rows[i]["fieldFullName"].ToString());
  1235. }
  1236. }
  1237. bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
  1238. bp_particle.Tag = new List<string>() { dt.Rows[i_row]["FieldId"].ToString(), dt.Rows[i_row]["ParticleId"].ToString(), dt.Rows[i_row]["TypeId"].ToString() };
  1239. DataRow dr = FrameGraphSubTable.NewRow();
  1240. //var bitmap = DrawRuler(bp_particle, (int)RulerPixels, 2);
  1241. //bitmap.Save("D:\\图片\\asd.bmp");
  1242. dr["pic"] = bp_particle;
  1243. //帧图列表列第一个字段的可选参数
  1244. dr["pid"] = datatable_data(dt, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p1);
  1245. //帧图列表列第二个字段的可选参数
  1246. dr["Size"] = datatable_data(dt, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_chartSort_p2);
  1247. dr["Width"] = dt.Rows[i_row]["rectwidth"].ToString();
  1248. dr["DMAX"] = Math.Round(Convert.ToDouble(dt.Rows[i_row]["dmax"]), 2).ToString();
  1249. dr["DMIN"] = Math.Round(Convert.ToDouble(dt.Rows[i_row]["dmin"]), 2).ToString();
  1250. dr["Class"] = dt.Rows[i_row]["typename"].ToString();
  1251. dr["fieldid"] = str_fieldid;
  1252. GetMaxElementFromDataTable(dt, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
  1253. double colVal = 0;
  1254. for (int i = 0; i < list_max_elementvale.Count; i++)
  1255. {
  1256. colVal = colVal + Convert.ToDouble(list_max_elementvale[i]);
  1257. }
  1258. //元素1
  1259. dr["ColName1"] = list_max_elementname[0] ;
  1260. dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
  1261. //元素2
  1262. dr["ColName2"] = list_max_elementname[1] ;
  1263. dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
  1264. //元素3
  1265. dr["ColName3"] = list_max_elementname[2] ;
  1266. dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
  1267. //元素4
  1268. dr["ColName4"] = list_max_elementname[3] ;
  1269. dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
  1270. //元素5
  1271. dr["ColName5"] = list_max_elementname[4] ;
  1272. dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
  1273. //元素6
  1274. dr["ColName6"] = list_max_elementname[5] ;
  1275. dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
  1276. //元素6
  1277. dr["ColName7"] = list_max_elementname[6] ;
  1278. dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
  1279. //元素6
  1280. dr["ColName8"] = list_max_elementname[7] ;
  1281. dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
  1282. //元素6
  1283. dr["ColName9"] = list_max_elementname[8] ;
  1284. dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
  1285. //元素6
  1286. dr["ColName10"] = list_max_elementname[9] ;
  1287. dr["ColVal10"] = ParameterNormalization(colVal, list_max_elementvale[9]);
  1288. FrameGraphSubTable.Rows.Add(dr);
  1289. }
  1290. }
  1291. data_A = FrameGraphSubTable.Copy();
  1292. }
  1293. 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)
  1294. {
  1295. //全部大类
  1296. DataTable dt_addCalss = new DataTable();
  1297. DataTable dt_allSubdivision = new DataTable();
  1298. //全部小类
  1299. if (m_bt_DBData.Columns.Count == 0)
  1300. {
  1301. GetDBData(m_mbszclass);
  1302. }
  1303. List<string> colid = new List<string>();
  1304. //获取粒级表
  1305. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  1306. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  1307. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1308. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  1309. {
  1310. if (sizestr.Split(',')[i].Length > 0)
  1311. {
  1312. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  1313. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  1314. colid.Add(d1.ToString() + "~" + d2.ToString());
  1315. }
  1316. }
  1317. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1318. colid.Add(d.ToString() + "~MAX");
  1319. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  1320. //------------------------------------------------
  1321. DataTable ls_partsize_dt = new DataTable();
  1322. ls_partsize_dt.TableName = "PartSize";
  1323. ls_partsize_dt.Columns.Add("c1");
  1324. ls_partsize_dt.Columns.Add("c2");
  1325. ls_partsize_dt.Columns.Add("c3");
  1326. ls_partsize_dt.Columns.Add("c4");
  1327. ls_partsize_dt.Columns.Add("c5");
  1328. ls_partsize_dt.Columns.Add("c6");
  1329. ls_partsize_dt.Columns.Add("c7");
  1330. ls_partsize_dt.Columns.Add("c8");
  1331. ls_partsize_dt.Columns.Add("c9");
  1332. DataRow dr = ls_partsize_dt.NewRow();
  1333. for (int i = 1; i < 10; i++)
  1334. {
  1335. if (colid.Count < i)
  1336. {
  1337. dr["c" + i.ToString()] = "";
  1338. }
  1339. else
  1340. {
  1341. dr["c" + i.ToString()] = colid[i - 1];
  1342. }
  1343. }
  1344. ls_partsize_dt.Rows.Add(dr);
  1345. DataTable ls_Particel_dt = new DataTable();
  1346. ls_Particel_dt.TableName = "Particel";
  1347. ls_Particel_dt.Columns.Add("c1", typeof(double));
  1348. ls_Particel_dt.Columns.Add("c2", typeof(double));
  1349. ls_Particel_dt.Columns.Add("c3", typeof(double));
  1350. ls_Particel_dt.Columns.Add("c4", typeof(double));
  1351. ls_Particel_dt.Columns.Add("c5", typeof(double));
  1352. ls_Particel_dt.Columns.Add("c6", typeof(double));
  1353. ls_Particel_dt.Columns.Add("c7", typeof(double));
  1354. ls_Particel_dt.Columns.Add("c8", typeof(double));
  1355. ls_Particel_dt.Columns.Add("c9", typeof(double));
  1356. ls_Particel_dt.Columns.Add("Name");
  1357. ls_Particel_dt.Columns.Add("total", typeof(double));
  1358. ls_Particel_dt.Columns.Add("TypeId");
  1359. ls_Particel_dt.Columns.Add("Class");
  1360. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  1361. {
  1362. DataRow dr2 = ls_Particel_dt.NewRow();
  1363. dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
  1364. dr2["Class"] = m_bt_DBData.Rows[i]["Class"].ToString();
  1365. dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();//获取分类编号
  1366. for (int j = 1; j < 10; j++)
  1367. {
  1368. if (colid.Count >= j)
  1369. {
  1370. dr2["c" + j.ToString()] = Convert.ToDouble(m_bt_DBData.Rows[i][colid[j - 1]]);
  1371. }
  1372. }
  1373. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  1374. {
  1375. dr2["total"] = "0"; //求合
  1376. double d_total = 0;
  1377. for (int j = 1; j < 10; j++)
  1378. {
  1379. if (colid.Count >= j)
  1380. {
  1381. d_total = d_total + Convert.ToInt64(m_bt_DBData.Rows[i][colid[j - 1]]);
  1382. }
  1383. }
  1384. dr2["total"] = d_total.ToString();
  1385. }
  1386. ls_Particel_dt.Rows.Add(dr2);
  1387. }
  1388. dt_allSubdivision = ls_Particel_dt.Copy();
  1389. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  1390. List<string> ClassName = new List<string>();
  1391. DataTable getClass_dt = fielddata.GetAllClass();
  1392. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1393. {
  1394. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  1395. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  1396. ClassName.Add("NULL");
  1397. else
  1398. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1399. }
  1400. //颗粒尺寸数据(例 1.5有多少,2.0有多少)
  1401. colid_data = new DataTable();
  1402. colid_data.Columns.Add("name");
  1403. colid_data.Columns.Add("quantity",typeof(double));
  1404. for (int i=0;i< ls_Particel_dt.Columns.Count;i++)
  1405. {
  1406. if (ls_Particel_dt.Columns[i].ColumnName=="c"+(i+1).ToString())
  1407. {
  1408. if (i< colid.Count)
  1409. {
  1410. DataRow dr1 = colid_data.NewRow();
  1411. dr1["name"] = colid[i].ToString();
  1412. int quantity = 0;
  1413. for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
  1414. {
  1415. quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
  1416. }
  1417. dr1["quantity"] = quantity.ToString();
  1418. colid_data.Rows.Add(dr1);
  1419. }
  1420. }
  1421. }
  1422. //获取大分类信息
  1423. DataTable dt = InvalidRemoval(QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName), "Class");
  1424. dt_addCalss = dt.Copy();
  1425. DataTable data = classIfIcationSort(ls_Particel_dt, ClassName, dt);
  1426. surface_dt = data.Copy();
  1427. class_dt = dt_addCalss.Copy();
  1428. subdivide_dt = dt_allSubdivision.Copy();
  1429. partsize_dt = ls_partsize_dt.Copy();
  1430. }
  1431. public DataTable ParticleResults(c_TemplateClass m_mbszclass)
  1432. {
  1433. if (m_bt_DBData.Columns.Count == 0)
  1434. {
  1435. GetDBData(m_mbszclass);
  1436. }
  1437. List<string> colid = new List<string>();
  1438. //获取粒级表
  1439. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  1440. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  1441. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1442. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  1443. {
  1444. if (sizestr.Split(',')[i].Length > 0)
  1445. {
  1446. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  1447. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  1448. colid.Add(d1.ToString() + "~" + d2.ToString());
  1449. }
  1450. }
  1451. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1452. colid.Add(d.ToString() + "~MAX");
  1453. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  1454. //------------------------------------------------
  1455. DataTable ls_partsize_dt = new DataTable();
  1456. ls_partsize_dt.TableName = "PartSize";
  1457. ls_partsize_dt.Columns.Add("c1");
  1458. ls_partsize_dt.Columns.Add("c2");
  1459. ls_partsize_dt.Columns.Add("c3");
  1460. ls_partsize_dt.Columns.Add("c4");
  1461. ls_partsize_dt.Columns.Add("c5");
  1462. ls_partsize_dt.Columns.Add("c6");
  1463. ls_partsize_dt.Columns.Add("c7");
  1464. ls_partsize_dt.Columns.Add("c8");
  1465. ls_partsize_dt.Columns.Add("c9");
  1466. ls_partsize_dt.Columns.Add("c10");
  1467. DataRow dr = ls_partsize_dt.NewRow();
  1468. for (int i = 1; i < 11; i++)
  1469. {
  1470. if (colid.Count < i)
  1471. {
  1472. dr["c" + i.ToString()] = " ";
  1473. }
  1474. else
  1475. {
  1476. dr["c" + i.ToString()] = colid[i - 1];
  1477. }
  1478. }
  1479. ls_partsize_dt.Rows.Add(dr);
  1480. DataTable ls_Particel_dt = new DataTable();
  1481. ls_Particel_dt.TableName = "Particel";
  1482. ls_Particel_dt.Columns.Add("c1");
  1483. ls_Particel_dt.Columns.Add("c2");
  1484. ls_Particel_dt.Columns.Add("c3");
  1485. ls_Particel_dt.Columns.Add("c4");
  1486. ls_Particel_dt.Columns.Add("c5");
  1487. ls_Particel_dt.Columns.Add("c6");
  1488. ls_Particel_dt.Columns.Add("c7");
  1489. ls_Particel_dt.Columns.Add("c8");
  1490. ls_Particel_dt.Columns.Add("c9");
  1491. ls_Particel_dt.Columns.Add("c10");
  1492. ls_Particel_dt.Columns.Add("Name");
  1493. ls_Particel_dt.Columns.Add("total");
  1494. ls_Particel_dt.Columns.Add("TypeId");
  1495. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  1496. {
  1497. DataRow dr2 = ls_Particel_dt.NewRow();
  1498. dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
  1499. dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();//获取分类编号
  1500. for (int j = 1; j < 11; j++)
  1501. {
  1502. if (colid.Count >= j)
  1503. {
  1504. double de = Convert.ToDouble(m_bt_DBData.Rows[i][colid[j - 1]]);
  1505. if (de == 0)
  1506. dr2["c" + j.ToString()] = " ";
  1507. else
  1508. dr2["c" + j.ToString()] = de.ToString();
  1509. }
  1510. }
  1511. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  1512. {
  1513. dr2["total"] = " "; //求合
  1514. double d_total = 0;
  1515. for (int j = 1; j < 11; j++)
  1516. {
  1517. if (colid.Count >= j)
  1518. {
  1519. d_total = d_total + Convert.ToInt64(m_bt_DBData.Rows[i][colid[j - 1]]);
  1520. }
  1521. }
  1522. if (d_total == 0)
  1523. {
  1524. continue;
  1525. dr2["total"] = " ";
  1526. }
  1527. else
  1528. dr2["total"] = d_total.ToString();
  1529. }
  1530. ls_Particel_dt.Rows.Add(dr2);
  1531. }
  1532. return ls_Particel_dt;
  1533. }
  1534. public DataTable TypeRange()
  1535. {
  1536. List<string> colid = new List<string>();
  1537. //获取粒级表
  1538. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  1539. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  1540. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1541. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  1542. {
  1543. if (sizestr.Split(',')[i].Length > 0)
  1544. {
  1545. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  1546. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  1547. colid.Add(d1.ToString() + "≤ X<" + d2.ToString());
  1548. }
  1549. }
  1550. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1551. colid.Add(d.ToString() + "≤ X<MAX");
  1552. DataTable ls_partsize_dt = new DataTable();
  1553. ls_partsize_dt.TableName = "PartSize";
  1554. ls_partsize_dt.Columns.Add("c1");
  1555. ls_partsize_dt.Columns.Add("c2");
  1556. ls_partsize_dt.Columns.Add("c3");
  1557. ls_partsize_dt.Columns.Add("c4");
  1558. ls_partsize_dt.Columns.Add("c5");
  1559. ls_partsize_dt.Columns.Add("c6");
  1560. ls_partsize_dt.Columns.Add("c7");
  1561. ls_partsize_dt.Columns.Add("c8");
  1562. ls_partsize_dt.Columns.Add("c9");
  1563. ls_partsize_dt.Columns.Add("c10");
  1564. ls_partsize_dt.Columns.Add("c11");
  1565. ls_partsize_dt.Columns.Add("c12");
  1566. DataRow dr = ls_partsize_dt.NewRow();
  1567. for (int i = 1; i < 13; i++)
  1568. {
  1569. if (colid.Count < i)
  1570. {
  1571. dr["c" + i.ToString()] = "";
  1572. }
  1573. else
  1574. {
  1575. dr["c" + i.ToString()] = colid[i - 1];
  1576. }
  1577. }
  1578. ls_partsize_dt.Rows.Add(dr);
  1579. return ls_partsize_dt;
  1580. }
  1581. public void ChemistryTable(c_TemplateClass m_mbszclass, out DataTable b1,out DataTable b2)
  1582. {
  1583. if (m_bt_DBData.Columns.Count == 0)
  1584. {
  1585. GetDBData(m_mbszclass);
  1586. }
  1587. //根据sql条件,查询获取颗粒信息数据
  1588. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  1589. DataTable AllAnalysisDetails = new DataTable();
  1590. AllAnalysisDetails.TableName = "ElementValue";
  1591. AllAnalysisDetails.Columns.Add("Name");
  1592. AllAnalysisDetails.Columns.Add("TypeId");
  1593. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  1594. AllAnalysisDetails.Columns.Add("Class");
  1595. AllAnalysisDetails.Columns.Add("con");
  1596. double total = 0;
  1597. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  1598. {
  1599. DataRow dr2 = AllAnalysisDetails.NewRow();
  1600. dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
  1601. dr2["Area"] = Convert.ToDouble(m_bt_DBData.Rows[i]["ar"]);
  1602. dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();
  1603. dr2["Class"] = m_bt_DBData.Rows[i]["Class"].ToString();
  1604. dr2["con"] = m_bt_DBData.Rows[i]["con"].ToString();
  1605. total += Convert.ToInt32(m_bt_DBData.Rows[i]["con"]);
  1606. AllAnalysisDetails.Rows.Add(dr2);
  1607. }
  1608. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  1609. List<string> ClassName = new List<string>();
  1610. DataTable getClass_dt = fielddata.GetAllClass();
  1611. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1612. {
  1613. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  1614. //ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1615. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  1616. ClassName.Add("NULL");
  1617. else
  1618. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1619. }
  1620. //统计元素物质大类的元素信息和面积占比
  1621. DataTable dt_ElementalSubstance = ElementalSubstance(AllAnalysisDetails, ClassName, fielddata);
  1622. //统计元素并按照Class Name自定义列表进行排序,大类中的小类元素信息按照面积从大到小排序
  1623. DataTable dt_ElementSorting = ElementSorting(AllAnalysisDetails, ClassName, fielddata);
  1624. //生成最后导出时物质元素成分表
  1625. DataTable dt = MaterialElementComposition(dt_ElementalSubstance, 13);//导出14个元素成分信息
  1626. //生成最后导出时物质元素细分表
  1627. SubdivisionOfMaterialElements(dt_ElementSorting, 13, ClassName, dt, out DataTable dt1, out DataTable dt2);
  1628. dt2.Columns.Add("con");
  1629. dt2.Columns.Add("per");
  1630. dt1.Columns.Add("con");
  1631. dt1.Columns.Add("per");
  1632. DataTable table = dt2.Copy();
  1633. table.Clear();
  1634. //table.Columns.Add("con");
  1635. int inxe = 0;
  1636. for(int i=0;i< dt2.Rows.Count;i++)
  1637. {
  1638. if(string.IsNullOrWhiteSpace(dt2.Rows[i]["Class"].ToString()))
  1639. {
  1640. for (int a=0;a< AllAnalysisDetails.Rows.Count;a++)
  1641. {
  1642. if(dt2.Rows[i]["Name"].ToString()== AllAnalysisDetails.Rows[a]["Name"].ToString())
  1643. {
  1644. dt2.Rows[i]["con"] = AllAnalysisDetails.Rows[a]["con"];
  1645. dt2.Rows[i]["per"] = (Convert.ToDouble(AllAnalysisDetails.Rows[a]["con"]) / total) * 100;
  1646. }
  1647. }
  1648. table.Rows.Add(dt2.Rows[i].ItemArray);
  1649. }
  1650. inxe++;
  1651. }
  1652. b1 = dt1.Copy();
  1653. b2 = table.Copy();
  1654. //return dt;
  1655. }
  1656. private DataTable classIfIcationSort(DataTable dataTable, List<string> ClassName, DataTable data)
  1657. {
  1658. DataTable dt = new DataTable();
  1659. dt = dataTable.Copy();
  1660. dt.Clear();
  1661. dt.TableName = "Particel_subdivision";
  1662. //循环list中每个类型
  1663. for (int i = 0; i < ClassName.Count(); i++)
  1664. {
  1665. DataTable data1 = dt.Copy();
  1666. data1.Clear();
  1667. data1.Rows.Add();
  1668. for (int a = 0; a < data.Rows.Count; a++)
  1669. {
  1670. if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  1671. {
  1672. for (int b = 1; b < 10; b++)
  1673. {
  1674. data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()];
  1675. }
  1676. data1.Rows[0]["total"] = data.Rows[a]["total"];
  1677. data1.Rows[0]["Class"] = data.Rows[a]["Class"];
  1678. dt.Rows.Add(data1.Rows[0].ItemArray);
  1679. }
  1680. }
  1681. DataTable dt_1 = new DataTable();
  1682. dt_1 = dt.Copy();
  1683. dt_1.Clear();
  1684. //循环DataTable中每个分类的数据
  1685. for (int a = 0; a < dataTable.Rows.Count; a++)
  1686. {
  1687. if (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
  1688. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  1689. {
  1690. dataTable.Rows[a]["Class"] = "";
  1691. dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
  1692. }
  1693. }
  1694. //将颗粒数量排序(从大到小)
  1695. DataView dv = dt_1.DefaultView;
  1696. dv.Sort = "total DESC";
  1697. DataTable dt_1_sort = dv.ToTable();
  1698. for (int a = 0; a < dt_1_sort.Rows.Count; a++)
  1699. {
  1700. dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
  1701. }
  1702. }
  1703. dt.Columns.Remove("TypeId");
  1704. return dt;
  1705. }
  1706. public bool InsertReportTemplateTable_ElementAvgGrid(c_TemplateClass m_mbszclass, out DataTable dt1, out DataTable dt2,out DataTable allElement_dt)
  1707. {
  1708. if (m_bt_DBData.Columns.Count == 0)
  1709. {
  1710. GetDBData(m_mbszclass);
  1711. }
  1712. //根据sql条件,查询获取颗粒信息数据
  1713. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  1714. DataTable AllAnalysisDetails = new DataTable();
  1715. AllAnalysisDetails.TableName = "ElementValue";
  1716. AllAnalysisDetails.Columns.Add("Name");
  1717. AllAnalysisDetails.Columns.Add("TypeId");
  1718. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  1719. AllAnalysisDetails.Columns.Add("Class");
  1720. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  1721. {
  1722. DataRow dr2 = AllAnalysisDetails.NewRow();
  1723. dr2["Name"] = m_bt_DBData.Rows[i]["TypeName"].ToString();
  1724. dr2["Area"] = Convert.ToDouble(m_bt_DBData.Rows[i]["ar"]);
  1725. dr2["TypeId"] = m_bt_DBData.Rows[i]["TypeId"].ToString();
  1726. dr2["Class"] = m_bt_DBData.Rows[i]["Class"].ToString();
  1727. AllAnalysisDetails.Rows.Add(dr2);
  1728. }
  1729. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  1730. List<string> ClassName = new List<string>();
  1731. DataTable getClass_dt = fielddata.GetAllClass();
  1732. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1733. {
  1734. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  1735. //ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1736. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  1737. ClassName.Add("NULL");
  1738. else
  1739. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1740. }
  1741. //统计元素物质大类的元素信息和面积占比
  1742. DataTable dt_ElementalSubstance = ElementalSubstance(AllAnalysisDetails, ClassName, fielddata);
  1743. //统计元素并按照Class Name自定义列表进行排序,大类中的小类元素信息按照面积从大到小排序
  1744. DataTable dt_ElementSorting = ElementSorting(AllAnalysisDetails, ClassName, fielddata);
  1745. //生成最后导出时物质元素成分表
  1746. DataTable dt = MaterialElementComposition(dt_ElementalSubstance, 13);//导出14个元素成分信息
  1747. //生成最后导出时物质元素细分表
  1748. SubdivisionOfMaterialElements(dt_ElementSorting, 13, ClassName, dt, out dt1, out dt2);
  1749. allElement_dt = dt_ElementSorting.Copy();
  1750. return true;
  1751. }
  1752. private bool SubdivisionOfMaterialElements(DataTable a_ElementalSubstance, int NumberOfColumns, List<string> ClassName, DataTable data, out DataTable dt1, out DataTable dt2)
  1753. {
  1754. DataTable dt_ElementalSubstance = new DataTable();
  1755. dt_ElementalSubstance = data.Copy();
  1756. dt_ElementalSubstance.Clear();
  1757. dt_ElementalSubstance.TableName = "ElementSubdivision_Value";
  1758. dt_ElementalSubstance.Columns["Name"].ColumnName = "Class";
  1759. dt_ElementalSubstance.Columns.Add("Name");
  1760. //处理元素面积保留小数点后两位
  1761. for (int i = 0; i < a_ElementalSubstance.Rows.Count; i++)
  1762. {
  1763. a_ElementalSubstance.Rows[i]["Area"] = Math.Round(Convert.ToDouble(a_ElementalSubstance.Rows[i]["Area"].ToString()), 2);
  1764. }
  1765. //循环元素物质大类
  1766. for (int i = 0; i < ClassName.Count; i++)
  1767. {
  1768. DataTable dt_1 = new DataTable();
  1769. dt_1 = data.Copy();
  1770. dt_1.Clear();
  1771. for (int a = 0; a < data.Rows.Count; a++)
  1772. {
  1773. if (data.Rows[a]["Name"].ToString() == ClassName[i].ToString())
  1774. {
  1775. dt_1.Rows.Add(data.Rows[a].ItemArray);
  1776. }
  1777. }
  1778. dt_1.Columns["Name"].ColumnName = "Class";
  1779. dt_1.Columns.Add("Name");
  1780. DataTable dt_2 = new DataTable();
  1781. dt_2 = dt_1.Copy();
  1782. dt_2.Clear();
  1783. dt_2.Rows.Add();
  1784. //循环整个表筛选出当前的物质
  1785. for (int a = 0; a < a_ElementalSubstance.Rows.Count; a++)
  1786. {
  1787. if (ClassName[i].ToString() == a_ElementalSubstance.Rows[a]["Class"].ToString())
  1788. {
  1789. for (int b = 0; b < dt_1.Columns.Count; b++)
  1790. {
  1791. if (dt_2.Columns[b].ToString() != "Class")
  1792. {
  1793. if (a_ElementalSubstance.Columns.Contains(dt_2.Columns[b].ToString()))
  1794. {
  1795. if (a_ElementalSubstance.Rows[a][dt_2.Columns[b].ToString()].ToString() == "")
  1796. {
  1797. dt_2.Rows[0][dt_2.Columns[b].ToString()] = 0;
  1798. }
  1799. else
  1800. {
  1801. dt_2.Rows[0][dt_2.Columns[b].ToString()] = a_ElementalSubstance.Rows[a][dt_2.Columns[b].ToString()];
  1802. }
  1803. }
  1804. else
  1805. {
  1806. dt_2.Rows[0][dt_2.Columns[b].ToString()] = 0;
  1807. }
  1808. }
  1809. }
  1810. dt_1.Rows.Add(dt_2.Rows[0].ItemArray);
  1811. }
  1812. }
  1813. for (int a = 0; a < dt_1.Rows.Count; a++)
  1814. {
  1815. dt_ElementalSubstance.Rows.Add(dt_1.Rows[a].ItemArray);
  1816. }
  1817. }
  1818. DataTable dataTable = new DataTable();
  1819. dataTable = dt_ElementalSubstance.Copy();
  1820. dataTable.Clear();
  1821. DataRow row = dataTable.NewRow();
  1822. dataTable.Rows.Add(row);
  1823. dataTable.TableName = "ElementSubdivision_Name";
  1824. for (int i = 0; i < dataTable.Columns.Count; i++)
  1825. {
  1826. dataTable.Rows[0][dataTable.Columns[i].ToString()] = dataTable.Columns[i].ToString();
  1827. }
  1828. dt1 = dataTable.Copy();
  1829. dt2 = dt_ElementalSubstance.Copy();
  1830. return true;
  1831. }
  1832. #region 三元图
  1833. //手动绘制的三元图
  1834. public Bitmap DrawATernaryPicture(int selectindex, c_TemplateClass m_mbszclass, List<Color> Color_list)
  1835. {
  1836. int sel = 0;
  1837. if (m_mbszclass.M_SY.int_xzkl == 0)
  1838. {
  1839. sel = 0;
  1840. }
  1841. else
  1842. {
  1843. sel = 1;
  1844. }
  1845. ResultFile resultFile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
  1846. string template = TemplateList[selectindex];
  1847. if (template == "")
  1848. { //三元相图模板
  1849. template = m_condition.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.TRIO_CHART_TYPE).ToString();
  1850. }
  1851. //获取粒级表
  1852. string pathtpf = Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";
  1853. List<string> nameList = new List<string>();
  1854. DataSet ds = XMLoperate.GetXmlData(pathtpf, "XMLData");
  1855. DataTable dt = ds.Tables["Member"];
  1856. string TemplateName = "";
  1857. //遍历第一层节点
  1858. foreach (DataRow element in dt.Rows)
  1859. {
  1860. TemplateName = element["TemplateName"].ToString();
  1861. if (TemplateName == template)
  1862. {
  1863. string Element = element["Element"].ToString();
  1864. nameList.Add(Element.Split('.')[0]);
  1865. nameList.Add(Element.Split('.')[1]);
  1866. nameList.Add(Element.Split('.')[2]);
  1867. break;
  1868. }
  1869. }
  1870. DataTable dt_point_sort = new DataTable();
  1871. dt_point_sort.Columns.Add("X", typeof(double));
  1872. dt_point_sort.Columns.Add("Y", typeof(double));
  1873. dt_point_sort.Columns.Add("Color_position");
  1874. DataTable particles = GetParticles(resultFile.FilePath, nameList, sel);
  1875. foreach (DataRow item in particles.Rows)
  1876. {
  1877. if (item["particleLocation"].ToString() == "0,0,0")
  1878. {
  1879. continue;
  1880. }
  1881. double top = Convert.ToDouble(item["top"]);
  1882. double left = Convert.ToDouble(item["left"]);
  1883. double right = Convert.ToDouble(item["right"]);
  1884. //x=right+top/2,y=(√3/2)*top
  1885. double Y = 0.866 * top * 500;
  1886. double X = (right + top / 2) * 500;
  1887. double[] point_ = { Math.Round(X, 2), Math.Round(Y) };
  1888. DataRow dr = dt_point_sort.NewRow();
  1889. dr["X"] = Math.Round(X, 2);
  1890. dr["Y"] = Math.Round(Y);
  1891. dr["Color_position"] = item["Color_position"];
  1892. dt_point_sort.Rows.Add(dr);
  1893. }
  1894. #region 图形
  1895. int Line = 500;
  1896. Bitmap map = new Bitmap(530, 530);
  1897. Graphics g = Graphics.FromImage(map);
  1898. SolidBrush sbrush_White = new SolidBrush(Color.White);
  1899. g.FillRectangle(sbrush_White, 0, 0, 530, 530);
  1900. Pen mypen = new Pen(Color.Black, 1);
  1901. g.DrawImage(map, 0, 0, map.Width, map.Height);
  1902. g.DrawLine(mypen, new Point(Line + 10, Line), new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))));//"\"
  1903. g.DrawLine(mypen, new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))), new Point(0 + 10, Line));//"/"
  1904. g.DrawLine(mypen, new Point(0 + 10, Line), new Point(Line + 10, Line));//"_"
  1905. mypen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
  1906. mypen.DashPattern = new float[] { 2, 2 };
  1907. mypen = new Pen(Color.FromArgb(212, 212, 212), 1);
  1908. int point = Line / 10;
  1909. for (int i = 1; i < 10; i++)
  1910. {
  1911. //"\"
  1912. int x1_a = point / 2 + ((point / 2) * (i - 1));
  1913. int x2_a = Line - (43 * i);
  1914. int y1_a = point * i;
  1915. g.DrawLine(mypen, new Point(x1_a + 10, x2_a), new Point(y1_a + 10, Line));
  1916. //"/"
  1917. int x1_b = Line - (point / 2 + ((point / 2) * (i - 1)));
  1918. int x2_b = Line - (43 * i);
  1919. int y1_b = Line - (point * i);
  1920. g.DrawLine(mypen, new Point(x1_b + 10, x2_b), new Point(y1_b + 10, Line));
  1921. //"_"
  1922. int x1_c = point / 2 + ((point / 2) * (i - 1));
  1923. int x2_c = Line - (43 * i);
  1924. int y1_c = Line - (point / 2 + ((point / 2) * (i - 1)));
  1925. int y2_c = Line - (43 * i);
  1926. g.DrawLine(mypen, new Point(x1_c + 10, x2_c), new Point(y1_c + 10, y2_c));
  1927. g.DrawLine(mypen, new Point(y1_a + 10, Line + 10), new Point(y1_a + 10, Line));
  1928. g.DrawLine(mypen, new Point(x1_b + 10, x2_b), new Point(x1_b + 10 + 10, x2_b));
  1929. g.DrawLine(mypen, new Point(x1_c + 10 - 10, x2_c), new Point(y1_c + 10, y2_c));
  1930. 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));
  1931. g.DrawString((i * 10).ToString(), new Font("Arial Unicode MS", 8, FontStyle.Bold), new SolidBrush(Color.Black), new Point(y1_b , Line+8));
  1932. 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));
  1933. }
  1934. for (int i = 0; i < dt_point_sort.Rows.Count; i++)
  1935. {
  1936. mypen = new Pen(Color.Black, 1);
  1937. SolidBrush mysbrush = new SolidBrush(Color_list[Convert.ToInt32(dt_point_sort.Rows[i]["Color_position"])]);
  1938. g.FillRectangle(mysbrush, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 8, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 4, 5);
  1939. g.DrawRectangle(mypen, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 7, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 5, 5);
  1940. }
  1941. Font myFont = new Font("Arial Unicode MS", 13, FontStyle.Bold);
  1942. Font Font_features = new Font("Arial Unicode MS", 10, FontStyle.Bold);
  1943. SolidBrush sbrush = new SolidBrush(Color.Black);
  1944. g.DrawString("features:" + dt_point_sort.Rows.Count.ToString(), Font_features, sbrush, 400, 200);
  1945. g.DrawString(TemplateName, myFont, sbrush, 265 - (TemplateName.Length * 10 / 2), 10);
  1946. g.DrawString(TemplateName.Split('.')[0].ToString(), myFont, sbrush, 265 - (TemplateName.Split('.')[0].ToString().Length * 10 / 2), 45);//顶点名字
  1947. g.DrawString(TemplateName.Split('.')[1].ToString(), myFont, sbrush, 0, 510);//左侧名字
  1948. g.DrawString(TemplateName.Split('.')[2].ToString(), myFont, sbrush, 500 - (TemplateName.Split('.')[0].ToString().Length * 10), 510);//左侧名字
  1949. //map.Save("D:\\1.bmp");
  1950. #endregion
  1951. return map;
  1952. }
  1953. //绘制图例
  1954. public Bitmap DrawATernaryDiagramLegend(List<Color> Color_list)
  1955. {
  1956. Bitmap map = new Bitmap(260, 115);
  1957. Graphics g = Graphics.FromImage(map);
  1958. SolidBrush sbrush_White = new SolidBrush(Color.White);
  1959. SolidBrush sbrush = new SolidBrush(Color.Black);
  1960. g.FillRectangle(sbrush_White, 0, 0, 260, 115);
  1961. Font myFont = new Font("Arial Unicode MS", 10, FontStyle.Regular);
  1962. Font myFont2 = new Font("Arial Unicode MS", 10, FontStyle.Regular);
  1963. g.DrawString("图例(length,μm)", myFont, sbrush, 70, 3);
  1964. //legend(length,microns)
  1965. Pen mypen = new Pen(Color.Black, 1);
  1966. g.DrawLine(mypen, 70, 19, 170, 19);
  1967. //设置标签名称
  1968. List<string> listName = new List<string>();
  1969. //获取粒级表
  1970. string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  1971. DataSet ds = XMLoperate.GetXml(pathe);
  1972. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1973. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  1974. {
  1975. if (sizestr.Split(',')[i].Length > 0)
  1976. {
  1977. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  1978. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  1979. listName.Add(d1.ToString() + "~" + d2.ToString());
  1980. }
  1981. }
  1982. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1983. listName.Add(d.ToString() + "~MAX");
  1984. int PositionJeight = 27;
  1985. //string str_unit = " μm";
  1986. string str_unit = "";
  1987. for (int i=0;i< listName.Count;i=i+3)
  1988. {
  1989. if (i < listName.Count)
  1990. {
  1991. SolidBrush sbrush_Color = new SolidBrush(Color_list[i]);
  1992. g.DrawRectangle(mypen, 0, PositionJeight, 8, 8);
  1993. g.FillRectangle(sbrush_Color, 1, PositionJeight + 1, 7, 7);
  1994. g.DrawString(listName[i].ToString() + str_unit, myFont2, sbrush, 12, PositionJeight - 2);
  1995. }
  1996. if (i + 1 < listName.Count)
  1997. {
  1998. SolidBrush sbrush_Color = new SolidBrush(Color_list[i + 1]);
  1999. g.DrawRectangle(mypen, 94, PositionJeight, 8, 8);
  2000. g.FillRectangle(sbrush_Color, 95, PositionJeight + 1, 7, 7);
  2001. g.DrawString(listName[i + 1].ToString() + str_unit, myFont2, sbrush, 106, PositionJeight - 2);
  2002. }
  2003. if (i + 2 < listName.Count)
  2004. {
  2005. SolidBrush sbrush_Color = new SolidBrush(Color_list[i + 2]);
  2006. g.DrawRectangle(mypen, 188, PositionJeight, 8, 8);
  2007. g.FillRectangle(sbrush_Color, 189, PositionJeight + 1, 7, 7);
  2008. g.DrawString(listName[i + 2].ToString() + str_unit, myFont2, sbrush, 199, PositionJeight - 2);
  2009. }
  2010. PositionJeight = PositionJeight + 15;
  2011. }
  2012. return map;
  2013. }
  2014. private DataTable GetParticles(string filepath, List<string> nameList, int sel)
  2015. {
  2016. ParticleData particledata = new ParticleData(filepath);
  2017. //设置标签名称
  2018. List<string> listName = new List<string>();
  2019. //获取粒级表
  2020. string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  2021. DataSet ds = XMLoperate.GetXml(pathe);
  2022. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  2023. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  2024. {
  2025. if (sizestr.Split(',')[i].Length > 0)
  2026. {
  2027. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  2028. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  2029. listName.Add(d1.ToString() + "~" + d2.ToString());
  2030. }
  2031. }
  2032. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  2033. listName.Add(d.ToString() + "~MAX");
  2034. string filedAndParticl = "";
  2035. if (sel == 1)
  2036. {
  2037. List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
  2038. foreach (var item in selectParticles)
  2039. {
  2040. filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
  2041. }
  2042. if (filedAndParticl != "")
  2043. {
  2044. filedAndParticl = filedAndParticl + ",";
  2045. }
  2046. }
  2047. string po = "";
  2048. string con = "";
  2049. int row = m_condition.m_conditionData.ConditionItemList.Count;
  2050. if (condition != -1)
  2051. {
  2052. List<string> li = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };
  2053. con = li[condition];
  2054. }
  2055. else
  2056. {
  2057. if (row < 4)
  2058. {
  2059. con = "DMAX";
  2060. }
  2061. else
  2062. {
  2063. con = m_condition.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
  2064. }
  2065. }
  2066. switch (con)
  2067. {
  2068. case "DMAX":
  2069. po = "DMAX";
  2070. break;
  2071. case "DMIN":
  2072. po = "DMIN";
  2073. break;
  2074. case "ECD":
  2075. po = "Area";
  2076. break;
  2077. case "FERET":
  2078. po = "DFERET";
  2079. break;
  2080. }
  2081. DataTable dtp = particledata.GetParticleAllHaveXray(filedAndParticl);
  2082. //DataTable dtp = particledata.GetParticleHaveXray(filedAndParticl);
  2083. for (int i=0;i<dtp.Rows.Count;i++)
  2084. {
  2085. if (Convert.ToInt32( dtp.Rows[i]["TypeId"])< 0 || dtp.Rows[i]["TypeName"].ToString()== "Invalid")
  2086. {
  2087. dtp.Rows[i].Delete();
  2088. }
  2089. }
  2090. dtp.AcceptChanges();
  2091. //创建一个临时表
  2092. DataTable ret_dt = new DataTable();
  2093. //然后额外存放三列,用于存放拆分后三个顶点的值
  2094. ret_dt.Columns.Add("sizeLevel");
  2095. ret_dt.Columns.Add("particleLocation");
  2096. ret_dt.Columns.Add("top");
  2097. ret_dt.Columns.Add("left");
  2098. ret_dt.Columns.Add("right");
  2099. ret_dt.Columns.Add("Color_position");
  2100. for (int k = 0; k < listName.Count; k++)
  2101. {
  2102. string str = listName[k];
  2103. string d1 = str.Split('~')[0];
  2104. string d2 = str.Split('~')[1];
  2105. if (d2 == "MAX")
  2106. {
  2107. d2 = "999";
  2108. }
  2109. DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
  2110. foreach (var item in datas)
  2111. {
  2112. DataRow dr = ret_dt.NewRow();
  2113. dr["sizeLevel"] = str;
  2114. string element = item["Element"].ToString();
  2115. string strRet = getStrRet(nameList, element);
  2116. dr["particleLocation"] = strRet;
  2117. dr["top"] = strRet.Split(',')[0];
  2118. dr["left"] = strRet.Split(',')[1];
  2119. dr["right"] = strRet.Split(',')[2];
  2120. dr["Color_position"] = k.ToString();
  2121. ret_dt.Rows.Add(dr);
  2122. }
  2123. }
  2124. return ret_dt;
  2125. }
  2126. private string getWhere(string max, string min, string col)
  2127. {
  2128. return col + ">=" + min + " and " + col + "<=" + max;
  2129. }
  2130. private string getStrRet(List<string> template, string element)
  2131. {
  2132. List<string> name = new List<string>()
  2133. { "h","he",
  2134. "li","be","b","c","n","o","f","ne",
  2135. "na","mg","al","si","p","s","cl","ar",
  2136. "k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr",
  2137. "rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe",
  2138. "cs","ba","la",
  2139. "ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu",
  2140. "hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn",
  2141. "fr","ra","ac",
  2142. "th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr"
  2143. };
  2144. List<double> value = new List<double>()
  2145. { 1.008,4.003,
  2146. 6.941,9.012,10.811,12.011,14.007,15.999,18.998,20.180,
  2147. 22.990,24.305,26.982,28.086,30.974,32.066,35.453,39.948,
  2148. 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,
  2149. 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,
  2150. 132.905,137.33,138.906,
  2151. 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,
  2152. 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,
  2153. 223.00,226.025,227.028,
  2154. 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
  2155. };
  2156. double d_ASum = 0;
  2157. double d_BSum = 0;
  2158. double d_CSum = 0;
  2159. string aElements = template[0];
  2160. string bElements = template[1];
  2161. string cElements = template[2];
  2162. foreach (var item in element.Split(';'))
  2163. {
  2164. if (item.Contains(aElements + "-"))
  2165. {
  2166. if (aElements != "")
  2167. {
  2168. d_ASum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(aElements.ToLower())];
  2169. }
  2170. }
  2171. for (int i = 0; i < bElements.Split(',').Length; i++)
  2172. {
  2173. string e = bElements.Split(',')[i];
  2174. if (item.Contains(e + "-"))
  2175. {
  2176. d_BSum = d_BSum + Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(e.ToLower())];
  2177. }
  2178. }
  2179. if (item.Contains(cElements + "-"))
  2180. {
  2181. if (cElements != "")
  2182. d_CSum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(cElements.ToLower())];
  2183. }
  2184. }
  2185. double allNums = d_ASum + d_BSum + d_CSum;
  2186. string strRet = "";
  2187. if ((allNums) == 0)
  2188. {
  2189. strRet = "0,0,0";
  2190. }
  2191. else
  2192. {
  2193. double aPercent = 0, bPercent = 0, cPercent = 0;
  2194. if (d_ASum != 0)
  2195. {
  2196. aPercent = d_ASum / allNums;
  2197. }
  2198. if (d_BSum != 0)
  2199. {
  2200. bPercent = d_BSum / allNums;
  2201. }
  2202. if (d_CSum != 0)
  2203. {
  2204. cPercent = d_CSum / allNums;
  2205. }
  2206. strRet = aPercent.ToString() + "," + bPercent.ToString() + "," + cPercent.ToString();
  2207. }
  2208. return strRet;
  2209. }
  2210. #endregion
  2211. /// <summary>
  2212. /// 大分类数据
  2213. /// </summary>
  2214. /// <param name="m_mbszclass"></param>
  2215. /// <returns></returns>
  2216. public DataTable ClassificationIntegration(c_TemplateClass m_mbszclass,string str)
  2217. {
  2218. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  2219. DataTable data = new DataTable();
  2220. if (m_mbszclass.M_SY.int_xzkl == 0)
  2221. {
  2222. data = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
  2223. }
  2224. else
  2225. {
  2226. DataTable AllInca = fielddata.GetAreaByAllIncA("");
  2227. DataTable SelectParticl = SelectParticleData();
  2228. data = GetParticleListForParticlSize(SelectParticl, AllInca);
  2229. }
  2230. DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
  2231. DataTable AllAnalysisDetails = new DataTable();
  2232. AllAnalysisDetails.Columns.Add("Name");
  2233. AllAnalysisDetails.Columns.Add("TypeId");
  2234. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  2235. AllAnalysisDetails.Columns.Add("Class");
  2236. AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
  2237. for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
  2238. {
  2239. DataRow dr2 = AllAnalysisDetails.NewRow();
  2240. dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
  2241. dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
  2242. dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
  2243. dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
  2244. dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
  2245. AllAnalysisDetails.Rows.Add(dr2);
  2246. }
  2247. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  2248. List<string> ClassName = new List<string>();
  2249. DataTable getClass_dt = fielddata.GetAllClass();
  2250. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  2251. {
  2252. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  2253. }
  2254. DataTable AreaRatio = new DataTable();
  2255. AreaRatio.TableName = "InclusionAreaRatio";
  2256. AreaRatio.Columns.Add("Class");
  2257. AreaRatio.Columns.Add("Name");
  2258. AreaRatio.Columns.Add("Area", typeof(double));
  2259. AreaRatio.Columns.Add("inca_proportion");
  2260. AreaRatio.Columns.Add("inca_FieldRatio");
  2261. AreaRatio.Columns.Add("Cunt", typeof(int));
  2262. //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
  2263. double totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
  2264. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  2265. {
  2266. DataRow dr2 = AreaRatio.NewRow();
  2267. dr2["Class"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
  2268. dr2["Name"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
  2269. dr2["Area"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
  2270. dr2["inca_proportion"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
  2271. dr2["inca_FieldRatio"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str)) * 100, 4);
  2272. dr2["Cunt"] = AllAnalysisDetails.Rows[i]["Cunt"].ToString();
  2273. AreaRatio.Rows.Add(dr2);
  2274. }
  2275. DataTable AreaRatio_dt = AreaRatio.Copy();
  2276. AreaRatio_dt.Clear();
  2277. for (int i = 0; i < ClassName.Count(); i++)
  2278. {
  2279. DataTable dt = AreaRatio.Copy();
  2280. dt.Clear();
  2281. for (int a = 0; a < AreaRatio.Rows.Count; a++)
  2282. {
  2283. if (AreaRatio.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  2284. {
  2285. dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
  2286. }
  2287. }
  2288. DataView dv = dt.DefaultView;
  2289. dv.Sort = "Area DESC";
  2290. DataTable dt_Element = dv.ToTable();
  2291. for (int a = 0; a < dt_Element.Rows.Count; a++)
  2292. {
  2293. AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  2294. }
  2295. }
  2296. DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
  2297. AllAnalysisDetails1.Clear();
  2298. for (int i = 0; i < ClassName.Count; i++)
  2299. {
  2300. DataTable dt = AreaRatio_dt.Copy();
  2301. dt.Clear();
  2302. for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
  2303. {
  2304. if (AreaRatio_dt.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  2305. {
  2306. dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
  2307. }
  2308. }
  2309. if (dt.Rows.Count > 0)
  2310. {
  2311. double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(Area)", "").ToString()));
  2312. double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
  2313. int cunt = Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
  2314. DataRow dr3 = AllAnalysisDetails1.NewRow();
  2315. dr3["Class"] = ClassName[i].ToString();
  2316. dr3["Area"] = Math.Round(Area, 2);
  2317. dr3["inca_proportion"] = Math.Round((Convert.ToDouble(dt.Rows[0]["Area"]) / totalInclusionArea2) * 100, 2);
  2318. dr3["inca_FieldRatio"] = Math.Round((Convert.ToDouble(dt.Rows[0]["Area"]) / Convert.ToDouble(str)) * 100, 4);
  2319. dr3["Cunt"] = cunt;
  2320. AllAnalysisDetails1.Rows.Add(dr3);
  2321. }
  2322. }
  2323. return AllAnalysisDetails1;
  2324. }
  2325. private DataTable SelectParticleData()
  2326. {
  2327. List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
  2328. #region Datatable数据表格式
  2329. DataTable dtUelect = new DataTable();
  2330. dtUelect.Columns.Add("fieldid");
  2331. dtUelect.Columns.Add("particleid");
  2332. dtUelect.Columns.Add("AveGray");
  2333. dtUelect.Columns.Add("RectLeft");
  2334. dtUelect.Columns.Add("RectTop");
  2335. dtUelect.Columns.Add("RectWidth");
  2336. dtUelect.Columns.Add("RectHeight");
  2337. dtUelect.Columns.Add("Area");
  2338. dtUelect.Columns.Add("PosX");
  2339. dtUelect.Columns.Add("PosY");
  2340. dtUelect.Columns.Add("TypeId");
  2341. dtUelect.Columns.Add("SegmentNum");
  2342. dtUelect.Columns.Add("SEMPosX");
  2343. dtUelect.Columns.Add("SEMPosY");
  2344. dtUelect.Columns.Add("XrayId");
  2345. dtUelect.Columns.Add("DMAX");
  2346. dtUelect.Columns.Add("DMIN");
  2347. dtUelect.Columns.Add("DPERP");
  2348. dtUelect.Columns.Add("PERIMETER");
  2349. dtUelect.Columns.Add("ORIENTATION");
  2350. dtUelect.Columns.Add("DINSCR");
  2351. dtUelect.Columns.Add("DMEAN");
  2352. dtUelect.Columns.Add("DELONG");
  2353. dtUelect.Columns.Add("DFERET");
  2354. dtUelect.Columns.Add("TypeName");
  2355. dtUelect.Columns.Add("TypeColor");
  2356. #endregion
  2357. for (int i = 0; i < selectParticles.Count; i++)
  2358. {
  2359. 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);
  2360. }
  2361. return dtUelect;
  2362. }
  2363. private DataTable ConSolidateInvalid(DataTable dt)
  2364. {
  2365. DataTable dt_invalid = dt.Clone();
  2366. DataTable dt_no_invalid = dt.Clone();
  2367. for (int i = 0; i < dt.Rows.Count; i++)
  2368. {
  2369. if (dt.Rows[i]["TypeName"].ToString() == "Invalid")
  2370. {
  2371. dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
  2372. }
  2373. else
  2374. {
  2375. dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
  2376. }
  2377. }
  2378. return dt_no_invalid;
  2379. }
  2380. /// <summary>
  2381. /// 细分类数据
  2382. /// </summary>
  2383. /// <param name="m_mbszclass"></param>
  2384. /// <returns></returns>
  2385. public DataTable subdivisionIntegration(c_TemplateClass m_mbszclass)
  2386. {
  2387. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  2388. DataTable data = new DataTable();
  2389. if (m_mbszclass.M_SY.int_xzkl == 0)
  2390. {
  2391. data = fielddata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
  2392. }
  2393. else
  2394. {
  2395. DataTable AllInca = fielddata.GetAreaByAllIncA("");
  2396. DataTable SelectParticl = SelectParticleData();
  2397. data = GetParticleListForParticlSize(SelectParticl, AllInca);
  2398. }
  2399. return ConSolidateInvalid(data);
  2400. }
  2401. public void GenerateINCAtable(string str,out DataTable dt)
  2402. {
  2403. //根据sql条件,查询获取颗粒信息数据
  2404. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  2405. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  2406. List<string> ClassName = new List<string>();
  2407. DataTable getClass_dt = fielddata.GetAllClass();
  2408. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  2409. {
  2410. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  2411. //ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  2412. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  2413. ClassName.Add("NULL");
  2414. else
  2415. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  2416. }
  2417. //夹杂物面积比添加大类
  2418. DataTable RawParticleData = InclusionAreaRatio_2(str);
  2419. //夹杂物面积比计算大类占比
  2420. ProportionOfParticleArea(RawParticleData, ClassName, str, out dt);
  2421. }
  2422. private bool ProportionOfParticleArea(DataTable dataTable, List<string> ClassName,string str, out DataTable dt_out)
  2423. {
  2424. DataTable AllAnalysisDetails = dataTable.Copy();
  2425. AllAnalysisDetails.Clear();
  2426. AllAnalysisDetails.TableName = "InclusionAreaRatio";
  2427. for (int i = 0; i < ClassName.Count; i++)
  2428. {
  2429. DataTable dt = dataTable.Copy();
  2430. dt.Clear();
  2431. for (int a = 0; a < dataTable.Rows.Count; a++)
  2432. {
  2433. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  2434. {
  2435. dt.Rows.Add(dataTable.Rows[a].ItemArray);
  2436. }
  2437. }
  2438. if (dt.Rows.Count > 0)
  2439. {
  2440. double totalInclusionArea = Convert.ToDouble(decimal.Parse(dataTable.Compute("sum(Area)", "").ToString()));
  2441. double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(Area)", "").ToString()));
  2442. DataRow dr = AllAnalysisDetails.NewRow();
  2443. dr["Class"] = ClassName[i].ToString();
  2444. dr["Area"] = Math.Round(Area, 2);
  2445. //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
  2446. dr["inca_proportion"] = Math.Round((Convert.ToDouble(Area) / totalInclusionArea) * 100, 2);
  2447. dr["inca_FieldRatio"] = Math.Round((Convert.ToDouble(Area) / Convert.ToDouble(str)) * 100, 4);
  2448. AllAnalysisDetails.Rows.Add(dr);
  2449. DataView dv = dt.DefaultView;
  2450. dv.Sort = "Area DESC";
  2451. DataTable dt_Area = dv.ToTable();
  2452. for (int a = 0; a < dt_Area.Rows.Count; a++)
  2453. {
  2454. dt_Area.Rows[a]["Class"] = "";
  2455. dt_Area.Rows[a]["Area"] = Math.Round(Convert.ToDouble(dt_Area.Rows[a]["Area"]), 2);
  2456. AllAnalysisDetails.Rows.Add(dt_Area.Rows[a].ItemArray);
  2457. }
  2458. }
  2459. }
  2460. dt_out = AllAnalysisDetails.Copy();
  2461. return true;
  2462. }
  2463. private DataTable InclusionAreaRatio_2(string str)
  2464. {
  2465. //根据sql条件,查询获取颗粒信息数据
  2466. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  2467. DataTable AreaInformationOfAllElements = InvalidRemoval(InvalidRemoval(fielddata.GetAreaByAllIncA(""), "GroupName"), "TypeName");
  2468. DataTable AllAnalysisDetails = new DataTable();
  2469. AllAnalysisDetails.Columns.Add("Name");
  2470. AllAnalysisDetails.Columns.Add("TypeId");
  2471. AllAnalysisDetails.Columns.Add("Area", typeof(double));
  2472. AllAnalysisDetails.Columns.Add("Class");
  2473. AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
  2474. for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
  2475. {
  2476. DataRow dr2 = AllAnalysisDetails.NewRow();
  2477. dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
  2478. dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
  2479. dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
  2480. dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
  2481. dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
  2482. AllAnalysisDetails.Rows.Add(dr2);
  2483. }
  2484. List<string> ClassName = new List<string>();
  2485. DataTable getClass_dt = fielddata.GetAllClass();
  2486. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  2487. {
  2488. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  2489. //ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  2490. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  2491. ClassName.Add("NULL");
  2492. else
  2493. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  2494. }
  2495. DataTable AreaRatio = new DataTable();
  2496. AreaRatio.TableName = "InclusionAreaRatio";
  2497. AreaRatio.Columns.Add("Class");
  2498. AreaRatio.Columns.Add("subdivision");
  2499. AreaRatio.Columns.Add("Area", typeof(double));
  2500. AreaRatio.Columns.Add("inca_proportion");
  2501. AreaRatio.Columns.Add("inca_FieldRatio");
  2502. //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
  2503. int sumArea = 0;
  2504. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  2505. {
  2506. sumArea = sumArea + Convert.ToInt32(AllAnalysisDetails.Rows[i]["Area"]);
  2507. }
  2508. for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
  2509. {
  2510. DataRow dr = AreaRatio.NewRow();
  2511. dr["Class"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
  2512. dr["subdivision"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
  2513. dr["Area"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
  2514. dr["inca_proportion"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / sumArea) * 100, 2);
  2515. dr["inca_FieldRatio"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str)) * 100, 4);
  2516. AreaRatio.Rows.Add(dr);
  2517. }
  2518. DataTable AreaRatio_dt = AreaRatio.Copy();
  2519. AreaRatio_dt.Clear();
  2520. for (int i = 0; i < ClassName.Count(); i++)
  2521. {
  2522. DataTable dt = AreaRatio.Copy();
  2523. dt.Clear();
  2524. for (int a = 0; a < AreaRatio.Rows.Count; a++)
  2525. {
  2526. if (AreaRatio.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  2527. {
  2528. dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
  2529. }
  2530. }
  2531. DataView dv = dt.DefaultView;
  2532. dv.Sort = "Area DESC";
  2533. DataTable dt_Element = dv.ToTable();
  2534. for (int a = 0; a < dt_Element.Rows.Count; a++)
  2535. {
  2536. AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
  2537. }
  2538. }
  2539. return AreaRatio_dt;
  2540. }
  2541. 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)
  2542. {
  2543. //首页信息
  2544. GB_Report = new GBReport(in_export);
  2545. GB_Report.setResultGrid(m_otsreport_export.m_mbszclass);
  2546. GB_Report.International_language(dev_internationalLanguage);
  2547. for (int i = 0; i < m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
  2548. {
  2549. string anothername = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
  2550. 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();
  2551. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
  2552. }
  2553. OTSCLRINTERFACE.CPropParamClr clr_prop = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  2554. List<string> datasourcelist = m_otsreport_export.m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  2555. if (gb_1)
  2556. {
  2557. List<DataTable> GB1 = InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop, datasourcelist, Index, (int)CALCULATE_TABLE_TYPE.GB_Method1);
  2558. DataView dv_gb1 = GB1[4].DefaultView;
  2559. dv_gb1.Sort = "Grade desc";
  2560. DataTable dt_gb1 = dv_gb1.ToTable();
  2561. for (int i=0; i < GB1[4].Rows.Count;i++)
  2562. {
  2563. for(int a=0;a< GB1[4].Columns.Count;a++)
  2564. {
  2565. GB1[4].Rows[i][a] = dt_gb1.Rows[i][a];
  2566. }
  2567. }
  2568. List<string> GB1NameList = new List<string>();
  2569. GB1NameList.Add("A类");
  2570. GB1NameList.Add("B类");
  2571. GB1NameList.Add("C类");
  2572. GB1NameList.Add("D类");
  2573. GB1NameList.Add("DS类");
  2574. GB_Report.set_GB_Method(GB1, GB1NameList, "方法一");
  2575. }
  2576. if (gb_2)
  2577. {
  2578. List<DataTable> GB2 = InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop, datasourcelist, Index, (int)CALCULATE_TABLE_TYPE.GB_Method2);
  2579. DataView dv_gb1 = GB2[5].DefaultView;
  2580. dv_gb1.Sort = "Grade desc";
  2581. DataTable dt_gb1 = dv_gb1.ToTable();
  2582. for (int i = 0; i < GB2[5].Rows.Count; i++)
  2583. {
  2584. for (int a = 0; a < GB2[5].Columns.Count; a++)
  2585. {
  2586. GB2[5].Rows[i][a] = dt_gb1.Rows[i][a];
  2587. }
  2588. }
  2589. List<string> GB2NameList = new List<string>();
  2590. GB2NameList.Add("A类");
  2591. GB2NameList.Add("B类");
  2592. GB2NameList.Add("C类");
  2593. GB2NameList.Add("D类");
  2594. GB2NameList.Add("D硫化物类");
  2595. GB2NameList.Add("DS类");
  2596. GB_Report.set_GB_Method(GB2, GB2NameList, "方法二");
  2597. }
  2598. DevExpress.XtraReports.UI.ReportPrintTool tool = new DevExpress.XtraReports.UI.ReportPrintTool(GB_Report);
  2599. tool.ShowPreview();
  2600. }
  2601. }
  2602. }