Selaa lähdekoodia

1. 添加日志功能以及日志的查询显示。

master
Nah 1 vuosi sitten
vanhempi
commit
4a462c78ae
39 muutettua tiedostoa jossa 1409 lisäystä ja 15 poistoa
  1. +1
    -1
      BPA.Model/Enums/DeviceType.cs
  2. +33
    -0
      BPA.Model/LogBase.cs
  3. +29
    -0
      BPA.Model/Table/AlarmLogTB.cs
  4. +22
    -0
      BPA.Model/Table/DebugLogTB.cs
  5. +22
    -0
      BPA.Model/Table/RecipeCompleteLogTB.cs
  6. +22
    -0
      BPA.Model/Table/RunLogTB.cs
  7. +32
    -0
      BPA.Model/Table/UserLogTB.cs
  8. +43
    -0
      BPA.SingleDevice/App.xaml.cs
  9. +4
    -0
      BPA.SingleDevice/BPA.SingleDevice.csproj
  10. +1
    -1
      BPA.SingleDevice/Business/DeviceAbs.cs
  11. +1
    -1
      BPA.SingleDevice/Business/MainControl.cs
  12. +1
    -0
      BPA.SingleDevice/GlobalUsing.cs
  13. +1
    -1
      BPA.SingleDevice/Interface/IDeviceAbs.cs
  14. +26
    -0
      BPA.SingleDevice/Services/ILogService.cs
  15. +145
    -0
      BPA.SingleDevice/Services/LogService.cs
  16. +81
    -0
      BPA.SingleDevice/View/AlarmLogView.xaml
  17. +30
    -0
      BPA.SingleDevice/View/AlarmLogView.xaml.cs
  18. +104
    -0
      BPA.SingleDevice/View/DebugLogView.xaml
  19. +30
    -0
      BPA.SingleDevice/View/DebugLogView.xaml.cs
  20. +1
    -0
      BPA.SingleDevice/View/MainView.xaml
  21. +4
    -2
      BPA.SingleDevice/View/OrderMainView.xaml
  22. +12
    -0
      BPA.SingleDevice/View/ParamsSetView.xaml
  23. +30
    -0
      BPA.SingleDevice/View/ParamsSetView.xaml.cs
  24. +10
    -5
      BPA.SingleDevice/View/RawMaterialManagementView.xaml
  25. +104
    -0
      BPA.SingleDevice/View/RecipeCompletView.xaml
  26. +30
    -0
      BPA.SingleDevice/View/RecipeCompletView.xaml.cs
  27. +5
    -0
      BPA.SingleDevice/View/RecipeManagementView.xaml
  28. +105
    -0
      BPA.SingleDevice/View/RunLogView.xaml
  29. +30
    -0
      BPA.SingleDevice/View/RunLogView.xaml.cs
  30. +110
    -0
      BPA.SingleDevice/View/UserLogView.xaml
  31. +30
    -0
      BPA.SingleDevice/View/UserLogView.xaml.cs
  32. +42
    -0
      BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs
  33. +61
    -0
      BPA.SingleDevice/ViewModel/DebugLogViewModel.cs
  34. +8
    -2
      BPA.SingleDevice/ViewModel/MainViewModel.cs
  35. +12
    -0
      BPA.SingleDevice/ViewModel/ParamsSetViewModel.cs
  36. +61
    -0
      BPA.SingleDevice/ViewModel/RecipeCompleteViewModel.cs
  37. +63
    -0
      BPA.SingleDevice/ViewModel/RunLogViewModel.cs
  38. +61
    -0
      BPA.SingleDevice/ViewModel/UserLogViewModel.cs
  39. +2
    -2
      BPA.UIControl/Themes/ScrollBar.xaml

