Jelajahi Sumber

update the sql statement for calling particles in the particle list

cxs 1 bulan lalu
induk
melakukan
87aec9fd91

+ 10 - 65
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -300,21 +300,11 @@ namespace OTSIncAReportGrids
             if (sel == (int)SelItem.analyticalParticle)
             {
 
-                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
-                DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
-                if (mergeParticles != null && mergeParticles.Rows.Count > 0)
-                {
-                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
-                }
+                particlesAll = Particledata.GetInfoForPartucleDevidePage_analyticalParticle(condition);
             }
             if (sel == (int)SelItem.otherParticles)
             {
-                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
-                DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
-                if (mergeParticles != null && mergeParticles.Rows.Count > 0)
-                {
-                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
-                }
+                particlesAll = Particledata.GetInfoForPartucleDevidePage_otherParticle(condition);
             }
             if (sel == (int)SelItem.MergeParticles)
             {
@@ -322,12 +312,7 @@ namespace OTSIncAReportGrids
             }
             if (sel == (int)SelItem.allParticles)
             {
-                DataTable particlesAll = Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
-                DataTable mergeParticles = Particledata.GetInfoForPartucleDevidePage_mergeParticles(condition);
-                if (mergeParticles != null && mergeParticles.Rows.Count > 0)
-                {
-                    Particledata.RemoveMergeParticles(ref particlesAll, mergeParticles);
-                }
+                particlesAll = Particledata.GetInfoForPartucleDevidePage_allParticles(condition);
             }
             particlesAll.Columns.Add("Hardness");
             particlesAll.Columns.Add("Density");
@@ -496,7 +481,7 @@ namespace OTSIncAReportGrids
                 }
                 particles.ImportRow(particlesAll.Rows[fi]);
             }
-            string particleM = "";
+
             List<string> ElementTypeSort = new List<string>(str_ElementsColName.Split(',').ToList());//去重
             for (int i = 0; i < ElementTypeSort.Count; i++)
             {
@@ -511,7 +496,7 @@ namespace OTSIncAReportGrids
             }
             double jd = 95f / (double)particles.Rows.Count;
             string filePath = result.FilePath + "\\FIELD_FILES\\";
