整理代码

This commit is contained in:
LAPTOP-SA27O0CB\guoke 2025-09-30 14:37:47 +08:00
parent b09382e51a
commit 20db9fc3eb
3 changed files with 10 additions and 17 deletions

View File

@ -35,7 +35,7 @@ namespace WpfApp
base.OnStartup(e);
// 创建互斥锁,确保应用程序只能启动一个实例
bool createdNew;
_mutex = new Mutex(true, "WinFormsAppSingleInstanceMutex", out createdNew);
_mutex = new Mutex(true, "WpfAppSingleInstanceMutex", out createdNew);
// 配置依赖注入
ServiceProvider = ServiceConfiguration.ConfigureServices();
// 初始化日志服务从依赖注入容器中获取实例这会触发构造函数并初始化LogService.Log
@ -46,24 +46,28 @@ namespace WpfApp
if (!createdNew)
{
MessageBox.Show("应用程序已经在运行中,不能重复启动!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
return; // 退出应用程序
Shutdown(); // 退出应用程序
return;
}
if (!HslCommunication.Authorization.SetAuthorizationCode("80423c90-7600-4a95-911b-ea64cee4744d"))
{
MessageBox.Show("应用程序内部组件错误无法启动!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
return; // 退出应用程序
Shutdown(); // 退出应用程序
return;
}
//绑定主板或cpu 改变了主板或cpu的序列号退出程序
if (!CheckHardwareBinding())
{
MessageBox.Show("检测到硬件环境发生变化,应用程序无法启动!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
LogService.Log.Info($"硬件环境序列号:{HardwareInfo.GetHardwareId()}");
return; // 退出应用程序
Shutdown(); // 退出应用程序
return;
}
if (DateTime.Now >= new DateTime(2028, 6, 19))
{
MessageBox.Show("错误:程序运行环境崩溃,请重新部署软件环境", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
Shutdown(); // 退出应用程序
return;
}

View File

@ -1,15 +1,6 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using guoke;
using SqlSugar;
using System.Windows;
namespace WpfApp
{

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace guoke
{