BPA.Model/DeviceType.cs → BPA.Model/Enums/DeviceType.cs Näytä tiedosto

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model
namespace BPA.Model.Enums
{
public enum EDeviceType : int
{

+ 33
- 0
BPA.Model/LogBase.cs Näytä tiedosto

@@ -0,0 +1,33 @@
using BPA.Helper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model
{
public class LogBase:NotifyBase
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true,IsIdentity =true)]//设置主键
public int ID { get { return _Id; } set { _Id = value; OnPropertyChanged(); } }
private int _Id;

/// <summary>
/// 日期
/// </summary>
public string Date { get { return _mDate; } set { _mDate = value; OnPropertyChanged(); } }
private string _mDate;

/// <summary>
/// 时间
/// </summary>
public string Time { get { return _mTime; } set { _mTime = value; OnPropertyChanged(); } }
private string _mTime;

}
}

+ 29
- 0
BPA.Model/Table/AlarmLogTB.cs Näytä tiedosto

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Table
{
public class AlarmLogTB:LogBase
{
/// <summary>
/// 报警信息
/// </summary>
public string Info { get { return _mInfo; } set { _mInfo = value; OnPropertyChanged(); } }
private string _mInfo;

/// <summary>
/// 报警值
/// </summary>
public string Value { get { return _mValue; } set { _mValue = value; OnPropertyChanged(); } }
private string _mValue;

/// <summary>
/// 报警等级
/// </summary>
public string Grade { get { return _mGrade; } set { _mGrade = value; OnPropertyChanged(); } }
private string _mGrade;
}
}

+ 22
- 0
BPA.Model/Table/DebugLogTB.cs Näytä tiedosto

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Table
{
public class DebugLogTB:LogBase
{
private string _DebugInfo;
/// <summary>
/// 调试信息。
/// </summary>
public string DebugInfo
{
get { return _DebugInfo; }
set { _DebugInfo = value; OnPropertyChanged(); }
}

}
}

+ 22
- 0
BPA.Model/Table/RecipeCompleteLogTB.cs Näytä tiedosto

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Table
{
public class RecipeCompleteLogTB:LogBase
{
private string _RecipeName;
/// <summary>
/// 配方名称。
/// </summary>
public string RecipeName
{
get { return _RecipeName; }
set { _RecipeName = value; OnPropertyChanged(); }
}

}
}

+ 22
- 0
BPA.Model/Table/RunLogTB.cs Näytä tiedosto

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Table
{
public class RunLogTB:LogBase
{
private string _RunLogInfo;
/// <summary>
/// 运行日志信息
/// </summary>
public string RunLogInfo
{
get { return _RunLogInfo; }
set { _RunLogInfo = value; OnPropertyChanged(); }
}

}
}

+ 32
- 0
BPA.Model/Table/UserLogTB.cs Näytä tiedosto

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Table
{
public class UserLogTB:LogBase
{

private string _UserName;

public string UserName
{
get { return _UserName; }
set { _UserName = value; OnPropertyChanged(); }
}


private string _UserLogInfo;
/// <summary>
/// 用户操作日志信息
/// </summary>
public string UserLogInfo
{
get { return _UserLogInfo; }
set { _UserLogInfo = value;OnPropertyChanged(); }
}

}
}

+ 43
- 0
BPA.SingleDevice/App.xaml.cs Näytä tiedosto

@@ -1,11 +1,15 @@
using BPA.SingleDevice.Business;
using BPA.SingleDevice.Helper;
using BPA.SingleDevice.Interface;
using BPA.SingleDevice.Services;
using BPA.SingleDevice.View;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

@@ -16,8 +20,27 @@ namespace BPA.SingleDevice
/// </summary>
public partial class App : Application
{

public App()
{
Services = ConfigurServices();
}

public new static App Current => (App)Application.Current;

public IServiceProvider Services { get; }
public EventWaitHandle ProgramStarted { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
bool createNew;
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "SingleDevice", out createNew);
if (!createNew)
{
MessageBox.Show("程序已启动!");
App.Current.Shutdown();
Environment.Exit(0);
}

base.OnStartup(e);
SqlHelper.GetInstance.Init();
MainControl.GetInstance.Start();
@@ -30,5 +53,25 @@ namespace BPA.SingleDevice
base.OnExit(e);
MainControl.GetInstance.Stop();
}

