Browse Source

优化设置,导出颗粒列表没有能谱元素数据的已分类颗粒不予导出

zhangjiaxin 1 month ago
parent
commit
08dba986ec
1 changed files with 108 additions and 104 deletions
  1. 108 104
      OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/ParticleList.cs

+ 108 - 104
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/ParticleList.cs

@@ -157,113 +157,117 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 				#region 插入颗粒部份
 				DataTable FilteredData = p1Data.Clone();
 				ImageProcessor imageProcessor = new ImageProcessor();
-				for (int i_row = 0; i_row < p1Data.Rows.Count; i_row++)
-				{
-					if (p1Data.Rows[i_row].ItemArray[24].ToString() != "Not Identified")
-					{
-						//获取颗粒的fieldid,和particleid
-						string str_fieldid = p1Data.Rows[i_row]["fieldid"].ToString();
-						string str_particleid = p1Data.Rows[i_row]["particleid"].ToString();
-						string str_typeid = p1Data.Rows[i_row]["TypeId"].ToString();
-						string str_typename = p1Data.Rows[i_row]["TypeName"].ToString();
-						string str_element = p1Data.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 > m_mbszclass.M_KLLBXX.list_int_kllb_number)
-							continue;
-						Rectangle rectangle = new Rectangle()
-                        { X = Convert.ToInt32(p1Data.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(p1Data.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(p1Data.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(p1Data.Rows[i_row]["RectHeight"]) };
-						Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
-						Bitmap bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
-						bp_particle = imageProcessor.ResizeImageWithPadding(bp_particle, 120, 120, System.Drawing.Color.White);
-						bp_particle.Tag = new List<string>() { p1Data.Rows[i_row]["FieldId"].ToString(), p1Data.Rows[i_row]["ParticleId"].ToString(), p1Data.Rows[i_row]["TypeId"].ToString() };
-						//获取该颗粒的xray能谱图像
-						DataTable DT_XR = ExportXRay(str_fieldid, str_particleid, fielddata);
-						//ElementIcons.Add(DT_XR);
-						System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
-								str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
-						Bitmap ls_xraybpnew = OTSIncAReportGraph.Class.DrawFunction.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理
-						DataTable SegmentData = fielddata.GetSegment();
-						Bitmap BinaryParticles = ImageSplicer.ParticleBinaryDiagram(SegmentData, Convert.ToInt32(str_fieldid), Convert.ToInt32(str_particleid));
-						Bitmap BP = imageProcessor.ResizeImageWithPadding(BinaryParticles, 120, 120, System.Drawing.Color.White);
-						//获取该颗粒的二次放大处理图像
-						//Bitmap ls_processbitmap = OTSIncAReportGraph.Class.DrawFunction.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善
-						//再将图像转成二进制流-------------------------------------------------------------------
-						//原图
-						MemoryStream newms_p1 = new MemoryStream();
-						bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
-						//二次放大图
-						MemoryStream newms_p2 = new MemoryStream();
-						BP.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
-						//能谱图
-						MemoryStream newms_p3 = new MemoryStream();
-						ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
-						//---------------------------------------------------------------------------------------                   
-						DataRow dr = DT_Largest20.NewRow();
-						dr["p1"] = bp_particle;
-						dr["p2"] = BP;
-						dr["p3"] = ls_xraybpnew;
-
-
-						newms_p1.Dispose();
-						newms_p2.Dispose();
-						newms_p3.Dispose();
-						dr["pid"] = serialNumber++.ToString();
-						//颗粒列表列中第一个可选参数
-						dr["Size"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1);
-						//这个参数没有用
-						dr["Width"] = p1Data.Rows[i_row]["rectwidth"].ToString();
-						//颗粒列表列中第二个可选参数
-						dr["DMAX"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p2);
-						//颗粒列表列中第三个可选参数
-						dr["DMIN"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p3);
-						//颗粒列表列中显示分类不可以选择
-						dr["Class"] = p1Data.Rows[i_row]["typename"].ToString();
-
-						dr["GroupName"] = p1Data.Rows[i_row]["GroupName"].ToString();
-						GetMaxElementFromDataTable(p1Data, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
-						double colVal = 0;
-						for (int a = 0; a < list_max_elementvale.Count; a++)
+                for (int i_row = 0; i_row < p1Data.Rows.Count; i_row++)
+                {
+                    if (p1Data.Rows[i_row]["Element"].ToString() != "")
+                    {
+						if (p1Data.Rows[i_row].ItemArray[24].ToString() != "Not Identified")
 						{
-							colVal = colVal + Convert.ToDouble(list_max_elementvale[a]);
+							//获取颗粒的fieldid,和particleid
+							string str_fieldid = p1Data.Rows[i_row]["fieldid"].ToString();
+							string str_particleid = p1Data.Rows[i_row]["particleid"].ToString();
+							string str_typeid = p1Data.Rows[i_row]["TypeId"].ToString();
+							string str_typename = p1Data.Rows[i_row]["TypeName"].ToString();
+							string str_element = p1Data.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 > m_mbszclass.M_KLLBXX.list_int_kllb_number)
+								continue;
+							Rectangle rectangle = new Rectangle()
+							{ X = Convert.ToInt32(p1Data.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(p1Data.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(p1Data.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(p1Data.Rows[i_row]["RectHeight"]) };
+							Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);
+							Bitmap bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);
+							bp_particle = imageProcessor.ResizeImageWithPadding(bp_particle, 120, 120, System.Drawing.Color.White);
+							bp_particle.Tag = new List<string>() { p1Data.Rows[i_row]["FieldId"].ToString(), p1Data.Rows[i_row]["ParticleId"].ToString(), p1Data.Rows[i_row]["TypeId"].ToString() };
+							//获取该颗粒的xray能谱图像
+							DataTable DT_XR = ExportXRay(str_fieldid, str_particleid, fielddata);
+							//ElementIcons.Add(DT_XR);
+							System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,
+									str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);
+							Bitmap ls_xraybpnew = OTSIncAReportGraph.Class.DrawFunction.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理
+							DataTable SegmentData = fielddata.GetSegment();
+							Bitmap BinaryParticles = ImageSplicer.ParticleBinaryDiagram(SegmentData, Convert.ToInt32(str_fieldid), Convert.ToInt32(str_particleid));
+							Bitmap BP = imageProcessor.ResizeImageWithPadding(BinaryParticles, 120, 120, System.Drawing.Color.White);
+							//获取该颗粒的二次放大处理图像
+							//Bitmap ls_processbitmap = OTSIncAReportGraph.Class.DrawFunction.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善
+							//再将图像转成二进制流-------------------------------------------------------------------
+							//原图
+							MemoryStream newms_p1 = new MemoryStream();
+							bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);
+							//二次放大图
+							MemoryStream newms_p2 = new MemoryStream();
+							BP.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);
+							//能谱图
+							MemoryStream newms_p3 = new MemoryStream();
+							ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);
+							//---------------------------------------------------------------------------------------                   
+							DataRow dr = DT_Largest20.NewRow();
+							dr["p1"] = bp_particle;
+							dr["p2"] = BP;
+							dr["p3"] = ls_xraybpnew;
+
+
+							newms_p1.Dispose();
+							newms_p2.Dispose();
+							newms_p3.Dispose();
+							dr["pid"] = serialNumber++.ToString();
+							//颗粒列表列中第一个可选参数
+							dr["Size"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p1);
+							//这个参数没有用
+							dr["Width"] = p1Data.Rows[i_row]["rectwidth"].ToString();
+							//颗粒列表列中第二个可选参数
+							dr["DMAX"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p2);
+							//颗粒列表列中第三个可选参数
+							dr["DMIN"] = datatable_data(p1Data, i_row, m_mbszclass.M_KLLBXX.str_cb_kllb_sort_p3);
+							//颗粒列表列中显示分类不可以选择
+							dr["Class"] = p1Data.Rows[i_row]["typename"].ToString();
+
+							dr["GroupName"] = p1Data.Rows[i_row]["GroupName"].ToString();
+							GetMaxElementFromDataTable(p1Data, i_row, out List<string> list_max_elementname, out List<double> list_max_elementvale);
+							double colVal = 0;
+							for (int a = 0; a < list_max_elementvale.Count; a++)
+							{
+								colVal = colVal + Convert.ToDouble(list_max_elementvale[a]);
+							}
+							//元素1
+							dr["ColName1"] = list_max_elementname[0];
+							dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
+							//元素2
+							dr["ColName2"] = list_max_elementname[1];
+							dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
+							//元素3
+							dr["ColName3"] = list_max_elementname[2];
+							dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
+							//元素4
+							dr["ColName4"] = list_max_elementname[3];
+							dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
+							//元素5
+							dr["ColName5"] = list_max_elementname[4];
+							dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
+							//元素6
+							dr["ColName6"] = list_max_elementname[5];
+							dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
+							//元素7
+							dr["ColName7"] = list_max_elementname[6];
+							dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
+							//元素8
+							dr["ColName8"] = list_max_elementname[7];
+							dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
+							//元素6
+							dr["ColName9"] = list_max_elementname[8];
+							dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
+							//元素6
+							dr["ColName9"] = list_max_elementname[9];
+							dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[9]);
+							DT_Largest20.Rows.Add(dr);
+							FilteredData.Rows.Add(p1Data.Rows[i_row].ItemArray);
 						}
-						//元素1
-						dr["ColName1"] = list_max_elementname[0];
-						dr["ColVal1"] = ParameterNormalization(colVal, list_max_elementvale[0]);
-						//元素2
-						dr["ColName2"] = list_max_elementname[1];
-						dr["ColVal2"] = ParameterNormalization(colVal, list_max_elementvale[1]);
-						//元素3
-						dr["ColName3"] = list_max_elementname[2];
-						dr["ColVal3"] = ParameterNormalization(colVal, list_max_elementvale[2]);
-						//元素4
-						dr["ColName4"] = list_max_elementname[3];
-						dr["ColVal4"] = ParameterNormalization(colVal, list_max_elementvale[3]);
-						//元素5
-						dr["ColName5"] = list_max_elementname[4];
-						dr["ColVal5"] = ParameterNormalization(colVal, list_max_elementvale[4]);
-						//元素6
-						dr["ColName6"] = list_max_elementname[5];
-						dr["ColVal6"] = ParameterNormalization(colVal, list_max_elementvale[5]);
-						//元素7
-						dr["ColName7"] = list_max_elementname[6];
-						dr["ColVal7"] = ParameterNormalization(colVal, list_max_elementvale[6]);
-						//元素8
-						dr["ColName8"] = list_max_elementname[7];
-						dr["ColVal8"] = ParameterNormalization(colVal, list_max_elementvale[7]);
-						//元素6
-						dr["ColName9"] = list_max_elementname[8];
-						dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[8]);
-						//元素6
-						dr["ColName9"] = list_max_elementname[9];
-						dr["ColVal9"] = ParameterNormalization(colVal, list_max_elementvale[9]);
-						DT_Largest20.Rows.Add(dr);
-						FilteredData.Rows.Add(p1Data.Rows[i_row].ItemArray);
 					}
+			
 				}
                 #endregion
                 OutDt.Add(DT_Largest20);