为系统配置添加上数据库
This commit is contained in:
parent
3c736f9d5b
commit
9f1db152eb
|
|
@ -31,7 +31,7 @@ public partial class MainWindow : Window
|
||||||
log = logService;
|
log = logService;
|
||||||
db = databaseService;
|
db = databaseService;
|
||||||
even = eventService;
|
even = eventService;
|
||||||
menu = new MenuController(this);// 初始化菜单控制器
|
menu = new MenuController(this, log, db, even);// 初始化菜单控制器
|
||||||
sensorManager = new SensorChartManager(this, log, db, even)
|
sensorManager = new SensorChartManager(this, log, db, even)
|
||||||
{
|
{
|
||||||
Sensor1 = Sensor1,
|
Sensor1 = Sensor1,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="新文件夹\**" />
|
||||||
|
<EmbeddedResource Remove="新文件夹\**" />
|
||||||
|
<None Remove="新文件夹\**" />
|
||||||
|
<Page Remove="新文件夹\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="src\public\Icons\main1-file-icon.png" />
|
<None Remove="src\public\Icons\main1-file-icon.png" />
|
||||||
<None Remove="src\public\Icons\main2-config-icon.png" />
|
<None Remove="src\public\Icons\main2-config-icon.png" />
|
||||||
|
|
@ -67,7 +74,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="src\public\Excel\" />
|
<Folder Include="src\public\Excel\" />
|
||||||
<Folder Include="新文件夹\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,14 @@
|
||||||
"Connection": "DataSource=LocalData.db",
|
"Connection": "DataSource=LocalData.db",
|
||||||
"Remarks": "",
|
"Remarks": "",
|
||||||
"Print": false
|
"Print": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "D1",
|
||||||
|
"Enabled": true,
|
||||||
|
"Type": 2,
|
||||||
|
"Connection": "DataSource=D1.db",
|
||||||
|
"Remarks": "产品数据库",
|
||||||
|
"Print": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows;
|
using guoke;
|
||||||
|
using System.Windows;
|
||||||
using WpfApp.src.view;
|
using WpfApp.src.view;
|
||||||
using WpfApp.Utils;
|
using WpfApp.Utils;
|
||||||
|
|
||||||
|
|
@ -10,9 +11,14 @@ namespace WpfApp.src.controllers
|
||||||
public class MenuController
|
public class MenuController
|
||||||
{
|
{
|
||||||
private readonly Window mainWindow;
|
private readonly Window mainWindow;
|
||||||
|
private readonly LogService log;
|
||||||
public MenuController(Window window)
|
private readonly DatabaseService db;
|
||||||
|
private readonly EventService<GeneralEventArgs> even;
|
||||||
|
public MenuController(Window window, LogService logService, DatabaseService databaseService, EventService<GeneralEventArgs> eventService)
|
||||||
{
|
{
|
||||||
|
log = logService;
|
||||||
|
db = databaseService;
|
||||||
|
even = eventService;
|
||||||
mainWindow = window;
|
mainWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,7 +38,7 @@ namespace WpfApp.src.controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OpenConfigPage()
|
public void OpenConfigPage()
|
||||||
{
|
{
|
||||||
WindowHelper.ShowPageDialog(new ConfigPage(),
|
WindowHelper.ShowPageDialog(new ConfigPage(log, db, even),
|
||||||
"配置", 972, 648,
|
"配置", 972, 648,
|
||||||
isResizable: false,
|
isResizable: false,
|
||||||
IconHelper.GetIconPath("main2-Config.ico"));
|
IconHelper.GetIconPath("main2-Config.ico"));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
using guoke;
|
using guoke;
|
||||||
|
using SqlSugar;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using static WpfApp.MainWindow;
|
||||||
|
|
||||||
namespace WpfApp.src.view;
|
namespace WpfApp.src.view;
|
||||||
|
|
||||||
|
|
@ -13,12 +15,24 @@ public partial class ConfigPage : Page
|
||||||
// 等级数据字典,每个等级对应 LevelInfo
|
// 等级数据字典,每个等级对应 LevelInfo
|
||||||
private Dictionary<string, LevelInfo> levelData;
|
private Dictionary<string, LevelInfo> levelData;
|
||||||
private Dictionary<int, SensorToleranceData> sensorData;
|
private Dictionary<int, SensorToleranceData> sensorData;
|
||||||
|
private readonly LogService log;
|
||||||
|
private readonly DatabaseService db;
|
||||||
|
private readonly EventService<GeneralEventArgs> even;
|
||||||
|
|
||||||
public ConfigPage()
|
public ConfigPage(LogService logService, DatabaseService databaseService, EventService<GeneralEventArgs> eventService)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InitializeLevelData();
|
InitializeLevelData();
|
||||||
InitializeSensorData();
|
InitializeSensorData();
|
||||||
|
log = logService;
|
||||||
|
db = databaseService;
|
||||||
|
even = eventService;
|
||||||
|
SqlSugarScope scope = db.GetScope("D1");
|
||||||
|
scope.guokeCheckToCreate<Product>();
|
||||||
|
scope.guokeCheckToCreate<SensorSelection>();
|
||||||
|
scope.guokeCheckToCreate<SensorToleranceData>();
|
||||||
|
scope.guokeCheckToCreate<MainSensorSelection>();
|
||||||
|
scope.guokeCheckToCreate<LevelInfo>();
|
||||||
|
|
||||||
// 注册等级标签按钮点击事件
|
// 注册等级标签按钮点击事件
|
||||||
LevelTabUnder.Click += LevelTab_Click;
|
LevelTabUnder.Click += LevelTab_Click;
|
||||||
|
|
@ -256,40 +270,21 @@ public partial class ConfigPage : Page
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 产品信息数据类
|
/// 产品信息数据类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Product
|
[SugarTable("Product")]
|
||||||
|
public class Product : BaseTableModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 主键 ID
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 产品名称
|
/// 产品名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime CreatedTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime UpdatedTime { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传感器选择数据类
|
/// 传感器选择数据类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SensorSelection
|
[SugarTable("SensorSelection")]
|
||||||
|
public class SensorSelection : BaseTableModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 主键 ID
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传感器1 名称或编号
|
/// 传感器1 名称或编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -314,28 +309,14 @@ public class SensorSelection
|
||||||
/// 所属产品名称
|
/// 所属产品名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime CreatedTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime UpdatedTime { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传感器公差数据类
|
/// 传感器公差数据类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SensorToleranceData
|
[SugarTable("SensorToleranceData")]
|
||||||
|
public class SensorToleranceData : BaseTableModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 主键 ID
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传感器名称(如 “传感器1”)
|
/// 传感器名称(如 “传感器1”)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -361,27 +342,14 @@ public class SensorToleranceData
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime CreatedTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime UpdatedTime { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主传感器选择数据类
|
/// 主传感器选择数据类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MainSensorSelection
|
[SugarTable("MainSensorSelection")]
|
||||||
|
public class MainSensorSelection : BaseTableModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 主键 ID
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数字传感器1 是否为主传感器
|
/// 数字传感器1 是否为主传感器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -406,24 +374,13 @@ public class MainSensorSelection
|
||||||
/// 所属产品名称
|
/// 所属产品名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProductName { get; set; }
|
public string ProductName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime CreatedTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新时间
|
|
||||||
/// </summary>
|
|
||||||
public DateTime UpdatedTime { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 等级信息数据类
|
/// 等级信息数据类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SugarTable("LevelInfo")]
|
||||||
public class LevelInfo
|
public class LevelInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user