Compare commits

...

3 Commits

@ -1,6 +1,9 @@
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Xml;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
@ -58,6 +61,27 @@ namespace SlnMesnac.Config
/// </summary> /// </summary>
public string redisConfig { get; set; } public string redisConfig { get; set; }
/// <summary>
/// 修改配置文件
/// </summary>
/// <param name="appConfig"></param>
public void SetValue(AppConfig appConfig)
{
var jsonObject = JsonConvert.SerializeObject(new
{
AppConfig = new
{
logPath = appConfig.logPath,
SqlConfig = appConfig.sqlConfig,
PlcConfig = appConfig.plcConfig,
RfidConfig = appConfig.rfidConfig,
RedisConfig = appConfig.redisConfig,
}
}, Newtonsoft.Json.Formatting.Indented);
var appSettingsPath = Path.Combine(AppContext.BaseDirectory, "appsettings.json");
File.WriteAllText(appSettingsPath, jsonObject);
}
public AppConfig Value => this; public AppConfig Value => this;
} }
} }

@ -7,6 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,5 +1,6 @@
using Autofac; using Autofac;
using SlnMesnac.Repository; using SlnMesnac.Repository;
using SlnMesnac.Serilog;
using System.Reflection; using System.Reflection;
using TouchSocket.Sockets; using TouchSocket.Sockets;
@ -63,6 +64,9 @@ namespace SlnMesnac.Ioc
//注入代码生成 //注入代码生成
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Generate.dll")); RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Generate.dll"));
//注入Serilog日志帮助类
builder.RegisterType(typeof(SerilogHelper)).SingleInstance();
} }

@ -37,8 +37,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" /> <PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="NVelocity" Version="1.2.0" /> <PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" /> <PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
</ItemGroup> </ItemGroup>

