Merge pull request 'dev' (#8) from dev into master

Reviewed-on: #8
master
wenjy 3 weeks ago
commit 6cace85647

@ -1,6 +1,9 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
@ -58,6 +61,27 @@ namespace SlnMesnac.Config
/// </summary>
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;
}
}

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

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

@ -37,8 +37,8 @@
<ItemGroup>
<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="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
</ItemGroup>

@ -1,6 +1,5 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HslCommunication.LogNet;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.Dialogs;
using SlnMesnac.Config;
@ -10,7 +9,6 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Windows;
@ -38,7 +36,7 @@ using System.Windows;
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel.Generate
{
internal class GenerateControlViewModel : ViewModelBase
internal partial class GenerateControlViewModel : ObservableObject
{
private readonly AppConfig _appConfig;
@ -60,55 +58,40 @@ namespace SlnMesnac.WPF.ViewModel.Generate
Options.Add(configId);
}
QuerySearchCommand = new RelayCommand<string>(Query);
CreateCodeCommand = new RelayCommand<string>(CreateCode);
}
#region 参数定义
private ObservableCollection<string> _options;
public ObservableCollection<string> Options
{
get { return _options; }
set
{
_options = value;
RaisePropertyChanged(nameof(Options));
}
get => _options;
set => SetProperty(ref _options, value);
}
private string _selectedOption;
public string SelectedOption
{
get { return _selectedOption; }
set
{
_selectedOption = value;
RaisePropertyChanged(nameof(SelectedOption));
}
get => _selectedOption;
set => SetProperty(ref _selectedOption, value);
}
private ObservableCollection<DbTableInfo> tablesDataGrid;
public ObservableCollection<DbTableInfo> TablesDataGrid
{
get { return tablesDataGrid; }
set { tablesDataGrid = value; RaisePropertyChanged(() => TablesDataGrid); }
get => tablesDataGrid;
set => SetProperty(ref tablesDataGrid, value);
}
#endregion
#region 事件定义
public RelayCommand<string> QuerySearchCommand { get; set; }
public RelayCommand<string> CreateCodeCommand { get;set; }
#endregion
/// <summary>
/// 查询事件
/// </summary>
/// <param name="search"></param>
private void Query(string search)
[RelayCommand]
private void QuerySearch(string search)
{
var configId = _selectedOption;
@ -129,6 +112,7 @@ namespace SlnMesnac.WPF.ViewModel.Generate
}
[RelayCommand]
private void CreateCode(string 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.Logging;
using SlnMesnac.Serilog;
using SlnMesnac.WPF.Page.Generate;
using System;
@ -9,7 +9,7 @@ using System.Windows;
namespace SlnMesnac.WPF.ViewModel
{
public class MainWindowViewModel: ViewModelBase
public partial class MainWindowViewModel: ObservableObject
{
public readonly SerilogHelper _logger;
@ -23,8 +23,8 @@ namespace SlnMesnac.WPF.ViewModel
private int _PlcStatus = 0;
public int PlcStatus
{
get { return _PlcStatus; }
set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); }
get => _PlcStatus;
set => SetProperty(ref _PlcStatus, value);
}
/// <summary>
/// 箱壳扫码器状态
@ -32,8 +32,8 @@ namespace SlnMesnac.WPF.ViewModel
private int _ShellScannerStatus = 0;
public int ShellScannerStatus
{
get { return _ShellScannerStatus; }
set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); }
get => _ShellScannerStatus;
set => SetProperty(ref _ShellScannerStatus, value);
}
/// <summary>
@ -42,39 +42,25 @@ namespace SlnMesnac.WPF.ViewModel
private int _BoldScannerStatus = 0;
public int BoldScannerStatus
{
get { return _BoldScannerStatus; }
set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); }
get => _BoldScannerStatus;
set => SetProperty(ref _BoldScannerStatus, value);
}
public System.Windows.Controls.UserControl _content;
public System.Windows.Controls.UserControl UserContent
{
get { return _content; }
set
{
_content = value;
RaisePropertyChanged(nameof(UserContent));
}
get => _content;
set => SetProperty(ref _content, value);
}
#endregion
#region 事件定义
/// <summary>
/// 界面跳转按钮事件
/// </summary>
public RelayCommand<object> ControlOnClickCommand { get; set; }
/// <summary>
/// 打开系统键盘
/// </summary>
public RelayCommand OpenSystemKeyboardCommand { get; set; }
/// <summary>
/// 窗体控制
/// </summary>
public RelayCommand<object> FormControlCommand { get; set; }
#endregion
public MainWindowViewModel()
@ -82,8 +68,6 @@ namespace SlnMesnac.WPF.ViewModel
_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>
/// <param name="obj"></param>
[RelayCommand]
private void FormControl(object obj)
{
try
@ -137,6 +122,7 @@ namespace SlnMesnac.WPF.ViewModel
/// <summary>
/// 界面跳转
/// </summary>
[RelayCommand]
private void ControlOnClick(object obj)
{
try

Loading…
Cancel
Save