private static IServiceProvider ConfigurServices()
{
var services = new ServiceCollection();

//services.AddSingleton<ISqlHelper, SqlHelper>();
services.AddSingleton<ILogService, LogService>();

services.AddSingleton<ParamsSetViewModel>();
services.AddSingleton<RunLogViewModel>();
services.AddSingleton<AlarmLogViewModel>();
services.AddSingleton<RecipeCompleteViewModel>();
services.AddSingleton<UserLogViewModel>();
services.AddSingleton<DebugLogViewModel>();



return services.BuildServiceProvider();
}
}
}

+ 4
- 0
BPA.SingleDevice/BPA.SingleDevice.csproj Näytä tiedosto

@@ -11,6 +11,10 @@
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPA.Model\BPA.Model.csproj" />
</ItemGroup>


+ 1
- 1
BPA.SingleDevice/Business/DeviceAbs.cs Näytä tiedosto

@@ -6,9 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPA.Helper;
using BPA.Model;
using BPA.SingleDevice.Helper;
using System.Threading;
using BPA.Model.Enums;

namespace BPA.SingleDevice.Business
{


+ 1
- 1
BPA.SingleDevice/Business/MainControl.cs Näytä tiedosto

@@ -6,10 +6,10 @@ using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using BPA.Communication;
using BPA.Model;
using BPA.Helper;
using System.Threading;
using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments;
using BPA.Model.Enums;

namespace BPA.SingleDevice.Business
{


+ 1
- 0
BPA.SingleDevice/GlobalUsing.cs Näytä tiedosto

@@ -16,4 +16,5 @@ global using BPA.SingleDevice.View;
global using BPA.SingleDevice.ViewModel;
global using BPA.UIControl.Enums;
global using BPA.UIControl.Commons;
using Microsoft.Extensions.DependencyInjection;


+ 1
- 1
BPA.SingleDevice/Interface/IDeviceAbs.cs Näytä tiedosto

@@ -1,4 +1,4 @@
using BPA.Model;
using BPA.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;


+ 26
- 0
BPA.SingleDevice/Services/ILogService.cs Näytä tiedosto

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Services
{
public interface ILogService
{

ObservableCollection<RunLogTB> RunLogs { get; set; }
ObservableCollection<UserLogTB> UserLogs { get; set; }
ObservableCollection<RecipeCompleteLogTB> RecipeCompleteLogs { get; set; }
ObservableCollection<AlarmLogTB> AlarmLogs { get; set; }
ObservableCollection<DebugLogTB> DebugLogs { get; set; }

void LogAlarmInfo(string info);
void LogUserInfo(string info, string userName = "");
void LogRunInfo(string info);
void LogRecipeCompleteInfo(string info);
void LogDebugInfo(string info);

Task<List<T>> GetAllLog<T>();
}
}

+ 145
- 0
BPA.SingleDevice/Services/LogService.cs Näytä tiedosto

@@ -0,0 +1,145 @@
using BPA.Helper.Log.DB;
using BPA.SingleDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Services
{
public class LogService :ILogService
{
private readonly ISqlHelper sqlHelper;

static readonly object runLock = new object();
static readonly object userlock = new object();
static readonly object alarmlock = new object();
static readonly object recipeLogslock = new object();
static readonly object debugLock = new object();


public ObservableCollection<RunLogTB> RunLogs { get; set; } = new();
public ObservableCollection<UserLogTB> UserLogs { get; set; } = new();
public ObservableCollection<RecipeCompleteLogTB> RecipeCompleteLogs { get; set; } = new();
public ObservableCollection<AlarmLogTB> AlarmLogs { get; set; } = new();
public ObservableCollection<DebugLogTB> DebugLogs { get; set; } = new();

public LogService()
{
this.sqlHelper = SqlHelper.GetInstance;
}

public void LogAlarmInfo(string info)
{
throw new NotImplementedException();
}

public void LogDebugInfo(string info)
{
lock (debugLock)
{
try
{
DebugLogTB log = new()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
DebugInfo = info
};

sqlHelper.AddAsync(log);
App.Current.Dispatcher.Invoke(() => { DebugLogs.Insert(0, log); });
}
catch (Exception)
{

// throw;
}
}
}

public void LogRecipeCompleteInfo(string info)
{
lock (recipeLogslock)
{
try
{
RecipeCompleteLogTB log = new()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
RecipeName = info
};

sqlHelper.AddAsync(log);
App.Current.Dispatcher.Invoke(() => { RecipeCompleteLogs.Insert(0, log); });
}
catch (Exception)
{

// throw;
}
}
}

public void LogRunInfo(string info)
{
lock (runLock)
{
try
{
RunLogTB runLog = new ()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
RunLogInfo = info
};

sqlHelper.AddAsync(runLog);
App.Current.Dispatcher.Invoke(() => { RunLogs.Insert(0, runLog); });
}
catch (Exception)
{

// throw;
}
}
}

public void LogUserInfo(string info, string userName = "")
{
lock (userlock)
{
try
{
UserLogTB log = new()
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
UserName= userName,
UserLogInfo = info
};

sqlHelper.AddAsync(log);
App.Current.Dispatcher.Invoke(() => { UserLogs.Insert(0, log); });
}
catch (Exception)
{

// throw;
}
}
}

