HaoShuang 4 年之前
父節點
當前提交
f1369d582b

+ 29 - 19
DBManager/MeasureDB.cs

@@ -48,6 +48,12 @@ namespace DBManager
             m_db.Open();           
         }
 
+        //关闭数据库
+        public void CloseDB()
+        {
+            m_db.Close();
+        }
+
         //创建分析点表
         public void CreateAnalysisPointsTable()
         {
@@ -177,28 +183,31 @@ namespace DBManager
             string sPrimary = ", PRIMARY KEY( ";
 
             //第1列, ID,是主键
+            sql = sql + "XrayID INTEGER";
+            sPrimary = sPrimary + "XrayID";
+
+            //第2列,AID
+            sql = sql + ",";
             sql = sql + "AID INTEGER";
-            sPrimary = sPrimary + "AID";
+            sPrimary = sPrimary + ", AID";
 
-            //第2列,SegNum
+            //第3列,SegNum
             sql = sql + ",";
             sql = sql + "SegNum INTEGER";
-            sPrimary = sPrimary + ", SegNum";
-
-            //第3列,SegID
+           
+            //第4列,SegID
             sql = sql + ",";
             sql = sql + "SegID INTEGER";
-            sPrimary = sPrimary + ", SegID";
-
-            //第4列,X
+            
+            //第5列,X
             sql = sql + ",";
             sql = sql + "X INTEGER";
 
-            //第5列,Y
+            //第6列,Y
             sql = sql + ",";
             sql = sql + "Y INTEGER";
 
-            //第6列,Length
+            //第7列,Length
             sql = sql + ",";
             sql = sql + "Length INTEGER";
 
@@ -233,7 +242,7 @@ namespace DBManager
         }
 
         //插入一条点扫描Xray的信息
-        public bool InsertAPointXay(int PointsId, int XrayId, int X, int Y,long[] XrayData, List<Dictionary<string, double>> listElement)
+        public bool InsertAPointXay(int PointsId, int XrayId, int X, int Y,long[] XrayData, Dictionary<string, double> listElement)
         {
             byte[] bArray = new byte[8000];
 
@@ -265,15 +274,15 @@ namespace DBManager
 
                 //向能谱元素表插入数据
                 int i = 0;
-                foreach (Dictionary<string, double> element in listElement)
+                foreach (KeyValuePair<string, double> element in listElement)
                 {
 
                     sql = "INSERT INTO Element(XayID, ElementNum, ElementID, Name, Percent) values ("
                        + XrayId.ToString() + ","
                        + listElement.Count.ToString() + ","
                        + i.ToString() + ","
-                       + element.Keys + ","
-                       + element.Values.ToString() + ")";
+                       + element.Key + ","
+                       + element.Value.ToString() + ")";
 
                     command = new SQLiteCommand(sql, m_db);
                     command.ExecuteNonQuery();
@@ -286,7 +295,7 @@ namespace DBManager
         }
 
         //插入一条面扫描Xray的信息
-        public bool InsertAAreaXay(int PointsId, int PointName, int XrayId, int AreaId, List<Segment> listSeg,long[] XrayData, List<Dictionary<string, double>> listElement)
+        public bool InsertAAreaXay(int PointsId, int XrayId, int AreaId, List<Segment> listSeg,long[] XrayData, Dictionary<string, double> listElement)
         {
             byte[] bArray = new byte[8000];
 
@@ -317,15 +326,15 @@ namespace DBManager
                 
                 //向能谱元素表插入数据
                 int i = 0;
-                foreach (Dictionary<string, double> element in listElement)
+                foreach (KeyValuePair<string, double> element in listElement)
                 {
 
                     sql = "INSERT INTO Element(XayID, ElementNum, ElementID, Name, Percent) values ("
                        + XrayId.ToString() + ","
                        + listElement.Count.ToString() + ","
                        + i.ToString() + ","
-                       + element.Keys + ","
-                       + element.Values.ToString() + ")";
+                       + element.Key + ","
+                       + element.Value.ToString() + ")";
 
                     command = new SQLiteCommand(sql, m_db);
                     command.ExecuteNonQuery();
@@ -337,8 +346,9 @@ namespace DBManager
                 foreach (Segment seg in listSeg)
                 {
 
-                    sql = "INSERT INTO AreaPosition(XayID, SegNum, SegID, X, Y, Length) values ("
+                    sql = "INSERT INTO AreaPosition(XayID, AID, SegNum, SegID, X, Y, Length) values ("
                        + XrayId.ToString() + ","
+                       + AreaId.ToString() + ","
                        + listSeg.Count.ToString() + ","
                        + i.ToString() + ","
                        + seg.X.ToString() + ","

+ 2 - 1
MeasureThread/Measure.cs

@@ -616,7 +616,7 @@ namespace MeasureThread
 
                     //写入数据库
                     m_nXrayId++;
-                    //InsertAPointXay(a_PointNum, m_nXrayId, pt.X, pt.Y, XrayData, listElement);
+                    m_MeasDB.InsertAPointXay(a_PointNum, m_nXrayId, pt.X, pt.Y, XrayData, listElement);
                     
                 }
             }
@@ -634,6 +634,7 @@ namespace MeasureThread
                     m_nXrayId++;
                     
                     AreasNo++;
+                    m_MeasDB.InsertAAreaXay(a_PointNum, m_nXrayId, AreasNo, listSeg, XrayData, listElement);
                 }
             }
 

二進制
packages/System.Data.SQLite.x64.1.0.113.0/lib/net46/System.Data.SQLite.dll


二進制
packages/System.ValueTuple.4.5.0/lib/net461/System.ValueTuple.dll