浏览代码

Merge branch 'OTSRelease3_0' of http://36.129.163.148:30080/gogsadmin/OTS into OTSRelease3_0

zhangjiaxin 1 年之前
父节点
当前提交
46305c3fa8

+ 0 - 4
OTSCPP/OTSClassifyEngine/ExpressionParseEngine/ZeroElementRulesDataDB.cpp

@@ -142,10 +142,6 @@ namespace OTSClassifyEngine
 		nCol = (int)CZeroElementRulesDataTable::ColumnID::S_Expression - (int)CZeroElementRulesDataTable::ColumnID::MIN;
 		sExpression = a_query->GetColStringValue(nCol, _T(""));
 		m_ZeroElementRuleItem->SetExpressionStr(sExpression.GetString());
-		if (sExpression == "")
-		{
-			return FALSE;
-		}
 		return TRUE;
 	}
 	

+ 1 - 6
OTSCPP/OTSClassifyEngine/SpectrumCompareEngine/OTSSTDLibFileMgr.cpp

@@ -132,12 +132,7 @@ namespace OTSClassifyEngine
 		GetZeroElementRulesDataDB();
 
 		auto rules= m_pZeroElementRulesDataDB->GetZeroElementRulesLib(bClear);
-		if (rules.size() == 0)
-		{
-			AfxMessageBox(_T("The format of the zero element rule is incorrect. Please use the zero element interface in the standard library editor to save and try again!"));
-				
-			return FALSE;
-		}
+		
 		lib->setZeroElementRuleList(rules);
 
 		return TRUE;

+ 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("检测到该数据库零元素规则格式错误,已进行修正!");
+                }
+            }
+        }
     }
 }