diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 60317f5..2c28fd4 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
log = logService;
db = databaseService;
even = eventService;
- menu = new MenuController(this);// 初始化菜单控制器
+ menu = new MenuController(this, log, db, even);// 初始化菜单控制器
sensorManager = new SensorChartManager(this, log, db, even)
{
Sensor1 = Sensor1,
diff --git a/WpfApp.csproj b/WpfApp.csproj
index 4d672f2..3891a00 100644
--- a/WpfApp.csproj
+++ b/WpfApp.csproj
@@ -8,6 +8,13 @@
true
+
+
+
+
+
+
+
@@ -67,7 +74,6 @@
-
diff --git a/appsettings.json b/appsettings.json
index d831697..fb56042 100644
--- a/appsettings.json
+++ b/appsettings.json
@@ -13,6 +13,14 @@
"Connection": "DataSource=LocalData.db",
"Remarks": "",
"Print": false
+ },
+ {
+ "Name": "D1",
+ "Enabled": true,
+ "Type": 2,
+ "Connection": "DataSource=D1.db",
+ "Remarks": "产品数据库",
+ "Print": true
}
]
}
diff --git a/src/controllers/MenuController.cs b/src/controllers/MenuController.cs
index 2a422d0..70f9a6d 100644
--- a/src/controllers/MenuController.cs
+++ b/src/controllers/MenuController.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using guoke;
+using System.Windows;
using WpfApp.src.view;
using WpfApp.Utils;
@@ -10,9 +11,14 @@ namespace WpfApp.src.controllers
public class MenuController
{
private readonly Window mainWindow;
-
- public MenuController(Window window)
+ private readonly LogService log;
+ private readonly DatabaseService db;
+ private readonly EventService even;
+ public MenuController(Window window, LogService logService, DatabaseService databaseService, EventService eventService)
{
+ log = logService;
+ db = databaseService;
+ even = eventService;
mainWindow = window;
}
@@ -32,7 +38,7 @@ namespace WpfApp.src.controllers
///
public void OpenConfigPage()
{
- WindowHelper.ShowPageDialog(new ConfigPage(),
+ WindowHelper.ShowPageDialog(new ConfigPage(log, db, even),
"配置", 972, 648,
isResizable: false,
IconHelper.GetIconPath("main2-Config.ico"));
diff --git a/src/view/ConfigPage.xaml.cs b/src/view/ConfigPage.xaml.cs
index 56dd01b..4750540 100644
--- a/src/view/ConfigPage.xaml.cs
+++ b/src/view/ConfigPage.xaml.cs
@@ -1,7 +1,9 @@
using guoke;
+using SqlSugar;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using static WpfApp.MainWindow;
namespace WpfApp.src.view;
@@ -13,12 +15,24 @@ public partial class ConfigPage : Page
// 等级数据字典,每个等级对应 LevelInfo
private Dictionary levelData;
private Dictionary sensorData;
+ private readonly LogService log;
+ private readonly DatabaseService db;
+ private readonly EventService even;
- public ConfigPage()
+ public ConfigPage(LogService logService, DatabaseService databaseService, EventService eventService)
{
InitializeComponent();
InitializeLevelData();
InitializeSensorData();
+ log = logService;
+ db = databaseService;
+ even = eventService;
+ SqlSugarScope scope = db.GetScope("D1");
+ scope.guokeCheckToCreate();
+ scope.guokeCheckToCreate();
+ scope.guokeCheckToCreate();
+ scope.guokeCheckToCreate();
+ scope.guokeCheckToCreate();
// 注册等级标签按钮点击事件
LevelTabUnder.Click += LevelTab_Click;
@@ -256,40 +270,21 @@ public partial class ConfigPage : Page
///
/// 产品信息数据类
///
-public class Product
+[SugarTable("Product")]
+public class Product : BaseTableModel
{
- ///
- /// 主键 ID
- ///
- public int Id { get; set; }
-
///
/// 产品名称
///
public string Name { get; set; }
-
-
- ///
- /// 创建时间
- ///
- public DateTime CreatedTime { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime UpdatedTime { get; set; }
}
///
/// 传感器选择数据类
///
-public class SensorSelection
+[SugarTable("SensorSelection")]
+public class SensorSelection : BaseTableModel
{
- ///
- /// 主键 ID
- ///
- public int Id { get; set; }
-
///
/// 传感器1 名称或编号
///
@@ -314,28 +309,14 @@ public class SensorSelection
/// 所属产品名称
///
public string ProductName { get; set; }
-
- ///
- /// 创建时间
- ///
- public DateTime CreatedTime { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime UpdatedTime { get; set; }
}
///
/// 传感器公差数据类
///
-public class SensorToleranceData
+[SugarTable("SensorToleranceData")]
+public class SensorToleranceData : BaseTableModel
{
- ///
- /// 主键 ID
- ///
- public int Id { get; set; }
-
///
/// 传感器名称(如 “传感器1”)
///
@@ -361,27 +342,14 @@ public class SensorToleranceData
///
public string ProductName { get; set; }
- ///
- /// 创建时间
- ///
- public DateTime CreatedTime { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime UpdatedTime { get; set; }
}
///
/// 主传感器选择数据类
///
-public class MainSensorSelection
+[SugarTable("MainSensorSelection")]
+public class MainSensorSelection : BaseTableModel
{
- ///
- /// 主键 ID
- ///
- public int Id { get; set; }
-
///
/// 数字传感器1 是否为主传感器
///
@@ -406,24 +374,13 @@ public class MainSensorSelection
/// 所属产品名称
///
public string ProductName { get; set; }
-
-
- ///
- /// 创建时间
- ///
- public DateTime CreatedTime { get; set; }
-
- ///
- /// 更新时间
- ///
- public DateTime UpdatedTime { get; set; }
-
}
///
/// 等级信息数据类
///
+[SugarTable("LevelInfo")]
public class LevelInfo
{
///