public async Task<List<T>> GetAllLog<T>()
{
var logs= await sqlHelper.GetListAsync<T>();
if (logs.IsSuccess)
{
return logs.Content;
}
return null;
}
}
}

+ 81
- 0
BPA.SingleDevice/View/AlarmLogView.xaml Näytä tiedosto

@@ -0,0 +1,81 @@
<UserControl x:Class="BPA.SingleDevice.View.AlarmLogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<bpa:DialogContainer>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 功能按钮-->
<StackPanel
Grid.Row="0"
Margin="10"
HorizontalAlignment="Right"
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">
<ToggleButton
HorizontalAlignment="Right" FontSize="25"
Content="实时日志" IsChecked="{Binding IsShowHistory}"
Command="{Binding ViewHistoryCommand}"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

<!--#endregion-->

<!--#region 列表-->
<bpa:ControlDisplay Grid.Row="1">
<DataGrid
Grid.Row="1"
AutoGenerateColumns="False"
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding AlarmLogs}"
RowHeight="50"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}" FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}" FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="120"
Binding="{Binding Grade}" FontSize="16"
Header="报警等级" />
<DataGridTextColumn
Width="180"
Binding="{Binding Value}" FontSize="16"
Header="报警值" />
<DataGridTextColumn
Width="*"
Binding="{Binding Info}" FontSize="16"
Header="报警信息" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/AlarmLogView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// AlarmLogView.xaml 的交互逻辑
/// </summary>
public partial class AlarmLogView : UserControl
{
public AlarmLogView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<AlarmLogViewModel>();
}
}
}

+ 104
- 0
BPA.SingleDevice/View/DebugLogView.xaml Näytä tiedosto

@@ -0,0 +1,104 @@
<UserControl x:Class="BPA.SingleDevice.View.DebugLogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<bpa:DialogContainer>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 功能按钮-->
<StackPanel
Grid.Row="0"
Margin="10"
HorizontalAlignment="Right"
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">

<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}">
<TextBlock Margin="5,0" Text="开始日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding StartTime}"
SelectedDateFormat="Short" />
<TextBlock Margin="5,0" Text="结束日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding EndTime}" />

<Button
Margin="10,0"
Command="{Binding GetHistoryCommand}"
Content="查询历史日志" />
</StackPanel>
<ToggleButton
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

<!--#endregion-->

<!--#region 列表-->
<bpa:ControlDisplay Grid.Row="1">
<DataGrid
Grid.Row="1"
AutoGenerateColumns="False"
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
RowHeight="50"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}"
FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}"
FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="*"
Binding="{Binding DebugInfo}"
FontSize="16"
Header="日志信息" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/DebugLogView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// DebugLogView.xaml 的交互逻辑
/// </summary>
public partial class DebugLogView : UserControl
{
public DebugLogView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<DebugLogViewModel>();
}
}
}

+ 1
- 0
BPA.SingleDevice/View/MainView.xaml Näytä tiedosto

@@ -14,6 +14,7 @@
TitleBackground="#2d2d2d"
TitleHeight="40"
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
mc:Ignorable="d">

<bpa:BPAWindow.DataContext>


+ 4
- 2
BPA.SingleDevice/View/OrderMainView.xaml Näytä tiedosto

