diff --git a/.vs/HighWayIot/v16/.suo b/.vs/HighWayIot/v16/.suo index d1e65301..3a0cb03a 100644 Binary files a/.vs/HighWayIot/v16/.suo and b/.vs/HighWayIot/v16/.suo differ diff --git a/Aucma.Scada.UI/App.config b/Aucma.Scada.UI/App.config new file mode 100644 index 00000000..b665e49c --- /dev/null +++ b/Aucma.Scada.UI/App.config @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aucma.Scada.UI/App.xaml b/Aucma.Scada.UI/App.xaml new file mode 100644 index 00000000..0b226d26 --- /dev/null +++ b/Aucma.Scada.UI/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/Aucma.Scada.UI/App.xaml.cs b/Aucma.Scada.UI/App.xaml.cs new file mode 100644 index 00000000..089ebbfa --- /dev/null +++ b/Aucma.Scada.UI/App.xaml.cs @@ -0,0 +1,132 @@ +using HighWayIot.Log4net; +using Lierda.WPFHelper; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; + +namespace Aucma.Scada.UI +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + private LogHelper logHelper = LogHelper.Instance; + + System.Threading.Mutex mutex; + + LierdaCracker cracker = new LierdaCracker(); + + public App() + { + this.Startup += new StartupEventHandler(App_StartUp); + this.Exit += new ExitEventHandler(Application_Exit); + + } + + void App_StartUp(object sender, StartupEventArgs e) + { + bool ret; + mutex = new System.Threading.Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out ret); + if (!ret) + { + MessageBox.Show("应用程序已开启,禁止重复运行"); + Environment.Exit(0); + } + } + private void Application_Exit(object sender, ExitEventArgs e) + { + logHelper.Info("程序退出"); + } + + protected override void OnStartup(StartupEventArgs e) + { + cracker.Cracker(100); //设置GC回收间隔 + RegisterEvents(); + base.OnStartup(e); + } + + private void RegisterEvents() + { + TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; + this.DispatcherUnhandledException += App_DispatcherUnhandledException; + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandleException; + } + + /// + /// Task线程异常捕获 + /// + /// + /// + private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) + { + try + { + var exception = e.Exception as Exception; + if (exception != null) + { + logHelper.Error("Task线程全局异常捕获成功", exception); + } + } + catch (Exception ex) + { + logHelper.Error("Task线程全局异常捕获", ex); + } + finally + { + e.SetObserved(); + } + } + + /// + /// UI线程异常捕获 + /// + /// + /// + private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) + { + try + { + logHelper.Error("UI线程全局异常捕获成功", e.Exception); + } + catch (Exception ex) + { + logHelper.Error("UI线程全局异常捕获", ex); + } + finally + { + e.Handled = true; + } + } + + /// + /// 非UI线程异常捕获 + /// + /// + /// + private void CurrentDomain_UnhandleException(object sender, UnhandledExceptionEventArgs e) + { + try + { + var exception = e.ExceptionObject as Exception; + if (exception != null) + { + logHelper.Error("非UI线程全局异常捕获成功", exception); + } + } + catch (Exception ex) + { + logHelper.Error("非UI线程全局异常捕获", ex); + } + finally + { + //e.SetObserved(); + } + } + } +} diff --git a/Aucma.Scada.UI/Aucma.Scada.UI.csproj b/Aucma.Scada.UI/Aucma.Scada.UI.csproj new file mode 100644 index 00000000..121ff12e --- /dev/null +++ b/Aucma.Scada.UI/Aucma.Scada.UI.csproj @@ -0,0 +1,173 @@ + + + + + Debug + AnyCPU + {43123E0B-B3B0-4FB4-A508-007D644B3E7C} + WinExe + Aucma.Scada.UI + Aucma.Scada.UI + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\HighWayIot.Library\Lierda.WPFHelper.dll + + + ..\HighWayIot.Library\MySql.Data.dll + + + ..\HighWayIot.Library\Oracle.ManagedDataAccess.dll + + + ..\HighWayIot.Library\SqlSugar.dll + + + + + ..\HighWayIot.Library\System.Data.SQLite.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + IndexControl.xaml + + + LogInfoControl.xaml + + + RecordControl.xaml + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + {deabc30c-ec6f-472e-bd67-d65702fdaf74} + HighWayIot.Log4net + + + {d0dc3cfb-6748-4d5e-b56a-76fdc72ab4b3} + HighWayIot.Repository + + + + + + + \ No newline at end of file diff --git a/Aucma.Scada.UI/Icon.png b/Aucma.Scada.UI/Icon.png new file mode 100644 index 00000000..15604655 Binary files /dev/null and b/Aucma.Scada.UI/Icon.png differ diff --git a/Aucma.Scada.UI/IndexControl.xaml b/Aucma.Scada.UI/IndexControl.xaml new file mode 100644 index 00000000..bd724292 --- /dev/null +++ b/Aucma.Scada.UI/IndexControl.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Aucma.Scada.UI/IndexControl.xaml.cs b/Aucma.Scada.UI/IndexControl.xaml.cs new file mode 100644 index 00000000..8984935e --- /dev/null +++ b/Aucma.Scada.UI/IndexControl.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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; + +namespace Aucma.Scada.UI +{ + /// + /// IndexControl.xaml 的交互逻辑 + /// + public partial class IndexControl : UserControl + { + public IndexControl() + { + InitializeComponent(); + } + } +} diff --git a/Aucma.Scada.UI/LogInfoControl.xaml b/Aucma.Scada.UI/LogInfoControl.xaml new file mode 100644 index 00000000..f593d462 --- /dev/null +++ b/Aucma.Scada.UI/LogInfoControl.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Aucma.Scada.UI/LogInfoControl.xaml.cs b/Aucma.Scada.UI/LogInfoControl.xaml.cs new file mode 100644 index 00000000..e33b5662 --- /dev/null +++ b/Aucma.Scada.UI/LogInfoControl.xaml.cs @@ -0,0 +1,33 @@ +using Aucma.Scada.UI.viewModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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; + +namespace Aucma.Scada.UI +{ + /// + /// LogInfoControl.xaml 的交互逻辑 + /// + public partial class LogInfoControl : UserControl + { + + public LogInfoControl() + { + InitializeComponent(); + + LogInfoViewModel logInfoViewModel = new LogInfoViewModel(); + this.DataContext = logInfoViewModel; + } + } +} diff --git a/Aucma.Scada.UI/MainWindow.xaml b/Aucma.Scada.UI/MainWindow.xaml new file mode 100644 index 00000000..4ebc72e4 --- /dev/null +++ b/Aucma.Scada.UI/MainWindow.xaml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +