添加项目文件。
This commit is contained in:
31
WPFWCSDemo/ViewModels/Settings/AboutViewModel.cs
Normal file
31
WPFWCSDemo/ViewModels/Settings/AboutViewModel.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace WPFWCSDemo.ViewModels.Settings
|
||||
{
|
||||
public partial class AboutViewModel:ObservableObject
|
||||
{
|
||||
[RelayCommand]
|
||||
void WebNavigation()
|
||||
{
|
||||
string url = "http://www.yctd.cn/";
|
||||
|
||||
Uri uri = new Uri(url);
|
||||
|
||||
// 使用Process.Start打开默认浏览器
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = uri.ToString(),
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
71
WPFWCSDemo/ViewModels/Settings/SettingViewModel.cs
Normal file
71
WPFWCSDemo/ViewModels/Settings/SettingViewModel.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Xml.Linq;
|
||||
using WPFWCSDemo.Models;
|
||||
using WPFWCSDemo.Utilities;
|
||||
using WPFWCSDemo.ViewModels.Settings;
|
||||
using WPFWCSDemo.Views.Settings;
|
||||
|
||||
namespace WPFWCSDemo.ViewModels
|
||||
{
|
||||
public partial class SettingViewModel : ObservableObject
|
||||
{
|
||||
private readonly Frame frame;
|
||||
public SettingViewModel(Frame navigationFrame)
|
||||
{
|
||||
frame = navigationFrame;
|
||||
|
||||
Menu = new ObservableCollection<SettingMenu>();
|
||||
CreateSettingMenu();
|
||||
|
||||
SkinViewModel.GetFrame(frame);
|
||||
|
||||
frame.Navigate(new Uri($"Views\\Settings\\SystemView.xaml", UriKind.Relative));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 菜单选择项
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
ObservableCollection<SettingMenu> _menu;
|
||||
|
||||
|
||||
void CreateSettingMenu()
|
||||
{
|
||||
Menu.Add(new SettingMenu() { Icon = "Pencil", Title = "个性化", NameSpace = "SkinView"/*nameof(SkinView)*/ });
|
||||
Menu.Add(new SettingMenu() { Icon = "Tools", Title = "系统设置", NameSpace = "SystemView" });
|
||||
Menu.Add(new SettingMenu() { Icon = "ExclamationThick", Title = "关于", NameSpace = "AboutView" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换导航
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
[RelayCommand]
|
||||
void SettingNavigate(SettingMenu menu)
|
||||
{
|
||||
try
|
||||
{
|
||||
frame.Navigate(new Uri($"Views\\Settings\\{menu.NameSpace}.xaml", UriKind.Relative));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
77
WPFWCSDemo/ViewModels/Settings/SkinViewModel.cs
Normal file
77
WPFWCSDemo/ViewModels/Settings/SkinViewModel.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using MaterialDesignColors;
|
||||
using MaterialDesignColors.ColorManipulation;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WPFWCSDemo.ViewModels.Settings
|
||||
{
|
||||
public partial class SkinViewModel:ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
static Frame frame;
|
||||
|
||||
public IEnumerable<ISwatch> Swatches { get; } = SwatchHelper.Swatches;
|
||||
|
||||
|
||||
//深浅色切换
|
||||
private bool _isDarkTheme;
|
||||
public bool IsDarkTheme
|
||||
{
|
||||
get => _isDarkTheme;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isDarkTheme, value))
|
||||
{
|
||||
ModifyTheme(theme => theme.SetBaseTheme(value ? Theme.Dark : Theme.Light));
|
||||
}
|
||||
}
|
||||
}
|
||||
//切换主题
|
||||
private static void ModifyTheme(Action<ITheme> modificationAction)
|
||||
{
|
||||
var paletteHelper = new PaletteHelper();
|
||||
ITheme theme = paletteHelper.GetTheme();
|
||||
|
||||
modificationAction?.Invoke(theme);
|
||||
|
||||
paletteHelper.SetTheme(theme);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private readonly PaletteHelper paletteHelper = new PaletteHelper();
|
||||
|
||||
/// <summary>
|
||||
/// 改变颜色
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
[RelayCommand]
|
||||
public void ChangeHue(object? obj)
|
||||
{
|
||||
var hue = (Color)obj!;
|
||||
|
||||
ITheme theme = paletteHelper.GetTheme();
|
||||
|
||||
theme.PrimaryLight = new ColorPair(hue.Lighten());
|
||||
theme.PrimaryMid = new ColorPair(hue);
|
||||
theme.PrimaryDark = new ColorPair(hue.Darken());
|
||||
|
||||
paletteHelper.SetTheme(theme);
|
||||
}
|
||||
|
||||
|
||||
public static void GetFrame(Frame navigationFrame)
|
||||
{
|
||||
frame = navigationFrame;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
389
WPFWCSDemo/ViewModels/Settings/SystemViewModel.cs
Normal file
389
WPFWCSDemo/ViewModels/Settings/SystemViewModel.cs
Normal file
@@ -0,0 +1,389 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using WPFWCSDemo.Models;
|
||||
using WPFWCSDemo.Schedules;
|
||||
using WPFWCSDemo.StateCode;
|
||||
using WPFWCSDemo.Utilities;
|
||||
using WPFWCSDemo.Views;
|
||||
|
||||
namespace WPFWCSDemo.ViewModels.Settings
|
||||
{
|
||||
public partial class SystemViewModel:ObservableObject
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 选中删除任务数据
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _isTaskDataDelete;
|
||||
|
||||
/// <summary>
|
||||
/// 选中删除报警数据
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _isAlarmDataDelete;
|
||||
|
||||
/// <summary>
|
||||
/// 实垛A线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineAStr = "重置A线请求标志";
|
||||
/// <summary>
|
||||
/// 实垛B线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineBStr = "重置B线请求标志";
|
||||
/// <summary>
|
||||
/// 实垛C线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineCStr = "重置C线请求标志";
|
||||
/// <summary>
|
||||
/// 实垛D线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineDStr = "重置D线请求标志";
|
||||
/// <summary>
|
||||
/// 实垛AB线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineABStr = "重置AB线请求标志";
|
||||
/// <summary>
|
||||
/// 实垛CD线显示文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _lineCDStr = "重置CD线请求标志";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否限制实垛A线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineAIsEnable = true;
|
||||
/// <summary>
|
||||
/// 是否限制实垛B线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineBIsEnable = true;
|
||||
/// <summary>
|
||||
/// 是否限制实垛C线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineCIsEnable = true;
|
||||
/// <summary>
|
||||
/// 是否限制实垛D线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineDIsEnable = true;
|
||||
/// <summary>
|
||||
/// 是否限制空托AB线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineABIsEnable = true;
|
||||
/// <summary>
|
||||
/// 是否限制空托CD线生成任务 0-解禁 1-禁止
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
bool _lineCDIsEnable = true;
|
||||
|
||||
/// <summary>
|
||||
/// A手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineAIsEnable = true;
|
||||
/// <summary>
|
||||
/// B手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineBIsEnable = true;
|
||||
/// <summary>
|
||||
/// C手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineCIsEnable = true;
|
||||
/// <summary>
|
||||
/// D手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineDIsEnable = true;
|
||||
/// <summary>
|
||||
/// AB手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineABIsEnable = true;
|
||||
/// <summary>
|
||||
/// CD手动允许下发标志
|
||||
/// </summary>
|
||||
public static bool lineCDIsEnable = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手动备份当前数据库
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
void GetSqlDBBackup()
|
||||
{
|
||||
if (MessageBox.Show("确定创建备份文件吗(此操作会生成一份备份文件)?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
SqlDatabaseMaintenance.SQLBackup();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("操作已取消");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除近3个月之外所有任务记录(保留最近3个月内数据)
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
void DeleteDataOutOfTreeMouths()
|
||||
{
|
||||
if (MessageBox.Show("确定删除数据吗(此操作会保留最近3个月内的数据,且删除最近3个月之外的数据)?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery("DELETE FROM TASK_HISTORY WHERE FINISHTIME<@FinishTime",
|
||||
new SqlParameter("@FinishTime", DateTime.Now.AddMonths(-3).ToString("yyyy-MM"))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调度任务备份
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
void TaskBackup()
|
||||
{
|
||||
if (MessageBox.Show("确定创建备份文件吗?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
if (IsTaskDataDelete)
|
||||
{
|
||||
if (MessageBox.Show("将删除已备份的【调度任务历史记录】数据,是否继续?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
SqlDatabaseMaintenance.SQLTaskBackup("Month", -6, IsTaskDataDelete);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("备份操作已取消");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//选择仅备份不删除数据
|
||||
SqlDatabaseMaintenance.SQLTaskBackup("Month", -6, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 历史报警备份
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
void AlarmBackup()
|
||||
{
|
||||
if (MessageBox.Show("确定创建备份文件吗?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
if (IsAlarmDataDelete)
|
||||
{
|
||||
if (MessageBox.Show("将删除已备份的【报警历史记录】数据,是否继续?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
SqlDatabaseMaintenance.SQLAlarmBackup("Month", -6, IsAlarmDataDelete);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("备份操作已取消");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//选择仅备份不删除数据
|
||||
SqlDatabaseMaintenance.SQLAlarmBackup("Month", -6, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 货位初始化
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
void CargoInitialize()
|
||||
{
|
||||
string result = Microsoft.VisualBasic.Interaction.InputBox("Enter something:", "Input Dialog", "");
|
||||
MessageBox.Show("You entered: " + result);
|
||||
CargoTableInitialize.CargoSpaceInit(10,50,5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手动控制输送线是否允许下发任务 true-允许 false-禁止
|
||||
/// </summary>
|
||||
/// <param name="lineName">实垛:A,B,C,D 空托:AB,CD</param>
|
||||
[RelayCommand]
|
||||
void LineIsEnabled(string lineName)
|
||||
{
|
||||
switch (lineName)
|
||||
{
|
||||
case "A":
|
||||
if (LineAIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止A线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineAIsEnable = false;
|
||||
lineAIsEnable = false;
|
||||
LineAStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineAStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许A线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineAIsEnable = true;
|
||||
lineAIsEnable = true;
|
||||
LineAStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineAStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "B":
|
||||
if (LineBIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止B线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineBIsEnable = false;
|
||||
lineBIsEnable = false;
|
||||
LineBStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineBStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许B线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineBIsEnable = true;
|
||||
lineBIsEnable = true;
|
||||
LineBStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineBStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "C":
|
||||
if (LineCIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止C线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineCIsEnable = false;
|
||||
lineCIsEnable = false;
|
||||
LineCStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineCStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许C线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineCIsEnable = true;
|
||||
lineCIsEnable = true;
|
||||
LineCStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineCStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "D":
|
||||
if (LineDIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止D线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineDIsEnable = false;
|
||||
lineDIsEnable = false;
|
||||
LineDStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineDStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许D线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineDIsEnable = true;
|
||||
lineDIsEnable = true;
|
||||
LineDStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineDStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "AB":
|
||||
if (LineABIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止AB线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineABIsEnable = false;
|
||||
lineABIsEnable = false;
|
||||
LineABStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineABStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许AB线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineABIsEnable = true;
|
||||
lineABIsEnable = true;
|
||||
LineABStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineABStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "CD":
|
||||
if (LineCDIsEnable)
|
||||
{
|
||||
if (MessageBox.Show("是否禁止CD线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineCDIsEnable = false;
|
||||
lineCDIsEnable = false;
|
||||
LineCDStr = "禁止下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineCDStr}】", "USER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show("是否允许CD线生成任务?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
LineCDIsEnable = true;
|
||||
lineCDIsEnable = true;
|
||||
LineCDStr = "允许下发";
|
||||
|
||||
SqlHelper.NewEventLog($"人工完成任务:{lineName}线切换为【{LineCDStr}】", "USER");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user