@@ -18,11 +18,12 @@
<Grid Margin="10">
<ListView
VerticalAlignment="Top"
bpa:ItemsControlHelper.ItemPadding="8 0 0 0"
bpa:ItemsControlHelper.ItemPadding="8 5 8 8"
ItemsSource="{Binding Goods}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="5" />
<!--<UniformGrid Columns="5" />-->
<WrapPanel/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
@@ -34,6 +35,7 @@
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<!--图片-->
<Border Width="120" Background="Gray" />
<TextBlock
Grid.Row="1"


+ 12
- 0
BPA.SingleDevice/View/ParamsSetView.xaml Näytä tiedosto

@@ -0,0 +1,12 @@
<UserControl x:Class="BPA.SingleDevice.View.ParamsSetView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/ParamsSetView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// ParamsSetView.xaml 的交互逻辑
/// </summary>
public partial class ParamsSetView : UserControl
{
public ParamsSetView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<ParamsSetViewModel>();
}
}
}

+ 10
- 5
BPA.SingleDevice/View/RawMaterialManagementView.xaml Näytä tiedosto

@@ -33,6 +33,7 @@
HorizontalAlignment="Right"
Command="{Binding AddCommand}"
Content="添加原料"
Width="100"
Style="{DynamicResource DarkButton}" />

<!--<Button
@@ -52,10 +53,14 @@
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding RawMaterInfos}"
RowHeight="35"
RowHeight="50"
SelectionMode="Single">
<!--<DataGrid.RowHeaderTemplate>
<DataTemplate>
@@ -81,27 +86,27 @@
Width="180"
Binding="{Binding LastModified}"
Header="最后修改时间" />
<DataGridTemplateColumn Width="150" Header="操作">
<DataGridTemplateColumn Width="300" Header="操作">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}"
Foreground="#2196F3"
Foreground="#2196F3" Width="100"
Style="{StaticResource TextButton}">
<bpa:Icon Type="Edit2Fill" />
</Button>
<Button
Command="{Binding DataContext.CopyCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}"
Foreground="#2196F3"
Foreground="#2196F3" Width="100"
Style="{StaticResource TextButton}">
<bpa:Icon Type="CopyleftFill" />
</Button>
<Button
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=local:RawMaterialManagementView}}"
CommandParameter="{Binding Id}"
CommandParameter="{Binding Id}" Width="100"
Style="{StaticResource TextErrorButton}">
<bpa:Icon Type="DeleteBinFill" />
</Button>


+ 104
- 0
BPA.SingleDevice/View/RecipeCompletView.xaml Näytä tiedosto

@@ -0,0 +1,104 @@
<UserControl x:Class="BPA.SingleDevice.View.RecipeCompletView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<bpa:DialogContainer>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 功能按钮-->
<StackPanel
Grid.Row="0"
Margin="10"
HorizontalAlignment="Right"
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">

<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}">
<TextBlock Margin="5,0" Text="开始日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding StartTime}"
SelectedDateFormat="Short" />
<TextBlock Margin="5,0" Text="结束日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding EndTime}" />

<Button
Margin="10,0"
Command="{Binding GetHistoryCommand}"
Content="查询历史日志" />
</StackPanel>
<ToggleButton
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

<!--#endregion-->

<!--#region 列表-->
<bpa:ControlDisplay Grid.Row="1">
<DataGrid
Grid.Row="1"
AutoGenerateColumns="False"
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
RowHeight="50"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}"
FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}"
FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="*"
Binding="{Binding RecipeName}"
FontSize="16"
Header="配方名称" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/RecipeCompletView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// RecipeCompletView.xaml 的交互逻辑
/// </summary>
public partial class RecipeCompletView : UserControl
{
public RecipeCompletView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<RecipeCompleteViewModel>();
}
}
}

+ 5
- 0
BPA.SingleDevice/View/RecipeManagementView.xaml Näytä tiedosto

@@ -46,6 +46,11 @@
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="False"
ItemsSource="{Binding RecipeInfos}"


+ 105
- 0
BPA.SingleDevice/View/RunLogView.xaml Näytä tiedosto