@ -1,6 +1,5 @@
using GalaSoft.MvvmLight; using CommunityToolkit.Mvvm.ComponentModel;
using GalaSoft.MvvmLight.Command; using CommunityToolkit.Mvvm.Input;
using HslCommunication.LogNet;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using SlnMesnac.Config; using SlnMesnac.Config;
@ -10,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data; using System.Data;
using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
@ -38,7 +36,7 @@ using System.Windows;
#endregion << 版 本 注 释 >> #endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel.Generate namespace SlnMesnac.WPF.ViewModel.Generate
{ {
internal class GenerateControlViewModel : ViewModelBase internal partial class GenerateControlViewModel : ObservableObject
{ {
private readonly AppConfig _appConfig; private readonly AppConfig _appConfig;
@ -60,55 +58,40 @@ namespace SlnMesnac.WPF.ViewModel.Generate
Options.Add(configId); Options.Add(configId);
} }
QuerySearchCommand = new RelayCommand<string>(Query);
CreateCodeCommand = new RelayCommand<string>(CreateCode);
} }
#region 参数定义 #region 参数定义
private ObservableCollection<string> _options; private ObservableCollection<string> _options;
public ObservableCollection<string> Options public ObservableCollection<string> Options
{ {
get { return _options; } get => _options;
set set => SetProperty(ref _options, value);
{
_options = value;
RaisePropertyChanged(nameof(Options));
}
} }
private string _selectedOption; private string _selectedOption;
public string SelectedOption public string SelectedOption
{ {
get { return _selectedOption; } get => _selectedOption;
set set => SetProperty(ref _selectedOption, value);
{
_selectedOption = value;
RaisePropertyChanged(nameof(SelectedOption));
}
} }
private ObservableCollection<DbTableInfo> tablesDataGrid; private ObservableCollection<DbTableInfo> tablesDataGrid;
public ObservableCollection<DbTableInfo> TablesDataGrid public ObservableCollection<DbTableInfo> TablesDataGrid
{ {
get { return tablesDataGrid; } get => tablesDataGrid;
set { tablesDataGrid = value; RaisePropertyChanged(() => TablesDataGrid); } set => SetProperty(ref tablesDataGrid, value);
} }
#endregion #endregion
#region 事件定义
public RelayCommand<string> QuerySearchCommand { get; set; }
public RelayCommand<string> CreateCodeCommand { get;set; }
#endregion
/// <summary> /// <summary>
/// 查询事件 /// 查询事件
/// </summary> /// </summary>
/// <param name="search"></param> /// <param name="search"></param>
private void Query(string search) [RelayCommand]
private void QuerySearch(string search)
{ {
var configId = _selectedOption; var configId = _selectedOption;
@ -129,6 +112,7 @@ namespace SlnMesnac.WPF.ViewModel.Generate
} }
[RelayCommand]
private void CreateCode(string tableName) private void CreateCode(string tableName)
{ {
var info = tableName; var info = tableName;

@ -1,7 +1,7 @@
using GalaSoft.MvvmLight; 
using GalaSoft.MvvmLight.Command; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.Serilog; using SlnMesnac.Serilog;
using SlnMesnac.WPF.Page.Generate; using SlnMesnac.WPF.Page.Generate;
using System; using System;
@ -9,7 +9,7 @@ using System.Windows;
namespace SlnMesnac.WPF.ViewModel namespace SlnMesnac.WPF.ViewModel
{ {
public class MainWindowViewModel: ViewModelBase public partial class MainWindowViewModel: ObservableObject
{ {
public readonly SerilogHelper _logger; public readonly SerilogHelper _logger;
@ -23,8 +23,8 @@ namespace SlnMesnac.WPF.ViewModel
private int _PlcStatus = 0; private int _PlcStatus = 0;
public int PlcStatus public int PlcStatus
{ {
get { return _PlcStatus; } get => _PlcStatus;
set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); } set => SetProperty(ref _PlcStatus, value);
} }
/// <summary> /// <summary>
/// 箱壳扫码器状态 /// 箱壳扫码器状态
@ -32,8 +32,8 @@ namespace SlnMesnac.WPF.ViewModel
private int _ShellScannerStatus = 0; private int _ShellScannerStatus = 0;
public int ShellScannerStatus public int ShellScannerStatus
{ {
get { return _ShellScannerStatus; } get => _ShellScannerStatus;
set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); } set => SetProperty(ref _ShellScannerStatus, value);
} }
/// <summary> /// <summary>
@ -42,39 +42,25 @@ namespace SlnMesnac.WPF.ViewModel
private int _BoldScannerStatus = 0; private int _BoldScannerStatus = 0;
public int BoldScannerStatus public int BoldScannerStatus
{ {
get { return _BoldScannerStatus; } get => _BoldScannerStatus;
set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); } set => SetProperty(ref _BoldScannerStatus, value);
} }
public System.Windows.Controls.UserControl _content; public System.Windows.Controls.UserControl _content;
public System.Windows.Controls.UserControl UserContent public System.Windows.Controls.UserControl UserContent
{ {
get { return _content; } get => _content;
set => SetProperty(ref _content, value);
set
{
_content = value;
RaisePropertyChanged(nameof(UserContent));
}
} }
#endregion #endregion
#region 事件定义 #region 事件定义
/// <summary>
/// 界面跳转按钮事件
/// </summary>
public RelayCommand<object> ControlOnClickCommand { get; set; }
/// <summary> /// <summary>
/// 打开系统键盘 /// 打开系统键盘
/// </summary> /// </summary>
public RelayCommand OpenSystemKeyboardCommand { get; set; } public RelayCommand OpenSystemKeyboardCommand { get; set; }
/// <summary>
/// 窗体控制
/// </summary>
public RelayCommand<object> FormControlCommand { get; set; }
#endregion #endregion
public MainWindowViewModel() public MainWindowViewModel()
@ -82,8 +68,6 @@ namespace SlnMesnac.WPF.ViewModel
_logger = App.ServiceProvider.GetService<SerilogHelper>(); _logger = App.ServiceProvider.GetService<SerilogHelper>();
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x));
} }
@ -91,6 +75,7 @@ namespace SlnMesnac.WPF.ViewModel
/// 窗体控制 /// 窗体控制
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj"></param>
[RelayCommand]
private void FormControl(object obj) private void FormControl(object obj)
{ {
try try
@ -137,6 +122,7 @@ namespace SlnMesnac.WPF.ViewModel
/// <summary> /// <summary>
/// 界面跳转 /// 界面跳转
/// </summary> /// </summary>
[RelayCommand]
private void ControlOnClick(object obj) private void ControlOnClick(object obj)
{ {
try try

Loading…
Cancel
Save