Explorar el Código

标准库编辑器打开检测并修改零元素规则字段的顺序

cxs hace 1 año
padre
commit
1f5573712c

+ 1 - 1
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSPropertyWindow.cs

@@ -392,6 +392,6 @@ namespace OTSMeasureApp
             var stype = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetSysType();
             OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype);
             DisplaySampleMeasureInfo(MeasureInfo);
-        }3434
+        }
     }
 }

+ 45 - 0
OTSPartA_STDEditor/UI/Form_Main.cs

@@ -1172,6 +1172,7 @@ namespace OTSPartA_STDEditor
                     InitForms(STDDBAddress);
                     this.Text = this.Text.Split(' ')[0] + "   " + STDDBAddress;
                     IsModified = false;
+                    CheckAccuracyofZeroRules();
                 }
                 catch(Exception ex)
                 {
@@ -1385,5 +1386,49 @@ namespace OTSPartA_STDEditor
                 return;
             }
         }
+
+        void CheckAccuracyofZeroRules()
+        {
+            System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + STDDBAddress + "'");
+            m_dbConnection.Open();
+            System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ZeroElementRules", m_dbConnection);
+            DataSet ds = new DataSet();
+            m_dataAdapter.Fill(ds);
+            DataTable dt = ds.Tables[0];
+            DataTable dt2 = dt.Copy();
+            if (dt != null)
+            {
+                if (dt.Columns[dt.Columns.Count - 1].ColumnName != "Expression")
+                {
+                    System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
+
+                    
+                    cmm.CommandText = "CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM ZeroElementRules";
+                    cmm.ExecuteNonQuery();
+                    cmm.CommandText = "DROP TABLE ZeroElementRules";
+                    cmm.ExecuteNonQuery();
+                    cmm.CommandText = "CREATE TABLE ZeroElementRules (ZeroElement TEXT,UsingElementList TEXT,UsingImgPropertyList TEXT,UsingOtherPropertyList TEXT,expression TEXT)";
+                    cmm.ExecuteNonQuery();
+                    cmm.CommandText = @"INSERT INTO ZeroElementRules (
+                                 ZeroElement,
+                                 UsingElementList,
+                                 UsingImgPropertyList,
+                                 UsingOtherPropertyList,
+                                 expression
+                             )
+                             SELECT ZeroElement,
+                                    UsingElementList,
+                                    UsingImgPropertyList,
+                                    UsingOtherPropertyList,
+                                    expression
+                               FROM sqlitestudio_temp_table; ";
+                    cmm.ExecuteNonQuery();
+                    cmm.CommandText = "DROP TABLE sqlitestudio_temp_table";
+                    cmm.ExecuteNonQuery();
+                    m_dbConnection.Close();
+                    MessageBox.Show("检测到该数据库零元素规则格式错误,已进行修正!");
+                }
+            }
+        }
     }
 }