@@ -0,0 +1,105 @@
<UserControl
x:Class="BPA.SingleDevice.View.RunLogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<bpa:DialogContainer>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 功能按钮-->
<StackPanel
Grid.Row="0"
Margin="10"
HorizontalAlignment="Right"
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">

<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked,Converter={StaticResource BooleanToVisibleConverter}}">
<TextBlock Margin="5,0" Text="开始日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding StartTime}"
SelectedDateFormat="Short" />
<TextBlock Margin="5,0" Text="结束日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding EndTime}" />

<Button
Margin="10,0"
Command="{Binding GetHistoryCommand}"
Content="查询历史日志" />
</StackPanel>
<ToggleButton
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Content="实时日志"
FontSize="25"
Command="{Binding SwitchLogModeCommand}"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

<!--#endregion-->

<!--#region 列表-->
<bpa:ControlDisplay Grid.Row="1">
<DataGrid
Grid.Row="1"
AutoGenerateColumns="False"
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
RowHeight="50"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}"
FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}"
FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="*"
Binding="{Binding RunLogInfo}"
FontSize="16"
Header="日志信息" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/RunLogView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// LogView.xaml 的交互逻辑
/// </summary>
public partial class RunLogView : UserControl
{
public RunLogView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<RunLogViewModel>();
}
}
}

+ 110
- 0
BPA.SingleDevice/View/UserLogView.xaml Näytä tiedosto

@@ -0,0 +1,110 @@
<UserControl
x:Class="BPA.SingleDevice.View.UserLogView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="http://BPAUIControl.io/winfx/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPA.SingleDevice.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<bpa:DialogContainer>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 功能按钮-->
<StackPanel
Grid.Row="0"
Margin="10"
HorizontalAlignment="Right"
bpa:PanelHelper.Spacing="15"
Orientation="Horizontal">

<StackPanel Orientation="Horizontal" Visibility="{Binding ElementName=IsShowHistory, Path=IsChecked, Converter={StaticResource BooleanToVisibleConverter}}">
<TextBlock Margin="5,0" Text="开始日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding StartTime}"
SelectedDateFormat="Short" />
<TextBlock Margin="5,0" Text="结束日期:" />
<DatePicker
Width="150"
bpa:ControlHelper.FocusBorderBrush="{DynamicResource Accent}"
bpa:ControlHelper.MouseOverBrush="{DynamicResource Accent}"
bpa:InputBoxHelper.IsClearable="True"
bpa:InputBoxHelper.Watermark="请选择日期"
SelectedDate="{Binding EndTime}" />

<Button
Margin="10,0"
Command="{Binding GetHistoryCommand}"
Content="查询历史日志" />
</StackPanel>
<ToggleButton
x:Name="IsShowHistory"
HorizontalAlignment="Right"
bpa:ToggleButtonHelper.CheckedContent="历史日志"
Command="{Binding SwitchLogModeCommand}"
Content="实时日志"
FontSize="25"
Style="{DynamicResource SwitchToggleButton}" />
</StackPanel>

<!--#endregion-->

<!--#region 列表-->
<bpa:ControlDisplay Grid.Row="1">
<DataGrid
Grid.Row="1"
AutoGenerateColumns="False"
BorderBrush="Gray"
BorderThickness="1"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserSortColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
GridLinesVisibility="All"
IsReadOnly="True"
ItemsSource="{Binding Logs}"
RowHeight="50"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn
Width="150"
Binding="{Binding Date}"
FontSize="16"
Header="日期" />
<DataGridTextColumn
Width="150"
Binding="{Binding Time}"
FontSize="16"
Header="时间" />
<DataGridTextColumn
Width="150"
Binding="{Binding UserName}"
FontSize="16"
Header="用户" />
<DataGridTextColumn
Width="*"
Binding="{Binding UserLogInfo}"
FontSize="16"
Header="操作信息" />
</DataGrid.Columns>
</DataGrid>
</bpa:ControlDisplay>
<!--<bpa:MessageContainer Grid.Row="1" Identifier="RawMaterialManagementView" />-->
<!--#endregion-->

</Grid>
</bpa:DialogContainer>
</UserControl>

