commit 3f40aa0f35faf5e44b979ceb547b96548525707b Author: maqiao <625215135@qq.com> Date: Tue Feb 27 09:01:14 2024 +0800 添加项目文件。 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/Common/Common.csproj b/Common/Common.csproj new file mode 100644 index 0000000..90c6633 --- /dev/null +++ b/Common/Common.csproj @@ -0,0 +1,13 @@ + + + + net6.0-windows + enable + true + + + + + + + diff --git a/Common/ValidatRules/ValidationErrorMappingBehavior.cs b/Common/ValidatRules/ValidationErrorMappingBehavior.cs new file mode 100644 index 0000000..ed432a7 --- /dev/null +++ b/Common/ValidatRules/ValidationErrorMappingBehavior.cs @@ -0,0 +1,75 @@ +using Microsoft.Xaml.Behaviors; +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Controls; + +namespace Common.ValidatRules +{ + public class ValidationErrorMappingBehavior : Behavior + { + #region Properties + + public static readonly DependencyProperty ValidationErrorsProperty = + DependencyProperty.Register("ValidationErrors", typeof(ObservableCollection), + typeof(ValidationErrorMappingBehavior), new PropertyMetadata(new ObservableCollection())); + + public ObservableCollection ValidationErrors + { + get { return (ObservableCollection)this.GetValue(ValidationErrorsProperty); } + set { this.SetValue(ValidationErrorsProperty, value); } + } + + public static readonly DependencyProperty HasValidationErrorProperty = DependencyProperty.Register("HasValidationError", + typeof(bool), typeof(ValidationErrorMappingBehavior), new PropertyMetadata(false)); + + public bool HasValidationError + { + get { return (bool)this.GetValue(HasValidationErrorProperty); } + set { this.SetValue(HasValidationErrorProperty, value); } + } + + #endregion + + #region Constructors + + public ValidationErrorMappingBehavior() + : base() + { } + + #endregion + + #region Events & Event Methods + + private void Validation_Error(object sender, ValidationErrorEventArgs e) + { + if (e.Action == ValidationErrorEventAction.Added) + { + this.ValidationErrors.Add(e.Error); + } + else + { + this.ValidationErrors.Remove(e.Error); + } + + this.HasValidationError = this.ValidationErrors.Count > 0; + } + + #endregion + + #region Support Methods + + protected override void OnAttached() + { + base.OnAttached(); + Validation.AddErrorHandler(this.AssociatedObject, Validation_Error); + } + + protected override void OnDetaching() + { + base.OnDetaching(); + Validation.RemoveErrorHandler(this.AssociatedObject, Validation_Error); + } + + #endregion + } +} diff --git a/DM_Weight.Commons/DM_Weight.Commons.csproj b/DM_Weight.Commons/DM_Weight.Commons.csproj new file mode 100644 index 0000000..90c6633 --- /dev/null +++ b/DM_Weight.Commons/DM_Weight.Commons.csproj @@ -0,0 +1,13 @@ + + + + net6.0-windows + enable + true + + + + + + + diff --git a/DM_Weight.Commons/ValidatRules/ValidationErrorMappingBehavior.cs b/DM_Weight.Commons/ValidatRules/ValidationErrorMappingBehavior.cs new file mode 100644 index 0000000..fce3c87 --- /dev/null +++ b/DM_Weight.Commons/ValidatRules/ValidationErrorMappingBehavior.cs @@ -0,0 +1,75 @@ +using Microsoft.Xaml.Behaviors; +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Controls; + +namespace DM_Weight.Commons.ValidatRules +{ + public class ValidationErrorMappingBehavior : Behavior + { + #region Properties + + public static readonly DependencyProperty ValidationErrorsProperty = + DependencyProperty.Register("ValidationErrors", typeof(ObservableCollection), + typeof(ValidationErrorMappingBehavior), new PropertyMetadata(new ObservableCollection())); + + public ObservableCollection ValidationErrors + { + get { return (ObservableCollection)this.GetValue(ValidationErrorsProperty); } + set { this.SetValue(ValidationErrorsProperty, value); } + } + + public static readonly DependencyProperty HasValidationErrorProperty = DependencyProperty.Register("HasValidationError", + typeof(bool), typeof(ValidationErrorMappingBehavior), new PropertyMetadata(false)); + + public bool HasValidationError + { + get { return (bool)this.GetValue(HasValidationErrorProperty); } + set { this.SetValue(HasValidationErrorProperty, value); } + } + + #endregion + + #region Constructors + + public ValidationErrorMappingBehavior() + : base() + { } + + #endregion + + #region Events & Event Methods + + private void Validation_Error(object sender, ValidationErrorEventArgs e) + { + if (e.Action == ValidationErrorEventAction.Added) + { + this.ValidationErrors.Add(e.Error); + } + else + { + this.ValidationErrors.Remove(e.Error); + } + + this.HasValidationError = this.ValidationErrors.Count > 0; + } + + #endregion + + #region Support Methods + + protected override void OnAttached() + { + base.OnAttached(); + Validation.AddErrorHandler(this.AssociatedObject, Validation_Error); + } + + protected override void OnDetaching() + { + base.OnDetaching(); + Validation.RemoveErrorHandler(this.AssociatedObject, Validation_Error); + } + + #endregion + } +} diff --git a/DM_Weight.sln b/DM_Weight.sln new file mode 100644 index 0000000..538774a --- /dev/null +++ b/DM_Weight.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32922.545 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DM_Weight", "DM_Weight\DM_Weight.csproj", "{439FA76B-F874-40DB-BAF2-E3647CD55B10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DM_Weight.Commons", "DM_Weight.Commons\DM_Weight.Commons.csproj", "{CBB05319-9054-4D93-86B3-C9B4395CE909}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {439FA76B-F874-40DB-BAF2-E3647CD55B10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {439FA76B-F874-40DB-BAF2-E3647CD55B10}.Release|Any CPU.Build.0 = Release|Any CPU + {CBB05319-9054-4D93-86B3-C9B4395CE909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBB05319-9054-4D93-86B3-C9B4395CE909}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBB05319-9054-4D93-86B3-C9B4395CE909}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBB05319-9054-4D93-86B3-C9B4395CE909}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E50E8179-1102-41F1-92F5-2905C75898A6} + EndGlobalSection +EndGlobal diff --git a/DM_Weight/App.config b/DM_Weight/App.config new file mode 100644 index 0000000..33ede04 --- /dev/null +++ b/DM_Weight/App.config @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DM_Weight/App.xaml b/DM_Weight/App.xaml new file mode 100644 index 0000000..6c8e926 --- /dev/null +++ b/DM_Weight/App.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs new file mode 100644 index 0000000..3e7521c --- /dev/null +++ b/DM_Weight/App.xaml.cs @@ -0,0 +1,278 @@ +using DM_Weight.Finger; +using DM_Weight.Port; +using DM_Weight.util.TabTip; +using DM_Weight.util; +using DM_Weight.ViewModels; +using DM_Weight.Views.Dialog; +using DM_Weight.Views; +using log4net.Config; +using Prism.Ioc; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Prism.Unity; +using log4net; +using System.Windows.Interop; +using System.Windows.Threading; +using System.Timers; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace DM_Weight +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : PrismApplication + { + private readonly ILog logger = LogManager.GetLogger(typeof(App)); + public App() + { + TabTipAutomation.IgnoreHardwareKeyboard = HardwareKeyboardIgnoreOptions.IgnoreAll; + TabTipAutomation.BindTo(); + TabTipAutomation.BindTo(); + } + + + + protected override Window CreateShell() + { + //UI线程未捕获异常处理事件 + this.DispatcherUnhandledException += OnDispatcherUnhandledException; + //Task线程内未捕获异常处理事件 + TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; + //多线程异常 + AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; + + return Container.Resolve(); + } + + void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) + { + logger.Error($"发生错误:{e.Exception.Message}"); + e.Handled = true; + } + + void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) + { + + foreach (Exception item in e.Exception.InnerExceptions) + { + logger.Error($"异常类型:{item.GetType()}{Environment.NewLine}来自:{item.Source}{Environment.NewLine}异常内容:{item.Message}"); + } + + //将异常标识为已经观察到 + e.SetObserved(); + } + + void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) + { + logger.Error($"Unhandled exception.{e.ToString()}"); + } + + + protected override void InitializeShell(Window shell) + { + + base.InitializeShell(shell); + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + // 注入日志 + XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); + //containerRegistry.RegisterInstance(LogManager.GetLogger("")); + + // 串口工具 + containerRegistry.RegisterSingleton(); + // 指纹机工具 + containerRegistry.RegisterSingleton(); + // 组态屏工具 + containerRegistry.RegisterSingleton(); + + containerRegistry.Register(); + + // 主窗口 + containerRegistry.Register(); + containerRegistry.RegisterForNavigation(); + + // 分页 + //containerRegistry.Register(); + //containerRegistry.Register(); + + // 登录页面 + containerRegistry.RegisterForNavigation(); + + // 布局页面 + containerRegistry.RegisterForNavigation(); + + // 录入指纹模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + + + #region 取药 + // 处方取药页面 + containerRegistry.RegisterForNavigation(); + // 处方取药模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 调拨取药页面 + containerRegistry.RegisterForNavigation(); + // 调拨取药模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 抽屉取药页面 + containerRegistry.RegisterForNavigation(); + // 自选取药模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 自选取药页面 + containerRegistry.RegisterForNavigation(); + + //多处方取药 + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + + #endregion + + #region 加药 + // 自选加药页面 + containerRegistry.RegisterForNavigation(); + // 调拨加药页面 + containerRegistry.RegisterForNavigation(); + + // 调拨取药模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 抽屉加药页面 + containerRegistry.RegisterForNavigation(); + // 自选加药模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + //多批次抽屉加药 + containerRegistry.RegisterForNavigation(); + #endregion + + #region 还药 + // 还药页面 + containerRegistry.RegisterForNavigation(); + // 按记录归还药品模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + + // 还药页面2 + containerRegistry.RegisterForNavigation(); + // 按处方归还药品模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 还空瓶页面 + containerRegistry.RegisterForNavigation(); + // 归还空瓶模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + #endregion + + #region 库存管理 + // 库存列表页面 + containerRegistry.RegisterForNavigation(); + // 库位绑定模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + //同一药品多批次库位绑定 + containerRegistry.RegisterForNavigation(); + // 库存盘点页面 + containerRegistry.RegisterForNavigation(); + // 药品列表页面 + containerRegistry.RegisterForNavigation(); + // 称重标定页面 + containerRegistry.RegisterForNavigation(); + + #endregion + + #region 系统设置 + // 用户管理页面 + containerRegistry.RegisterForNavigation(); + // 编辑用户模态框 + containerRegistry.RegisterDialog(); + containerRegistry.RegisterForNavigation(); + // 角色管理页面 + containerRegistry.RegisterForNavigation(); + // 系统设置 + containerRegistry.RegisterForNavigation(); + // 调试页面 + containerRegistry.RegisterForNavigation(); + + //主设置页面 + containerRegistry.RegisterForNavigation(); + //冰箱抽屉设置页面 + containerRegistry.RegisterForNavigation(); + #endregion + + // 设备记录页面 + containerRegistry.RegisterForNavigation(); + + containerRegistry.RegisterForNavigation(); + + } + private void PrismApplication_Startup(object sender, StartupEventArgs e) + { + //获取欲启动程序名 + string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; + //检查程序是否已经启动,已经启动则显示提示退出程序 + if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1) + { + //系统在运行 + RaiseOtherProcess(); + Application.Current.Shutdown(); + return; + } + } + private static void RaiseOtherProcess() + { + Process proc = Process.GetCurrentProcess(); + foreach (Process otherProc in Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName)) + { + if (proc.Id != otherProc.Id) + { + IntPtr hWnd = otherProc.MainWindowHandle; + if (IsIconic(hWnd)) + { + ShowWindowAsync(hWnd, 9); + } + SetForegroundWindow(hWnd); + break; + } + } + } + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr hWnd); + [DllImport("user32.dll")] + private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + [DllImport("user32.dll")] + private static extern bool IsIconic(IntPtr hWnd); + + private void PrismApplication_Startup_1(object sender, StartupEventArgs e) + { + //获取欲启动程序名 + string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; + //检查程序是否已经启动,已经启动则显示提示退出程序 + if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1) + { + //系统在运行 + RaiseOtherProcess(); + Application.Current.Shutdown(); + return; + } + } + } +} diff --git a/DM_Weight/AssemblyInfo.cs b/DM_Weight/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/DM_Weight/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/DM_Weight/Common/AddQuantityRule.cs b/DM_Weight/Common/AddQuantityRule.cs new file mode 100644 index 0000000..3e1535d --- /dev/null +++ b/DM_Weight/Common/AddQuantityRule.cs @@ -0,0 +1,35 @@ +using DM_Weight.Converter; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace DM_Weight.Common +{ + public class AddQuantityRule : ValidationRule + { + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + var addQuantity = value.ToString(); + if(string.IsNullOrEmpty(addQuantity)) { return new ValidationResult(false,"数量不能为空"); } + bool flag = int.TryParse(addQuantity,out int iAddQuantity); + string tips = string.Empty; + if(flag) + { + if(iAddQuantity<=0) + { + tips = "添加数量不能小于0"; + } + } + else + { + tips = "请输入正确数值"; + } + flag=tips.Length > 0?false:true; + return new ValidationResult(flag,tips); + } + } +} diff --git a/DM_Weight/Common/BoardTypeEnum.cs b/DM_Weight/Common/BoardTypeEnum.cs new file mode 100644 index 0000000..1a2ae46 --- /dev/null +++ b/DM_Weight/Common/BoardTypeEnum.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Common +{ + /// + /// + /// + public enum BoardTypeEnum + { + //物理隔断 + separation = 1, + //单支计数 + single = 2, + //管控药盒 + box = 3, + //储物箱 + storage = 4, + //智能显示 + smart = 5, + //称重计数 + weigh = 6, + //称重+管控药盒 + weighBox=63, + //称重+智能显示+管控药盒 + weighSmartBox = 653, + //冰箱抽屉 + fridge=7 + } + /// + /// 抽屉类型 + /// + public enum DrawerTypeEnum + { + //与BoardType同类型抽屉 + drawerTypeOne = 1, + //与BoardType同类型内置回收 + drawerTypeTwo = 2, + //回收箱抽屉 + recyle=3 + } +} diff --git a/DM_Weight/Common/CRC16MODBUS.cs b/DM_Weight/Common/CRC16MODBUS.cs new file mode 100644 index 0000000..6384cf7 --- /dev/null +++ b/DM_Weight/Common/CRC16MODBUS.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Common +{ + public class CRC16MODBUS + { + /// Name: CRC-16/MODBUS x16+x15+x2+1 + /// Poly: 0x8005 + /// Init: 0xFFFF + /// Refin: true + /// Refout: true + /// Xorout: 0x0000 + ///******************************添加数据CRC16MODBUS校验位******************************************* + public static byte[] CrcModBus(byte[] buffer, int start = 0, int len = 0) + { + if (buffer == null || buffer.Length == 0) return null; + if (start < 0) return null; + if (len == 0) len = buffer.Length - start; + int length = start + len; + if (length > buffer.Length) return null; + ushort crc = 0xFFFF;// Initial value + for (int i = start; i < length; i++) + { + crc ^= buffer[i]; + for (int j = 0; j < 8; j++) + { + if ((crc & 1) > 0) + crc = (ushort)((crc >> 1) ^ 0xA001);// 0xA001 = reverse 0x8005 + else + crc = (ushort)(crc >> 1); + } + } + byte[] ret = BitConverter.GetBytes(crc); + //Array.Reverse(ret); + return ret; + } + } +} diff --git a/DM_Weight/Common/CommonClass.cs b/DM_Weight/Common/CommonClass.cs new file mode 100644 index 0000000..daf7730 --- /dev/null +++ b/DM_Weight/Common/CommonClass.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace DM_Weight.Common +{ + public class CommonClass + { + //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题 + public static string ReadAppSetting(string key) + { + string xPath = "/configuration/appSettings//add[@key='" + key + "']"; + XmlDocument doc = new XmlDocument(); + string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; + doc.Load(exeFileName + ".dll.config"); + XmlNode node = doc.SelectSingleNode(xPath); + return node.Attributes["value"].Value; + } + public static void SaveAppSetting(string key,string value) + { + Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + _configuration.AppSettings.Settings[key].Value = value; + _configuration.Save(); + ConfigurationManager.RefreshSection(key); + } + } +} diff --git a/DM_Weight/Common/PrismManager.cs b/DM_Weight/Common/PrismManager.cs new file mode 100644 index 0000000..459848b --- /dev/null +++ b/DM_Weight/Common/PrismManager.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Common +{ + public class PrismManager + { + ///// + ///// 主页面区域,主要呈现登录页及登录后页面 + ///// + //public static readonly string MainViewRegionName = "MainContent"; + /// + /// 设置菜单页面跳转,主要呈现设置下子菜单 + /// + public static readonly string SettingViewRegionName = "SettingViewContent"; + ///// + ///// 主页面各菜单页 + ///// + //public static readonly string HomeViewRegionName = "HomeViewContent"; + } +} diff --git a/DM_Weight/Common/StaticClass.cs b/DM_Weight/Common/StaticClass.cs new file mode 100644 index 0000000..f9a9883 --- /dev/null +++ b/DM_Weight/Common/StaticClass.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.Common +{ + public class StaticClass + { + public static byte[] StrToHexByte(string hexString) + { + if (string.IsNullOrEmpty(hexString)) + { + return null; + } + hexString = hexString.Replace(" ", ""); + if ((hexString.Length % 2) != 0) hexString += " "; + byte[] returnBytes = new byte[hexString.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16); + return returnBytes; + } + } +} diff --git a/DM_Weight/Common/Temperature.cs b/DM_Weight/Common/Temperature.cs new file mode 100644 index 0000000..ca7a7dc --- /dev/null +++ b/DM_Weight/Common/Temperature.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DM_Weight.Port; +using log4net; + +namespace DM_Weight.Common +{ + public class Temperature + { + private readonly static ILog logger = LogManager.GetLogger(typeof(Temperature)); + /// + /// 将收到的返回转换成具体温度数值 + /// + /// + /// + public static string GetResultWD(string receiveData) + { + try + { + + string newStrWD = receiveData.Substring(10, 4); + + logger.Info($"截取后数据newStrWD:{newStrWD}"); + int iWD = Convert.ToInt32(newStrWD, 16); + logger.Info($"截取后数据iWD:{iWD}"); + float fWD = 0; + if (iWD != 0) + { + fWD = iWD * 1.0f / 10; + } + + logger.Info($"截取后数据fWD:{fWD}"); + string strRet = $"冰箱抽屉当前温度:{fWD}℃;"; + + return strRet; + } + catch (Exception ex) + { + logger.Info("GetResultWD异常", new Exception($"{ex.ToString()}")); + } + return "数据异常"; + } + } +} diff --git a/DM_Weight/Common/TemperatureRangeRule.cs b/DM_Weight/Common/TemperatureRangeRule.cs new file mode 100644 index 0000000..1ebe4bd --- /dev/null +++ b/DM_Weight/Common/TemperatureRangeRule.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; + +namespace DM_Weight.Common +{ + //设置冰箱温度规则 + public class TemperatureRangeRule : ValidationRule + { + //冰箱温度设置区间为取自配置文件(2~8度) + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + bool flag = false; + string tips = string.Empty; + try + { + string[] rang = value.ToString().Split('-'); + if (rang.Length >= 2) + { + bool bSRange = int.TryParse(rang[0], out int sRange); + bool bERange = int.TryParse(rang[1], out int eRange); + if (bSRange && bERange) + { + if (sRange < 2 || eRange > 8) + { + tips = "温度区间设置2-8度,请检查输入"; + return new ValidationResult(flag, tips); + } + else + { + flag = true; + } + } + else + { + tips = "请输入正确的数值"; + return new ValidationResult(flag, tips); + } + + } + else + { + tips = "请输入正确的数值"; + return new ValidationResult(flag, tips); + } + return new ValidationResult(flag, tips); + } + catch (Exception ex) + { + tips = $"校验异常{ex.ToString()}"; + return new ValidationResult(flag, tips); + } + } + } +} diff --git a/DM_Weight/Common/TemperatureRule.cs b/DM_Weight/Common/TemperatureRule.cs new file mode 100644 index 0000000..f606a65 --- /dev/null +++ b/DM_Weight/Common/TemperatureRule.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; + +namespace DM_Weight.Common +{ + //设置冰箱温度规则 + public class TemperatureRule : ValidationRule + { + //冰箱温度设置区间为取自配置文件(2~8度) + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + bool flag = false; + string tips = string.Empty; + try + { + bool bValue = decimal.TryParse(value.ToString(), out decimal mValue); + if (!bValue) + { + tips = "请输入正确的数值"; + return new ValidationResult(flag, tips); + } + + decimal f = Math.Abs(mValue - (int)mValue); + if (f.ToString().Length > 3) + { + tips = "温度区间设置保留小数点后一位,请检查输入"; + return new ValidationResult(flag, tips); + } + string[] temperatureRange = CommonClass.ReadAppSetting("temperatureRange").Split('-'); + if (temperatureRange.Length > 0) + { + int iMin = int.Parse(temperatureRange[0]); + int iMax = int.Parse(temperatureRange[1]); + if (mValue < iMin || mValue > iMax) + { + tips = $"温度区间设置为{iMin}~{iMax}度,保留小数点后一位,请检查输入"; + } + else + { + flag = true; + } + } + return new ValidationResult(flag, tips); + } + catch (Exception ex) + { + tips = $"校验异常{ex.ToString()}"; + return new ValidationResult(flag, tips); + } + } + } +} diff --git a/DM_Weight/Components/pagination/Pagination.xaml b/DM_Weight/Components/pagination/Pagination.xaml new file mode 100644 index 0000000..8b3eee6 --- /dev/null +++ b/DM_Weight/Components/pagination/Pagination.xaml @@ -0,0 +1,43 @@ + + + + + + +