@@ -699,7 +699,7 @@ | |||
</VisualStateManager.VisualStateGroups> | |||
<StackPanel HorizontalAlignment="Center" Margin="5" Orientation="Horizontal"> | |||
<Image Source="/BPASmartClient.CustomResource;component/Image/退出.png" Width="16" ></Image> | |||
<TextBlock Margin="5,0,0,0" x:Name="textBlock" Text="{TemplateBinding Content}" FontSize="16" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="#A5FFFFFF" /> | |||
<TextBlock Margin="5,0,0,0" x:Name="textBlock" Text="{TemplateBinding Content}" FontSize="14" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="#A5FFFFFF" /> | |||
</StackPanel> | |||
</Border> | |||
@@ -1,13 +1,18 @@ | |||
using BPASmartClient.Message; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Media; | |||
using System.Windows.Threading; | |||
namespace BPASmartClient.ViewModel | |||
{ | |||
@@ -16,6 +21,7 @@ namespace BPASmartClient.ViewModel | |||
/// </summary> | |||
public class LogViewModel :ObservableObject | |||
{ | |||
public DispatcherTimer dispatcherTimer; | |||
private ObservableCollection<LogModel> _LogModels; | |||
public ObservableCollection<LogModel> LogDataGrid | |||
@@ -52,10 +58,148 @@ namespace BPASmartClient.ViewModel | |||
}); | |||
ExcelCommand = new RelayCommand(() => | |||
{ | |||
ExcellOrder(); | |||
}); | |||
//dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };//1秒一流转 | |||
//dispatcherTimer.Tick += delegate | |||
//{ | |||
// if (TimedClear) | |||
// { | |||
// } | |||
//}; | |||
//dispatcherTimer.Start(); | |||
} | |||
private string[] colums = new string[] { "订单编号","商品名称","排序号","订单状态","开始时间","取餐时间","结束时间" }; | |||
/// <summary> | |||
/// 导出数据 | |||
/// </summary> | |||
public void ExcellOrder() | |||
{ | |||
if (LogDataGrid.Count > 0) | |||
{ | |||
string text = "时间 类型 日志内容\n"; | |||
LogDataGrid?.ToList().ForEach(temp => | |||
{ | |||
text = text + temp.time + " " + temp.type + " " + temp.message+ "\n"; | |||
}); | |||
SaveFileDialog openfile = new SaveFileDialog(); | |||
openfile.Filter = "Txt文件(*.txt)|*.txt"; | |||
if (openfile.ShowDialog() == null) | |||
{ | |||
return; | |||
} | |||
string path = openfile.FileName; | |||
if (!System.IO.File.Exists(path)) | |||
{ | |||
//没有则创建这个文件 | |||
FileStream fs1 = new FileStream(path,FileMode.Create,FileAccess.Write);//创建写入文件 | |||
StreamWriter sw = new StreamWriter(fs1); | |||
sw.WriteLine(text);//开始写入值 | |||
sw.Close(); | |||
fs1.Close(); | |||
} | |||
else | |||
{ | |||
FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Write); | |||
StreamWriter sr = new StreamWriter(fs); | |||
sr.WriteLine(text);//开始写入值 | |||
sr.Close(); | |||
fs.Close(); | |||
} | |||
string msg = string.Format("记录导出完成,共导出记录{0}条,是否打开!",LogDataGrid.Count); | |||
if (System.Windows.MessageBox.Show(msg,"提示",MessageBoxButton.OKCancel) == MessageBoxResult.OK) | |||
{ | |||
OpenFile(openfile.FileName); | |||
} | |||
} | |||
else | |||
System.Windows.MessageBox.Show("无数据!"); | |||
} | |||
/// <summary> | |||
/// 打开指定路径下文件,比如:Word、Excel、Dll、图片等都可以(前提是你已经安装打开程序的对应软件) | |||
/// </summary> | |||
/// <param name="NewFileName">eg:D:\Test\模版8.doc</param> | |||
/// <param name="NewFileName">eg:D:\Test\模版8.doc</param> | |||
private void OpenFile(string NewFileName) | |||
{ | |||
Process process = new Process(); | |||
ProcessStartInfo processStartInfo = new ProcessStartInfo(NewFileName); | |||
process.StartInfo = processStartInfo; | |||
#region 下面这段被注释掉代码(可以用来全屏打开代码) | |||
//建立新的系统进程 | |||
////System.Diagnostics.Process process = new System.Diagnostics.Process(); | |||
//设置文件名,此处为图片的真实路径 + 文件名(需要有后缀) | |||
////process.StartInfo.FileName = NewFileName; | |||
//此为关键部分。设置进程运行参数,此时为最大化窗口显示图片。 | |||
////process.StartInfo.Arguments = "rundll32.exe C://WINDOWS//system32//shimgvw.dll,ImageView_Fullscreen"; | |||
// 此项为是否使用Shell执行程序,因系统默认为true,此项也可不设,但若设置必须为true | |||
process.StartInfo.UseShellExecute = true; | |||
#endregion | |||
try | |||
{ | |||
process.Start(); | |||
try | |||
{ | |||
// process.WaitForExit(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
throw ex; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
throw ex; | |||
} | |||
finally | |||
{ | |||
try | |||
{ | |||
if (process != null) | |||
{ | |||
process.Close(); | |||
process = null; | |||
} | |||
} | |||
catch { } | |||
} | |||
} | |||
private bool _RealTimeModel = true; | |||
public bool RealTimeModel | |||
{ | |||
get | |||
{ | |||
return _RealTimeModel; | |||
} | |||
set | |||
{ | |||
if (_RealTimeModel == value) | |||
return; | |||
_RealTimeModel = value; | |||
OnPropertyChanged("RealTimeModel"); | |||
} | |||
} | |||
private bool _TimedClear = true; | |||
public bool TimedClear | |||
{ | |||
get | |||
{ | |||
return _TimedClear; | |||
} | |||
set | |||
{ | |||
if (_TimedClear == value) | |||
return; | |||
_TimedClear = value; | |||
OnPropertyChanged("TimedClear"); | |||
} | |||
} | |||
public RelayCommand ExcelCommand { get; set; } | |||
@@ -10,8 +10,8 @@ | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" /> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/> | |||
<!--<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>--> | |||
<ResourceDictionary> | |||
<con:ColorConverter x:Key="ColorConverter" /> | |||
@@ -6,6 +6,14 @@ | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<!--底部窗体栏--> | |||
<Grid > | |||
<Grid.RowDefinitions> | |||
@@ -7,6 +7,14 @@ | |||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:LogViewModel></vm:LogViewModel> | |||
</UserControl.DataContext> | |||
@@ -19,8 +27,8 @@ | |||
<!--查询按钮栏--> | |||
<StackPanel Orientation="Horizontal" Margin="10,0,10,0"> | |||
<CheckBox Margin="10,0,0,0" IsChecked="True">实时模式</CheckBox> | |||
<CheckBox Margin="10,0,0,0" IsChecked="True">定时清除</CheckBox> | |||
<CheckBox Margin="10,0,0,0" IsChecked="{Binding RealTimeModel, UpdateSourceTrigger=PropertyChanged}" >实时模式</CheckBox> | |||
<CheckBox Margin="10,0,0,0" IsChecked="{Binding TimedClear, UpdateSourceTrigger=PropertyChanged}">定时清除</CheckBox> | |||
<Button Margin="10,0,0,0" Cursor="Hand" Command="{Binding ExcelCommand}">导出</Button> | |||
</StackPanel> | |||
@@ -36,14 +44,14 @@ | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="操作类" Width="300"> | |||
<DataGridTemplateColumn Header="日志类型" Width="300"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="日志描述" Width="*"> | |||
<DataGridTemplateColumn Header="日志内容" Width="*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | |||
@@ -14,7 +14,14 @@ | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Window.Resources> | |||
<Window.DataContext> | |||
<vm:MainViewModel></vm:MainViewModel> | |||
</Window.DataContext> | |||
@@ -34,7 +41,7 @@ | |||
</Grid.ColumnDefinitions> | |||
<Border Grid.ColumnSpan="2" Style="{DynamicResource bordertop矩形}"></Border> | |||
<Border Style="{DynamicResource bordertopL}"></Border> | |||
<Image Margin="10,0,0,0" VerticalAlignment="Center" Style="{DynamicResource imagetop_Title}" ></Image> | |||
<Image Margin="20,0,0,0" VerticalAlignment="Center" Style="{DynamicResource imagetop_Title}" ></Image> | |||
<Grid Grid.Column="1"> | |||
<Menu > | |||
<MenuItem Header="状态监视" > | |||
@@ -100,7 +107,7 @@ | |||
</StackPanel> | |||
</Grid> | |||
<Border Style="{DynamicResource border竖线}" /> | |||
<Button x:Name="ButClose" Grid.Column="4" Margin="10,0,20,0" Style="{DynamicResource CommonBtnStyle退出按钮}" VerticalAlignment="Center" ToolTip="退出程序" Cursor="Hand" Content="退出"/> | |||
<Button x:Name="ButClose" Grid.Column="4" Margin="10,0,20,0" Style="{DynamicResource CommonBtnStyle退出按钮}" VerticalAlignment="Center" ToolTip="退出程序" Cursor="Hand" Content="退出"/> | |||
</StackPanel> | |||
</Grid> | |||
@@ -118,7 +125,7 @@ | |||
<Grid Margin="10"> | |||
<Border Style="{DynamicResource borderFromTitle}" Width="600"></Border> | |||
<Button Grid.Row="0" Content="返回" Style="{DynamicResource CommonBtn_返回}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click"/> | |||
<TextBlock x:Name="Title" HorizontalAlignment="Center" FontSize="16" Foreground="#feffff">日志监控界面</TextBlock> | |||
<TextBlock x:Name="Title" HorizontalAlignment="Center" FontSize="18" Foreground="#feffff">日志监控界面</TextBlock> | |||
</Grid> | |||
<!--#region 底部窗体栏--> | |||