+ 30
- 0
BPA.SingleDevice/View/UserLogView.xaml.cs Näytä tiedosto

@@ -0,0 +1,30 @@
using Microsoft.Extensions.DependencyInjection;
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 BPA.SingleDevice.View
{
/// <summary>
/// UserLogView.xaml 的交互逻辑
/// </summary>
public partial class UserLogView : UserControl
{
public UserLogView()
{
InitializeComponent();
this.DataContext = App.Current.Services.GetService<UserLogViewModel>();
}
}
}

+ 42
- 0
BPA.SingleDevice/ViewModel/AlarmLogViewModel.cs Näytä tiedosto

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class AlarmLogViewModel:NotifyBase
{
public AlarmLogViewModel()
{
AlarmLogs = new();
for (int i = 1; i <= 100; i++)
{
AlarmLogs.Add(new()
{
ID = i,
Date = DateTime.Now.Date.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
Value = "108",
Info = "测试用报警信息",
Grade = "一般报警"
});
}
ViewHistoryCommand = new(() =>
{
//MessageBoxR.Show(IsShowHistory.ToString());
Message.Show(IsShowHistory.ToString());
});
}

public bool IsShowHistory { get; set; }
public ObservableCollection<AlarmLogTB> AlarmLogs { get; set; }

/// <summary>
/// 查看历史日志。
/// </summary>
public BPARelayCommand ViewHistoryCommand { get; set; }
}
}

+ 61
- 0
BPA.SingleDevice/ViewModel/DebugLogViewModel.cs Näytä tiedosto

@@ -0,0 +1,61 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class DebugLogViewModel:NotifyBase
{
private readonly ILogService logService;
private ObservableCollection<DebugLogTB> logs;

public DebugLogViewModel(ILogService logService)
{
this.logService = logService;

Logs = logService.DebugLogs;

StartTime = DateTime.Now.AddDays(-1);
EndTime = DateTime.Now;

SwitchLogModeCommand = new(() =>
{
if (!IsShowHistory)
{
Logs = logService.DebugLogs;
}
});
GetHistoryCommand = new(async () =>
{
Logs = null;
//查询历史日志
var logs = await logService.GetAllLog<DebugLogTB>();
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime));
});
}
public bool IsShowHistory { get; set; }
public ObservableCollection<DebugLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } }

/// <summary>
/// 开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}

+ 8
- 2
BPA.SingleDevice/ViewModel/MainViewModel.cs Näytä tiedosto

@@ -18,9 +18,15 @@ namespace BPA.SingleDevice.ViewModel
{
ViewItems = new ObservableCollection<ViewItem>
{
new ViewItem("原料管理", new RawMaterialManagementView(), IconType.ReservedFill),
new ViewItem("配方管理", new RecipeManagementView(), IconType.NewspaperFill),
new ViewItem("点单主页", new OrderMainView(), IconType.Home3Fill),
new ViewItem("配方管理", new RecipeManagementView(), IconType.NewspaperFill),
new ViewItem("原料管理", new RawMaterialManagementView(), IconType.ReservedFill),
new ViewItem("运行日志",new RunLogView(),IconType.FileTextLine),
new ViewItem("操作日志",new UserLogView(),IconType.AccountPinCircleLine),
new ViewItem("报警日志",new AlarmLogView(),IconType.AlarmWarningLine),
new ViewItem("调试日志",new DebugLogView(),IconType.BugLine),
new ViewItem("配方完成日志",new RecipeCompletView(),IconType.TaskLine),
new ViewItem("参数设置",new ParamsSetView(),IconType.Settings4Line)
};

SelecteCommand = new BPARelayCommand<object>(DoNavChanged);


+ 12
- 0
BPA.SingleDevice/ViewModel/ParamsSetViewModel.cs Näytä tiedosto

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class ParamsSetViewModel:NotifyBase
{
}
}

+ 61
- 0
BPA.SingleDevice/ViewModel/RecipeCompleteViewModel.cs Näytä tiedosto

