Jelajahi Sumber

修改优化备份数据代码位置

zhangjiaxin 3 tahun lalu
induk
melakukan
8e8a37747e

+ 71 - 1
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -2162,7 +2162,7 @@ namespace OTSIncAReportGraph.Controls
             if (dr== DialogResult.OK)
             {
                 
-               if (ReportFun.DeleteParticlesFromLibrary(m_mouseOver_dparticle.ParticleId, m_mouseOver_dparticle.FieldId))
+               if (DeleteParticlesFromLibrary(m_mouseOver_dparticle.ParticleId, m_mouseOver_dparticle.FieldId))
                 {
                     MessageBox.Show("Deleted successfully");
 
@@ -2184,6 +2184,76 @@ namespace OTSIncAReportGraph.Controls
             }
            
         }
+
+
+        private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        {
+            bool DoesItExist = false;
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
+                {
+                    DoesItExist = true;
+                    break;
+                }
+            }
+            if (!DoesItExist)
+            {
+                //备份数据库
+                BackupDatabase();
+            }
+            DoesItExist = false;
+
+            //防止为空校验判断
+            if (resultFile.List_OTSField == null)
+                return false;
+            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
+            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
+            {
+
+                return true;
+            }
+            else
+
+            {
+                return false;
+            }
+        }
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
         int GetsIntersectionOfTheIntercepts(Point P1,Point P2,int y)
         {
             int x = (y - P1.Y * P2.X + P1.X * P2.Y) / (P2.Y - P1.Y);

+ 3 - 7
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionSortImage.cs

@@ -929,22 +929,18 @@ namespace OTSIncAReportGraph.Controls
                 Point sem_point = (Point)in_obj;
 
                 //第一步,连接电镜
-                m_ReportFun.ConnectToIpcSvr();
+                
 
-                Thread.Sleep(500);
 
                 //第二步,移动到指定位置,先读取再设置
-                if (m_ReportFun.m_SEMConnectionState == true)
+                if (m_ReportFun.ConnectToIpcSvr())
                 {
                     m_ReportFun.MoveSemToPointXY(sem_point.X, sem_point.Y);
                 }
 
                 Thread.Sleep(1500);
 
-                //第三步,断开电镜连接
-                m_ReportFun.DisConnectSEM();
-
-                //Thread.Sleep(1000);
+             
 
                 m_mythread_state = false;
             }

+ 1 - 68
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -345,74 +345,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 
         }
 
-        public bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
-        {
-            bool DoesItExist = false;
-            for (int i=1;i<201;i++)
-            {
-                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups"+i.ToString()))
-                {
-                    DoesItExist = true;
-                    break;
-                }
-            }
-            if (!DoesItExist)
-            {
-                //备份数据库
-                BackupDatabase();
-            }
-            DoesItExist = false;
-
-            //防止为空校验判断
-            if (resultFile.List_OTSField == null)
-                return false;
-            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
-            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
-            {
-                
-                return true;
-            }else
-
-            {
-                return false;
-            }
-        }
-
-        public bool BackupDatabase()
-        {
-            //创建备份数据库文件夹
-            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
-            string sourceName = "Inclusion.db";//源文件名称
-            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
-            string Fields = "";
-            for (int i = 1; i < 201; i++)
-            {
-                if (System.IO.Directory.Exists(folderPath + i.ToString()))
-                {
-                    Fields = folderPath + i.ToString();
-                    break;
-                }
-                else
-                {
-                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
-                    Fields = folderPath + i.ToString();
-                    break;
-                }
-            }
-            if (Fields == "")
-            {
-                return false;
-            }
-            //复制数据库文件
-            string targetPath = Path.Combine(Fields, sourceName);
-            FileInfo file = new FileInfo(sourcePath);
-            if (file.Exists)
-            {
-                file.CopyTo(targetPath, true);
-            }
-
-            return true;
-        }
+        
         /// <summary>
         /// 传入所有的物理field坐标点,和单个物理field的宽高,返回所有field的左上角位置,和整个field组成的rect大小
         /// </summary>

+ 0 - 11
OTSIncAReportApp/1-UI/Control_Grids/OTSIncAReportGridsFuncation/OTSReportGridsFun.cs

@@ -237,17 +237,6 @@ namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
 
         }
 
-        /// <summary>
-        /// 断开电镜连接
-        /// </summary>
-        public void DisConnectSEM_ForParticlesGrid()
-        {
-            m_cfun.DisConnect();
-            //if (m_cfun.DisConnectSem() == true)
-
-            m_SEMConnectionState = false;
-        }
-
         #endregion
 
         #region 获取数据_测量结果概况

+ 71 - 2
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -1148,7 +1148,7 @@ namespace OTSIncAReportGrids
                 Thread.Sleep(1500);
 
                 //第三步,断开电镜连接
-                m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
+                //m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
 
                 //Thread.Sleep(500);
 
@@ -2096,7 +2096,7 @@ namespace OTSIncAReportGrids
                     {
                         if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
                         {
-                            if (ReportFun.DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
+                            if (DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
                             {
                                 MessageBox.Show("Deleted successfully");
 
@@ -2121,6 +2121,75 @@ namespace OTSIncAReportGrids
                 }
             }
         }
+
+        private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        {
+            bool DoesItExist = false;
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
+                {
+                    DoesItExist = true;
+                    break;
+                }
+            }
+            if (!DoesItExist)
+            {
+                //备份数据库
+                BackupDatabase();
+            }
+            DoesItExist = false;
+
+            //防止为空校验判断
+            if (resultFile.List_OTSField == null)
+                return false;
+            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
+            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
+            {
+
+                return true;
+            }
+            else
+
+            {
+                return false;
+            }
+        }
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
         private void DisplayData()
         {
             if (cbB_PageSize.SelectedItem.ToString() == "All")

+ 0 - 4
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -252,10 +252,6 @@ namespace OTSIncAReportApp._1_UI
 
             Thread.Sleep(500);
 
-            //第三步,断开电镜连接
-            m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
-
-            //Thread.Sleep(500);
         }
 
         private void bgw_process_ProgressChanged(object sender, ProgressChangedEventArgs e)

+ 37 - 1
OTSIncAReportApp/1-UI/frmReportApp.cs

@@ -1161,7 +1161,7 @@ namespace OTSIncAReportApp
             resultFile = m_rstDataMgr.CurResultFile;
             ReportFun = new OTSImageDisHelp(resultFile);
 
-            if (ReportFun.BackupDatabase())
+            if (BackupDatabase())
             {
                 MessageBox.Show("Backup succeeded");
             }
@@ -1170,6 +1170,42 @@ namespace OTSIncAReportApp
                 MessageBox.Show("Backup failed");
             }
         }
+
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
     }
 }