From 1aeba205ca41da0f9c31bb7c0e3c0d8534f69e61 Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周四, 14 11月 2024 17:20:40 +0800
Subject: [PATCH] fabu

---
 DataCapture_MA/Form1.cs |   45 ++++++++++++++++++++++++++++-----------------
 1 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/DataCapture_MA/Form1.cs b/DataCapture_MA/Form1.cs
index c737007..9a7579b 100644
--- a/DataCapture_MA/Form1.cs
+++ b/DataCapture_MA/Form1.cs
@@ -41,6 +41,9 @@
             AutoMapper.Mapper.Initialize((cfg) => {
                 cfg.AddProfile<MapperConfiguration>();
             });
+
+            // 鍒犻櫎涓�涓湀鍓嶇殑鏁版嵁
+            new Thread(AutoDeleteHistoryDate.Handler).Start();
         }
 
         private void ReceiveHandle()
@@ -130,27 +133,35 @@
 
         private void CreateDatabase()
         {
-            using (var context = new DbModel())
+            try
             {
-                // 纭繚鏁版嵁搴撳拰琛ㄥ瓨鍦紝濡傛灉涓嶅瓨鍦ㄥ垯鍒涘缓
-                context.Database.EnsureCreated();
-
-                // 娣诲姞涓�浜涙暟鎹�
-                context.RobotInfo.Add(new RobotInfo
+                using (var context = new DbModel())
                 {
-                    WarnningNum = 0,
-                    //RobotStatus = "Normal",
-                    RobotModel = "Model X",
-                    RobotSerialNo = "123456",
-                    WarnningContent = "娓呴櫎瀵屾枃鏈鏁版嵁",
-                    CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
-                    IsDelete = false
-                });
+                    // 纭繚鏁版嵁搴撳拰琛ㄥ瓨鍦紝濡傛灉涓嶅瓨鍦ㄥ垯鍒涘缓
+                    context.Database.EnsureCreated();
 
-                // 淇濆瓨鏇存敼
-                context.SaveChanges();
+                    // 娣诲姞涓�浜涙暟鎹�
+                    context.RobotInfo.Add(new RobotInfo
+                    {
+                        WarnningNum = 0,
+                        //RobotStatus = "Normal",
+                        RobotModel = "Model X",
+                        RobotSerialNo = "123456",
+                        WarnningContent = "娓呴櫎瀵屾枃鏈鏁版嵁",
+                        CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                        CreateStamp = DateTimeOffset.Now.ToUnixTimeSeconds(),
+                        IsDelete = false
+                    });
 
-                var xx = context.RobotInfo.ToList();
+                    // 淇濆瓨鏇存敼
+                    context.SaveChanges();
+
+                    var xx = context.RobotInfo.ToList();
+                }
+            }
+            catch (Exception ex)
+            {
+                r_showBox.Text = "鏁版嵁搴撳垵濮嬪寲寮傚父"+ ex.Message;
             }
         }
 

--
Gitblit v1.9.3