@@ -0,0 +1,61 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class RecipeCompleteViewModel:NotifyBase
{
private readonly ILogService logService;
private ObservableCollection<RecipeCompleteLogTB> logs;

public RecipeCompleteViewModel(ILogService logService)
{
this.logService = logService;

Logs = logService.RecipeCompleteLogs;

StartTime = DateTime.Now.AddDays(-1);
EndTime = DateTime.Now;

SwitchLogModeCommand = new(() =>
{
if (!IsShowHistory)
{
Logs = logService.RecipeCompleteLogs;
}
});
GetHistoryCommand = new(async () =>
{
Logs = null;
//查询历史日志
var logs = await logService.GetAllLog<RecipeCompleteLogTB>();
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime));
});
}
public bool IsShowHistory { get; set; }
public ObservableCollection<RecipeCompleteLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } }

/// <summary>
/// 开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}

+ 63
- 0
BPA.SingleDevice/ViewModel/RunLogViewModel.cs Näytä tiedosto

@@ -0,0 +1,63 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class RunLogViewModel : NotifyBase
{
private readonly ILogService logService;
private ObservableCollection<RunLogTB> logs;

public RunLogViewModel(ILogService logService)
{
this.logService = logService;

Logs = logService.RunLogs;

StartTime = DateTime.Now.AddDays(-1);
EndTime = DateTime.Now;

SwitchLogModeCommand = new(() =>
{
if (!IsShowHistory)
{
Logs = logService.RunLogs;
}
});
GetHistoryCommand = new(async () =>
{
Logs = null;
//查询历史日志
var logs = await logService.GetAllLog<RunLogTB>();
Logs = new(logs?
.Where(log => log.Date.ObjToDate() >= StartTime
&& log.Date.ObjToDate() <= EndTime));
});
}
public bool IsShowHistory { get; set; }
public ObservableCollection<RunLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } }

/// <summary>
/// 开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}

+ 61
- 0
BPA.SingleDevice/ViewModel/UserLogViewModel.cs Näytä tiedosto

@@ -0,0 +1,61 @@
using BPA.SingleDevice.Services;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
public class UserLogViewModel:NotifyBase
{
private readonly ILogService logService;
private ObservableCollection<UserLogTB> logs;

public UserLogViewModel(ILogService logService)
{
this.logService = logService;

Logs = logService.UserLogs;

StartTime = DateTime.Now.AddDays(-1);
EndTime = DateTime.Now;

SwitchLogModeCommand = new(() =>
{
if (!IsShowHistory)
{
Logs = logService.UserLogs;
}
});
GetHistoryCommand = new(async () =>
{
Logs = null;
//查询历史日志
var logs = await logService.GetAllLog<UserLogTB>();
Logs = new(logs?.Where(log => log.Date.ObjToDate() >= StartTime && log.Date.ObjToDate() <= EndTime));
});
}
public bool IsShowHistory { get; set; }
public ObservableCollection<UserLogTB> Logs { get => logs; set { logs = value; OnPropertyChanged(); } }

/// <summary>
/// 开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime EndTime { get; set; }

/// <summary>
/// 切换日志类型
/// </summary>
public BPARelayCommand SwitchLogModeCommand { get; set; }
/// <summary>
/// 查看历史日志。
/// </summary>
public BPARelayCommand GetHistoryCommand { get; set; }
}
}

+ 2
- 2
BPA.UIControl/Themes/ScrollBar.xaml Näytä tiedosto

@@ -74,7 +74,7 @@
</Grid.Tag>
<Grid.Width>
<MultiBinding Converter="{StaticResource MathMultiplyConverter}">
<Binding Path="(rubyer:ScrollViewerHelper.ScrollBarSize)" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
<Binding Path="(bpa:ScrollViewerHelper.ScrollBarSize)" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
<Binding Path="Tag" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Grid.Width>
@@ -191,7 +191,7 @@
</Grid.Tag>
<Grid.Height>
<MultiBinding Converter="{StaticResource MathMultiplyConverter}">
<Binding Path="(rubyer:ScrollViewerHelper.ScrollBarSize)" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
<Binding Path="(bpa:ScrollViewerHelper.ScrollBarSize)" RelativeSource="{RelativeSource Mode=TemplatedParent}" />
<Binding Path="Tag" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Grid.Height>


Ladataan…
Peruuta
Tallenna