|
@@ -112,8 +112,37 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
#endregion
|
|
|
|
|
|
#region 一次性读取数据所需要的数据
|
|
|
+ private void GetSTL(out DataTable data)
|
|
|
+ {
|
|
|
+ DataTable dt = new DataTable();
|
|
|
+ dt.Columns.Add("TypeId");
|
|
|
+ dt.Columns.Add("Hardness", typeof(double));
|
|
|
+ dt.Columns.Add("Hardness_detailed");
|
|
|
+ ResultFile resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()];
|
|
|
+ string str_libraryName = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resfile.ResultInfo["Sample"])["Members"])["MsrParams"])["STDName"].ToString();
|
|
|
+
|
|
|
+ OTSSysMgrTools.SqLiteHelper sh = new OTSSysMgrTools.SqLiteHelper("data source='" + System.IO.Directory.GetCurrentDirectory()+ "\\Config\\SysData\\"+ str_libraryName + ".db" + "'");
|
|
|
+ DataTable dt_stl= sh.ExecuteQuery("select * from ClassifySTD");
|
|
|
+ for (int i=0;i< dt_stl.Rows.Count;i++)
|
|
|
+ {
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
+ dr["TypeId"] = dt_stl.Rows[i]["StrName"].ToString();
|
|
|
+ dr["Hardness_detailed"] = dt_stl.Rows[i]["Hardness"].ToString();
|
|
|
+ if (System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", "").ToString()!="")
|
|
|
+ {
|
|
|
+ dr["Hardness"] = Convert.ToDouble(System.Text.RegularExpressions.Regex.Replace(dt_stl.Rows[i]["Hardness"].ToString(), @"[^\d.\d]", ""));
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ dr["Hardness"] = 0;
|
|
|
+ }
|
|
|
+ dt.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ data = dt;
|
|
|
+ }
|
|
|
public bool GetDBData()
|
|
|
{
|
|
|
+ //GetSTL();
|
|
|
+
|
|
|
m_bt_DBData.Clear();
|
|
|
m_bt_DBData.Columns.Clear();
|
|
|
ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
|
|
@@ -224,9 +253,8 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
/// <returns></returns>
|
|
|
public bool InsertReportTemplateTable_ParticlesGridDevidePage()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
int serialNumber = 1;
|
|
|
-
|
|
|
//------------------加载模块,获取数据-------------------------------------------------
|
|
|
m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
|
|
|
|
|
@@ -238,8 +266,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
dv.Sort = "DMAX DESC";
|
|
|
DataTable dt_ParticlesGridDevidePage = dv.ToTable();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath;
|
|
|
//------------------加载模块,获取数据结束----------------------------------------------
|
|
|
#region 创建要插入数据库表结构
|
|
@@ -319,18 +345,12 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
#region 插入-前20颗粒部份
|
|
|
-
|
|
|
|
|
|
for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
|
|
|
{
|
|
|
if (dt_ParticlesGridDevidePage.Rows[i_row].ItemArray[24].ToString()!= "Not Identified")
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
//获取颗粒的fieldid,和particleid
|
|
|
string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
|
|
|
string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
@@ -347,7 +367,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
if (str_fieldid == "-1")
|
|
|
continue;
|
|
|
|
|
|
-
|
|
|
if (serialNumber > 20)
|
|
|
continue;
|
|
|
|
|
@@ -417,7 +436,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
dr["DMIN"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmin"]), 2).ToString();
|
|
|
dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
|
|
|
|
|
|
-
|
|
|
List<string> list_max_elementname = new List<string>();
|
|
|
List<double> list_max_elementvale = new List<double>();
|
|
|
GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
|
|
@@ -440,7 +458,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
dr["ColName6"] = list_max_elementname[5];
|
|
|
dr["ColVal6"] = list_max_elementvale[5].ToString();
|
|
|
|
|
|
-
|
|
|
DT_Largest20.Rows.Add(dr);
|
|
|
}
|
|
|
}
|
|
@@ -460,9 +477,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
dt_GridDevidePage.Rows.Add(dt_ParticlesGridDevidePage.Rows[i].ItemArray);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile(dt_GridDevidePage, out vs ,out data);
|
|
|
-
|
|
|
string str_path_FIELD_FILES_MARK = str_resultPath + "\\FIELD_FILES_MARK\\";
|
|
|
DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);
|
|
|
if (theFolder.Exists)
|
|
@@ -473,7 +488,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
{
|
|
|
if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
|
|
|
{
|
|
|
-
|
|
|
//确认对应的帧图名
|
|
|
string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
|
|
|
if (str_fieldid==vs[i].ToString())
|
|
@@ -483,7 +497,6 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
if (datarowlist.Count() > 0)
|
|
|
{
|
|
|
Bitmap ls_bp_fieldmark = new Bitmap(nextifile.FullName);
|
|
|
-
|
|
|
DataRow dr = DT_field_dt.NewRow();
|
|
|
MemoryStream newms_bp_fieldmark = new MemoryStream();
|
|
|
ls_bp_fieldmark.Save(newms_bp_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
@@ -492,19 +505,14 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
newms_bp_fieldmark.Read(newarr_fieldmark, 0, newarr_fieldmark.Length);
|
|
|
dr["FieldImg"] = newarr_fieldmark;
|
|
|
dr["FieldId"] = str_fieldid;
|
|
|
-
|
|
|
ls_bp_fieldmark.Dispose();
|
|
|
DT_field_dt.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
DT_field_dt_copy = DT_field_dt.Copy();
|
|
|
}
|
|
|
|
|
@@ -607,13 +615,403 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
}
|
|
|
#endregion
|
|
|
FrameGraphParticleTable(dt_ParticlesGridDevidePage, str_resultPath, fielddata, DT_field_dt);
|
|
|
+ m_list_dt.Add(DT_field_dt_copy);
|
|
|
+ m_list_dt.Add(DT_Largest_frame);
|
|
|
+ m_list_dt.Add(DT_Largest20);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool InsertReportTemplateTable_ParticlesGridDevidePage_CleanlinessA()
|
|
|
+ {
|
|
|
+ DataTable dt_stl = new DataTable();
|
|
|
+ GetSTL(out dt_stl);
|
|
|
+
|
|
|
+ int serialNumber = 1;
|
|
|
+ //------------------加载模块,获取数据-------------------------------------------------
|
|
|
+ m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
|
|
|
+
|
|
|
+ //根据sql条件,查询获取颗粒信息数据
|
|
|
+ ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath);
|
|
|
+ DataTable dt = InvalidRemoval(fielddata.GetIncaSurfaceData(), "TypeName");
|
|
|
+
|
|
|
+ dt.Columns.Add("Hardness", typeof(double));
|
|
|
+ dt.Columns.Add("Hardness_detailed");
|
|
|
+ for (int i=0;i<dt.Rows.Count;i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ for (int a=0;a< dt_stl.Rows.Count;a++)
|
|
|
+ {
|
|
|
+ if (dt.Rows[i]["TypeName"].ToString() ==dt_stl.Rows[a]["TypeId"].ToString())
|
|
|
+ {
|
|
|
+ dt.Rows[i]["Hardness"] = Convert.ToDouble(dt_stl.Rows[a]["Hardness"]);
|
|
|
+ dt.Rows[i]["Hardness_detailed"] = dt_stl.Rows[a]["Hardness_detailed"];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //将颗粒大小排序(从大到小)
|
|
|
+ DataView dv = dt.DefaultView;
|
|
|
+ dv.Sort = "Hardness DESC";
|
|
|
+ DataTable dt_ParticlesGridDevidePage = dv.ToTable();
|
|
|
+
|
|
|
+ string str_resultPath = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath;
|
|
|
+ //------------------加载模块,获取数据结束----------------------------------------------
|
|
|
+ #region 创建要插入数据库表结构
|
|
|
+ //插入模板需父子表,结构
|
|
|
+ //表名field_dt表:(父表) 帧图表
|
|
|
+ DataTable DT_field_dt = new DataTable();
|
|
|
+ DT_field_dt.TableName = "field_dt";
|
|
|
+ DataColumn colpictid2 = new DataColumn("FieldId");
|
|
|
+ colpictid2.DataType = typeof(int);
|
|
|
+ DT_field_dt.Columns.Add(colpictid2);
|
|
|
+ //图像列
|
|
|
+ DataColumn colpict2 = new DataColumn("FieldImg");
|
|
|
+ colpict2.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ DT_field_dt.Columns.Add(colpict2);
|
|
|
+
|
|
|
+ //表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
|
|
|
+ DataTable DT_field_dt_copy = new DataTable();
|
|
|
+ DataTable DT_Largest_frame = new DataTable();
|
|
|
+ DT_Largest_frame.TableName = "Largest_frame";
|
|
|
+ DT_Largest_frame.Columns.Add("pid");
|
|
|
+ DT_Largest_frame.Columns.Add("Size");
|
|
|
+ DT_Largest_frame.Columns.Add("Width");
|
|
|
+ DT_Largest_frame.Columns.Add("DMAX");
|
|
|
+ DT_Largest_frame.Columns.Add("DMIN");
|
|
|
+ DT_Largest_frame.Columns.Add("Class");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName1");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName2");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName3");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName4");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName5");
|
|
|
+ DT_Largest_frame.Columns.Add("ColName6");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal1");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal2");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal3");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal4");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal5");
|
|
|
+ DT_Largest_frame.Columns.Add("ColVal6");
|
|
|
+ DataColumn colpictid = new DataColumn("FieldId");
|
|
|
+ colpictid.DataType = typeof(int);
|
|
|
+ DT_Largest_frame.Columns.Add(colpictid);
|
|
|
+ //图像列
|
|
|
+ DataColumn colpict = new DataColumn("p1");
|
|
|
+ colpict.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ DT_Largest_frame.Columns.Add(colpict);
|
|
|
|
|
|
+ //largest20表:(无关系表) 需要显示前20条带有显示能谱图像的颗粒表
|
|
|
+ DataTable DT_Largest20 = new DataTable();
|
|
|
+ DT_Largest20.TableName = "Largest20";
|
|
|
+ DT_Largest20.Columns.Add("pid");
|
|
|
+ DT_Largest20.Columns.Add("Size");
|
|
|
+ DT_Largest20.Columns.Add("Width");
|
|
|
+ DT_Largest20.Columns.Add("DMAX");
|
|
|
+ DT_Largest20.Columns.Add("DMIN");
|
|
|
+ DT_Largest20.Columns.Add("Class");
|
|
|
+ DT_Largest20.Columns.Add("ColName1");
|
|
|
+ DT_Largest20.Columns.Add("ColName2");
|
|
|
+ DT_Largest20.Columns.Add("ColName3");
|
|
|
+ DT_Largest20.Columns.Add("ColName4");
|
|
|
+ DT_Largest20.Columns.Add("ColName5");
|
|
|
+ DT_Largest20.Columns.Add("ColName6");
|
|
|
+ DT_Largest20.Columns.Add("ColVal1");
|
|
|
+ DT_Largest20.Columns.Add("ColVal2");
|
|
|
+ DT_Largest20.Columns.Add("ColVal3");
|
|
|
+ DT_Largest20.Columns.Add("ColVal4");
|
|
|
+ DT_Largest20.Columns.Add("ColVal5");
|
|
|
+ DT_Largest20.Columns.Add("ColVal6");
|
|
|
+ // 图像列
|
|
|
+ DataColumn colpict_20ago = new DataColumn("p1");
|
|
|
+ colpict_20ago.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ DT_Largest20.Columns.Add(colpict_20ago);
|
|
|
+ DataColumn colpict2_20ago = new DataColumn("p2");
|
|
|
+ colpict2_20ago.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ DT_Largest20.Columns.Add(colpict2_20ago);
|
|
|
+ DataColumn colpict3_20ago = new DataColumn("p3");
|
|
|
+ colpict3_20ago.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ DT_Largest20.Columns.Add(colpict3_20ago);
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 插入-前20颗粒部份
|
|
|
+
|
|
|
+ for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
|
|
|
+ {
|
|
|
+ if (dt_ParticlesGridDevidePage.Rows[i_row].ItemArray[24].ToString() != "Not Identified")
|
|
|
+ {
|
|
|
+ //获取颗粒的fieldid,和particleid
|
|
|
+ string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
|
|
|
+ string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
|
+ string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
|
|
|
+ string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
|
|
|
+ string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
|
|
|
+ string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
|
|
|
+
|
|
|
+ //获取原始颗粒图像
|
|
|
+ Bitmap bp_particle = new Bitmap(1, 1);
|
|
|
+ string str_path = str_resultPath + "\\FIELD_FILES\\";
|
|
|
+ string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
|
|
|
+
|
|
|
+ if (str_fieldid == "-1")
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (serialNumber > 20)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (str_subparticles != null && str_subparticles != "")
|
|
|
+ {
|
|
|
+ //合并大颗粒
|
|
|
+ double ScanFieldSize = 1142;
|
|
|
+ Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);
|
|
|
+ int pixw = tempbit.Width;
|
|
|
+ double xs = pixw / ScanFieldSize;
|
|
|
+ bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //正常颗粒
|
|
|
+ Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };
|
|
|
+ Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
|
|
|
+ bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
|
|
|
+ bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };
|
|
|
+ }
|
|
|
+ //获取该颗粒的xray能谱图像
|
|
|
+ System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
|
|
|
+ str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
|
|
|
+ Bitmap ls_xraybpnew = new Bitmap(1, 1);
|
|
|
+ ls_xraybpnew = OTSIncAReportGraph.Class.DrawFunction.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理
|
|
|
+
|
|
|
+ //获取该颗粒的二次放大处理图像
|
|
|
+ Bitmap ls_processbitmap = new Bitmap(1, 1);
|
|
|
+ ls_processbitmap = OTSIncAReportGraph.Class.DrawFunction.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善
|
|
|
+
|
|
|
+ //再将图像转成二进制流-------------------------------------------------------------------
|
|
|
+ //原图
|
|
|
+ MemoryStream newms_p1 = new MemoryStream();
|
|
|
+ bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
+ newms_p1.Seek(0, SeekOrigin.Begin);
|
|
|
+ byte[] newarr_p1 = new byte[newms_p1.Length];
|
|
|
+ newms_p1.Read(newarr_p1, 0, newarr_p1.Length);
|
|
|
+
|
|
|
+ //二次放大图
|
|
|
+ MemoryStream newms_p2 = new MemoryStream();
|
|
|
+ ls_processbitmap.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
+ newms_p2.Seek(0, SeekOrigin.Begin);
|
|
|
+ byte[] newarr_p2 = new byte[newms_p2.Length];
|
|
|
+ newms_p2.Read(newarr_p2, 0, newarr_p2.Length);
|
|
|
+
|
|
|
+ //能谱图
|
|
|
+ MemoryStream newms_p3 = new MemoryStream();
|
|
|
+ ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
+ newms_p3.Seek(0, SeekOrigin.Begin);
|
|
|
+ byte[] newarr_p3 = new byte[newms_p3.Length];
|
|
|
+ newms_p3.Read(newarr_p3, 0, newarr_p3.Length);
|
|
|
+ //---------------------------------------------------------------------------------------
|
|
|
+ DataRow dr = DT_Largest20.NewRow();
|
|
|
+
|
|
|
+ dr["p1"] = newarr_p1;
|
|
|
+ dr["p2"] = newarr_p2;
|
|
|
+ dr["p3"] = newarr_p3;
|
|
|
+ newms_p1.Dispose();
|
|
|
+ newms_p2.Dispose();
|
|
|
+ newms_p3.Dispose();
|
|
|
+
|
|
|
+ dr["pid"] = serialNumber++.ToString();
|
|
|
+ //dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
|
+ dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
|
|
|
+ dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
|
|
|
+ dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]), 2).ToString();
|
|
|
+ dr["DMIN"] = dt_ParticlesGridDevidePage.Rows[i_row]["Hardness_detailed"].ToString();
|
|
|
+ dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
|
|
|
+
|
|
|
+ List<string> list_max_elementname = new List<string>();
|
|
|
+ List<double> list_max_elementvale = new List<double>();
|
|
|
+ GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
|
|
|
+ //元素1
|
|
|
+ dr["ColName1"] = list_max_elementname[0];
|
|
|
+ dr["ColVal1"] = list_max_elementvale[0].ToString();
|
|
|
+ //元素2
|
|
|
+ dr["ColName2"] = list_max_elementname[1];
|
|
|
+ dr["ColVal2"] = list_max_elementvale[1].ToString();
|
|
|
+ //元素3
|
|
|
+ dr["ColName3"] = list_max_elementname[2];
|
|
|
+ dr["ColVal3"] = list_max_elementvale[2].ToString();
|
|
|
+ //元素4
|
|
|
+ dr["ColName4"] = list_max_elementname[3];
|
|
|
+ dr["ColVal4"] = list_max_elementvale[3].ToString();
|
|
|
+ //元素5
|
|
|
+ dr["ColName5"] = list_max_elementname[4];
|
|
|
+ dr["ColVal5"] = list_max_elementvale[4].ToString();
|
|
|
+ //元素6
|
|
|
+ dr["ColName6"] = list_max_elementname[5];
|
|
|
+ dr["ColVal6"] = list_max_elementvale[5].ToString();
|
|
|
+
|
|
|
+ DT_Largest20.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 插入-帧图图像部份
|
|
|
+ List<string> vs = new List<string>();
|
|
|
+ DataTable data = new DataTable();
|
|
|
+ //首先生成标记颗粒的帧图图像文件
|
|
|
+ DataTable dt_GridDevidePage = new DataTable();
|
|
|
+ dt_GridDevidePage = dt_ParticlesGridDevidePage.Copy();
|
|
|
+ dt_GridDevidePage.Clear();
|
|
|
+ for (int i = 0; i < dt_ParticlesGridDevidePage.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (dt_ParticlesGridDevidePage.Rows[i]["TypeName"].ToString() != "Not Identified")
|
|
|
+ {
|
|
|
+ dt_GridDevidePage.Rows.Add(dt_ParticlesGridDevidePage.Rows[i].ItemArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile(dt_GridDevidePage, out vs, out data);
|
|
|
+ string str_path_FIELD_FILES_MARK = str_resultPath + "\\FIELD_FILES_MARK\\";
|
|
|
+ DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);
|
|
|
+ if (theFolder.Exists)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < vs.Count; i++)
|
|
|
+ {
|
|
|
+ foreach (FileInfo nextifile in theFolder.GetFiles())
|
|
|
+ {
|
|
|
+ if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
|
|
|
+ {
|
|
|
+ //确认对应的帧图名
|
|
|
+ string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
|
|
|
+ if (str_fieldid == vs[i].ToString())
|
|
|
+ {
|
|
|
+ //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
|
|
|
+ DataRow[] datarowlist = dt_GridDevidePage.Select(" fieldid = " + str_fieldid);
|
|
|
+ if (datarowlist.Count() > 0)
|
|
|
+ {
|
|
|
+ Bitmap ls_bp_fieldmark = new Bitmap(nextifile.FullName);
|
|
|
+ DataRow dr = DT_field_dt.NewRow();
|
|
|
+ MemoryStream newms_bp_fieldmark = new MemoryStream();
|
|
|
+ ls_bp_fieldmark.Save(newms_bp_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
+ newms_bp_fieldmark.Seek(0, SeekOrigin.Begin);
|
|
|
+ byte[] newarr_fieldmark = new byte[newms_bp_fieldmark.Length];
|
|
|
+ newms_bp_fieldmark.Read(newarr_fieldmark, 0, newarr_fieldmark.Length);
|
|
|
+ dr["FieldImg"] = newarr_fieldmark;
|
|
|
+ dr["FieldId"] = str_fieldid;
|
|
|
+ ls_bp_fieldmark.Dispose();
|
|
|
+ DT_field_dt.Rows.Add(dr);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DT_field_dt_copy = DT_field_dt.Copy();
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 插入-前20颗粒外的颗粒
|
|
|
+ for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
|
|
|
+ {
|
|
|
+ if (dt_ParticlesGridDevidePage.Rows[i_row]["element"].ToString() == "")
|
|
|
+ continue;
|
|
|
+ //获取颗粒的fieldid,和particleid
|
|
|
+ string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
|
|
|
+ if (Convert.ToInt32(str_fieldid) < 20)
|
|
|
+ {
|
|
|
+
|
|
|
+ string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
|
+ string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();
|
|
|
+ string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();
|
|
|
+ string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();
|
|
|
+ string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();
|
|
|
+
|
|
|
+ //获取原始颗粒图像
|
|
|
+ Bitmap bp_particle = new Bitmap(1, 1);
|
|
|
+ string str_path = str_resultPath + "\\FIELD_FILES\\";
|
|
|
+ string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";
|
|
|
+ if (str_subparticles != null && str_subparticles != "")
|
|
|
+ {
|
|
|
+ //合并大颗粒
|
|
|
+ //double ScanFieldSize = 1142;
|
|
|
+ //Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);
|
|
|
+ //int pixw = tempbit.Width;
|
|
|
+ //double xs = pixw / ScanFieldSize;
|
|
|
+ //bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //正常颗粒
|
|
|
+ Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };
|
|
|
+ Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
|
|
|
+ bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
|
|
|
+ bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取该颗粒的xray能谱图像
|
|
|
+ System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
|
|
|
+ str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
|
|
|
+
|
|
|
+ //获取该颗粒的二次放大处理图像
|
|
|
+ Bitmap ls_processbitmap = new Bitmap(1, 1);
|
|
|
+ ls_processbitmap = (Bitmap)bp_particle.Clone();//待完善
|
|
|
+
|
|
|
+ //再将图像转成二进制流-------------------------------------------------------------------
|
|
|
+ //原图
|
|
|
+ MemoryStream newms_p1 = new MemoryStream();
|
|
|
+ bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
|
+ newms_p1.Seek(0, SeekOrigin.Begin);
|
|
|
+ byte[] newarr_p1 = new byte[newms_p1.Length];
|
|
|
+ newms_p1.Read(newarr_p1, 0, newarr_p1.Length);
|
|
|
+ //---------------------------------------------------------------------------------------
|
|
|
+ DataRow dr = DT_Largest_frame.NewRow();
|
|
|
+ dr["p1"] = newarr_p1;
|
|
|
+ newms_p1.Dispose();
|
|
|
+
|
|
|
+ dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
|
+ dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
|
|
|
+ dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
|
|
|
+ dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]), 2).ToString();
|
|
|
+ dr["DMIN"] = dt_ParticlesGridDevidePage.Rows[i_row]["Hardness_detailed"].ToString();
|
|
|
+ dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();
|
|
|
+
|
|
|
+ dr["fieldid"] = str_fieldid;
|
|
|
+
|
|
|
+ List<string> list_max_elementname = new List<string>();
|
|
|
+ List<double> list_max_elementvale = new List<double>();
|
|
|
+ GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);
|
|
|
+ //元素1
|
|
|
+ dr["ColName1"] = list_max_elementname[0];
|
|
|
+ dr["ColVal1"] = list_max_elementvale[0].ToString();
|
|
|
+ //元素2
|
|
|
+ dr["ColName2"] = list_max_elementname[1];
|
|
|
+ dr["ColVal2"] = list_max_elementvale[1].ToString();
|
|
|
+ //元素3
|
|
|
+ dr["ColName3"] = list_max_elementname[2];
|
|
|
+ dr["ColVal3"] = list_max_elementvale[2].ToString();
|
|
|
+ //元素4
|
|
|
+ dr["ColName4"] = list_max_elementname[3];
|
|
|
+ dr["ColVal4"] = list_max_elementvale[3].ToString();
|
|
|
+ //元素5
|
|
|
+ dr["ColName5"] = list_max_elementname[4];
|
|
|
+ dr["ColVal5"] = list_max_elementvale[4].ToString();
|
|
|
+ //元素6
|
|
|
+ dr["ColName6"] = list_max_elementname[5];
|
|
|
+ dr["ColVal6"] = list_max_elementvale[5].ToString();
|
|
|
+
|
|
|
+
|
|
|
+ DT_Largest_frame.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ FrameGraphParticleTable(dt_ParticlesGridDevidePage, str_resultPath, fielddata, DT_field_dt);
|
|
|
m_list_dt.Add(DT_field_dt_copy);
|
|
|
m_list_dt.Add(DT_Largest_frame);
|
|
|
m_list_dt.Add(DT_Largest20);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
private bool JudgeWhetherItExists(int id, DataTable dt,string column)
|
|
|
{
|
|
|
for (int i=0;i<dt.Rows.Count;i++)
|
|
@@ -717,7 +1115,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
dr["p1"] = newarr_p1;
|
|
|
newms_p1.Dispose();
|
|
|
|
|
|
- dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();
|
|
|
+ dr["pid"] = /*str_fieldid + */dt_ParticlesGridDevidePage.Rows[i_row]["Hardness_detailed"].ToString();
|
|
|
dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式
|
|
|
dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();
|
|
|
dr["DMAX"] = Math.Round(Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["dmax"]),2).ToString();
|
|
@@ -1353,7 +1751,8 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
}
|
|
|
}
|
|
|
if (bl)
|
|
|
- dataTable.Rows[0][ta.Columns[a].ToString()] = Math.Round( Convert.ToDouble(decimal.Parse(ta.Compute("sum(" + ta.Columns[a].ToString() + ")", "").ToString()))/ ElementalSubstance,2);
|
|
|
+ //datatSuncolumn(ta, ta.Columns[a].ToString());
|
|
|
+ dataTable.Rows[0][ta.Columns[a].ToString()] = Math.Round(datatSuncolumn(ta, ta.Columns[a].ToString()) / ElementalSubstance,2);
|
|
|
}
|
|
|
}
|
|
|
dataTable.Rows[0]["Name"] = ClassName[i].ToString();
|
|
@@ -1364,6 +1763,19 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
}
|
|
|
return dt_Class;
|
|
|
}
|
|
|
+ private double datatSuncolumn(DataTable dt ,string str)
|
|
|
+ {
|
|
|
+ double sum=0;
|
|
|
+ for (int i=0;i<dt.Rows.Count;i++)
|
|
|
+ {
|
|
|
+ if (dt.Rows[i][str].ToString()=="")
|
|
|
+ {
|
|
|
+ dt.Rows[i][str] = 0;
|
|
|
+ }
|
|
|
+ sum = sum+Convert.ToDouble(dt.Rows[i][str].ToString());
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
private DataTable MaterialElementComposition(DataTable a_ElementalSubstance,int NumberOfColumns)
|
|
|
{
|
|
|
DataTable dt_ElementalSubstance = new DataTable();
|