-            KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
+            
             for (int i = 0; i < particles.Rows.Count; i++)
             {
                 if (i % 10 == 0)
@@ -528,51 +513,11 @@ namespace OTSIncAReportGrids
                     {
                         if (enl.Current.Key == "ParticleImage")
                         {
-                            if (particles.Columns.Contains("SubParticles"))
-                            {
-                                string subt = particles.Rows[i]["SubParticles"].ToString();
-                                if (subt != null && subt != "")
-                                {
-                                    double ScanFieldSize = result.GetScanFieldSizeX();
-                                    string filePatht = result.FilePath + "\\FIELD_FILES\\";
-                                    string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
-                                    Bitmap tempbit = Particledata.ReadImageFile(imagePatht);
-                                    int pixw = tempbit.Width;
-                                    double xs = pixw / ScanFieldSize;
-                                    OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
-                                    OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
-                                    particleM = particleM + "," + subt;
-                                    Bitmap bmap = Particledata.GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION,Y_AXIS_DIRECTION);
-                                    if (bmap != null)
-                                    {
-                                        string[] str = subt.Split(',');
-                                        bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
-                                        //dgV_ParticlesDevidePage.Rows[add_rowindex].Height= dgV_ParticlesDevidePage.Rows[add_rowindex].Height< bmap.Height ? bmap.Height: dgV_ParticlesDevidePage.Rows[add_rowindex].Height;
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].DefaultCellStyle.ForeColor = Color.Chocolate;
-                                    }
-                                    else
-                                    {
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
-                                        dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
-                                    }
-                                }
-                            }
-                            else
-                            {
-                                if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
-                                {
-                                    string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
-                                    FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
-                                }
-                                Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
-                                Bitmap bmap = Particledata.GetBitmapByParticle(FieldImage.Value, rectangle);
-                                bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString(), particles.Rows[i]["XrayId"].ToString() };
-                                dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
-                                dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
-                            }
+                            string subt = particles.Rows[i]["SubParticles"].ToString();
+                            dgV_ParticlesDevidePage.Rows[add_rowindex].Height = 150;
+                            
+                            dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = Particledata.GetParticlescreenshot(subt,result);
+                            dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Style.BackColor = Color.Azure;
                         }
                         if (enl.Current.Key == "DiameterRatio")
                         {

+ 59 - 10
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/ParticleData.cs

@@ -4,6 +4,7 @@ using DevExpress.XtraEditors.Filtering;
 using OTSCommon.DBOperate;
 using OTSCommon.DBOperate.Model;
 using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
+using OTSIncAReportApp.OTSRstMgrFunction;
 using OTSIncAReportGraph.Controls;
 using OTSPeriodicTable;
 using System;
@@ -767,7 +768,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
 		public DataTable GetInfoForPartucleDevidePage_analyticalParticle(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4)" +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle') " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
@@ -777,7 +778,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
 
         public DataTable GetInfoForPartucleDevidePage_otherParticle(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and typeid =9 or typeid =-1 or typeid =4) " +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1  and SubParticles is not 'IsSubParticle' and (typeid =9 or typeid =0 or typeid =-1 or typeid =4)) " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
@@ -790,31 +791,39 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         /// <returns></returns>
         public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
-                "as 'SEMPosX',FieldPosY as 'SEMPosY',XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles,''as Element from MergedParticleInfo where 1=1 " + condition;
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData where (SubParticles Is not null and SubParticles is not 'IsSubParticle' )" + condition;
             DataTable DT1 = new DataTable();
             try
             {
                 DT1 = dbHelper.ExecuteQuery(sqliteString);
             }
-            catch  
+            catch
             {
-            
+
             }
             return DT1;
         }
 
         public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData  where xrayid > -1 " +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData  where xrayid > -1 and SubParticles is not 'IsSubParticle' " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
             return DT;
         }
+        
+        
+        
+        
+        
+        
+        
+        
+        
         public DataTable GetInfoForPartucleDevidePage_NotIdentifyParticle(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =9 " +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =9 " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
@@ -822,7 +831,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         }
         public DataTable GetInfoForPartucleDevidePage_InvalidParticle(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =-1 " +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =-1 " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
@@ -830,7 +839,7 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
         }
         public DataTable GetInfoForPartucleDevidePage_LowCountsParticle(string condition)
         {
-            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 typeid =4 " +
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticle,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 typeid =4 " +
                 condition;
             DataTable DT = new DataTable();
             DT = dbHelper.ExecuteQuery(sqliteString);
@@ -1400,6 +1409,46 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
             return list_showelementinfo;
         }
+        
+
+        public Bitmap GetParticlescreenshot(string subt, ResultFile result)
+        {
+            Bitmap bmap = null;
+            KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
+            if (subt != null && subt != "" && subt != "IsSubParticle")
+            {
+                double ScanFieldSize = result.GetScanFieldSizeX();
+                string filePatht = result.FilePath + "\\FIELD_FILES\\";
+                string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
+                Bitmap tempbit = ReadImageFile(imagePatht);
+                int pixw = tempbit.Width;
+                double xs = pixw / ScanFieldSize;
+                OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
+                OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
+                
+
+                bmap = GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
+                if (bmap != null)
+                {
+                    string[] str = subt.Split(',');
+                    //bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1], particles.Rows[i]["TypeId"].ToString() };
+                }
+            }
+            else if (subt != "IsSubParticle")
+            {
+                //if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
+                //{
+                //    string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
+                //    FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
+                //}
+                //Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
+                //Bitmap bmap = GetBitmapByParticle(FieldImage.Value, rectangle);
+                //bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString(), particles.Rows[i]["XrayId"].ToString() };
+                //dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
+                //dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
+            }
+            return bmap;
+        }
         #endregion