Browse Source

添加日志查看

master
sc 9 months ago
parent
commit
d8dad60041
  1. 9
      Properties/Resources.Designer.cs
  2. 3
      Properties/Resources.en-US.resx
  3. 3
      Properties/Resources.resx
  4. 3
      Properties/Resources.zh-CN.resx
  5. 9
      Properties/Resources.zh-TW.resx
  6. 7
      SunlightCentralizedControlManagement_SCCM_.csproj
  7. 2
      UserClass/AsyncTcpClient.cs
  8. 16
      View/EngineerSetView.xaml
  9. 40
      View/LogView.xaml
  10. 99
      View/LogView.xaml.cs
  11. 4
      View/ProductionPlanningEdit.xaml.cs
  12. 7
      View/ProductionPlanningView.xaml.cs
  13. 8
      View/SYSSetView.xaml
  14. 4
      View/SYSSetView.xaml.cs
  15. 7
      ViewModel/MainWindowViewModel.cs

9
Properties/Resources.Designer.cs

@ -1131,6 +1131,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 Log 的本地化字符串。
/// </summary>
public static string log {
get {
return ResourceManager.GetString("log", resourceCulture);
}
}
/// <summary>
/// 查找类似 Low-water level 的本地化字符串。
/// </summary>

3
Properties/Resources.en-US.resx

@ -948,4 +948,7 @@
<data name="ENWOIP" xml:space="preserve">
<value>Editing non-pending work order is prohibited</value>
</data>
<data name="log" xml:space="preserve">
<value>Log</value>
</data>
</root>

3
Properties/Resources.resx

@ -948,4 +948,7 @@
<data name="ENWOIP" xml:space="preserve">
<value>Editing non-pending work order is prohibited</value>
</data>
<data name="log" xml:space="preserve">
<value>Log</value>
</data>
</root>

3
Properties/Resources.zh-CN.resx

@ -948,4 +948,7 @@
<data name="ENWOIP" xml:space="preserve">
<value>禁止编辑非等待中的工单</value>
</data>
<data name="log" xml:space="preserve">
<value>日志</value>
</data>
</root>

9
Properties/Resources.zh-TW.resx

@ -942,4 +942,13 @@
<data name="DoesNotExist" xml:space="preserve">
<value>頁面不存在</value>
</data>
<data name="ENWOIP" xml:space="preserve">
<value>禁止編輯非待處理工單!</value>
</data>
<data name="EHCIP" xml:space="preserve">
<value>禁止編輯歷史工單!</value>
</data>
<data name="log" xml:space="preserve">
<value>日誌</value>
</data>
</root>

7
SunlightCentralizedControlManagement_SCCM_.csproj

@ -127,6 +127,9 @@
<Compile Include="View\CurveDiagram.xaml.cs">
<DependentUpon>CurveDiagram.xaml</DependentUpon>
</Compile>
<Compile Include="View\LogView.xaml.cs">
<DependentUpon>LogView.xaml</DependentUpon>
</Compile>
<Compile Include="View\MachinesView.xaml.cs">
<DependentUpon>MachinesView.xaml</DependentUpon>
</Compile>
@ -203,6 +206,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\LogView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\MachinesView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

2
UserClass/AsyncTcpClient.cs

@ -285,7 +285,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
else if (SYSAPI == "SC980")
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
MessageBox.Show(DAT);
MessageBox.Show(DAT,"SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
}
return EasyTask.CompletedTask;

16
View/EngineerSetView.xaml

@ -8,22 +8,22 @@
mc:Ignorable="d"
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
<Grid>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxCOM0" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" />
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,10,0,0" x:Name="comboBoxCOM0" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16" />
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM1" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,90,0,0" x:Name="comboBoxCOM2" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,130,0,0" x:Name="comboBoxLanguage" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxLanguage_SelectionChanged" FontSize="20"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM1" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,90,0,0" x:Name="comboBoxCOM2" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="16"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,130,0,0" x:Name="comboBoxLanguage" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxLanguage_SelectionChanged" FontSize="16"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,130,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Language}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,170,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.SERVER}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,210,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Mode}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,250,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.SQL}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,290,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.USER}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,330,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Password}" VerticalAlignment="Top" Width="120" FontSize="25"/>
<TextBox x:Name="TEXT_SQLIP" HorizontalAlignment="Left" Height="40" Margin="150,170,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="20"/>
<TextBox x:Name="TEXT_SQLIP" HorizontalAlignment="Left" Height="40" Margin="150,170,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="16"/>
<ComboBox x:Name="TEXT_SQMOD" Height="40" Margin="150,210,0,0" VerticalAlignment="Top" Width="200" FontSize="16" HorizontalAlignment="Left"/>
<TextBox x:Name="TEXT_SQLNAME" HorizontalAlignment="Left" Height="40" Margin="150,250,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="20"/>
<TextBox x:Name="TEXT_SQLUSER" HorizontalAlignment="Left" Height="40" Margin="150,290,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="20"/>
<TextBox x:Name="TEXT_SQLPASWORD" HorizontalAlignment="Left" Height="40" Margin="150,330,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="20"/>
<TextBox x:Name="TEXT_SQLNAME" HorizontalAlignment="Left" Height="40" Margin="150,250,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="16"/>
<TextBox x:Name="TEXT_SQLUSER" HorizontalAlignment="Left" Height="40" Margin="150,290,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="16"/>
<TextBox x:Name="TEXT_SQLPASWORD" HorizontalAlignment="Left" Height="40" Margin="150,330,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="200" FontSize="16"/>
<Button Content="{x:Static lang:Resources.Test}" HorizontalAlignment="Left" Height="35" Margin="270,375,0,0" VerticalAlignment="Top" Width="80" Click="Test_Click"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,375,0,0" x:Name="textlog" TextWrapping="Wrap" Text="------------" VerticalAlignment="Top" Width="140" FontSize="20"/>

40
View/LogView.xaml

@ -0,0 +1,40 @@
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.LogView"
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:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="1200">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="600"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ComboBox Height="45" x:Name="comboBox_log" VerticalAlignment="Top" FontSize="20" Background="#FF90BEFF"
DropDownClosed="comboBox_log_DropDownClosed" BorderBrush="#FF00204E" Padding="1,1,1,1"/>
<DataGrid Grid.Column="0" x:Name="gridLog" Margin="0,50,0,0" HeadersVisibility ="Column"
IsReadOnly="True" AutoGenerateColumns="False" MouseDoubleClick="DataGrid_gridLogClick" >
<DataGrid.Columns>
<!--列信息绑定-->
<DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="195" MaxWidth="195" MinWidth="195" CanUserReorder="False"/>
<DataGridTextColumn Binding="{Binding Length}" Header="Volume" Width="50" MaxWidth="150" MinWidth="100" CanUserReorder="False"/>
<DataGridTextColumn Binding="{Binding CreationTimeUtc}" Header="Creation time" Width="150" MaxWidth="150" MinWidth="150" CanUserReorder="False"/>
<DataGridTextColumn Binding="{Binding LastWriteTimeUtc}" Header="Last modified time" Width="150" MaxWidth="150" MinWidth="150" CanUserReorder="False"/>
</DataGrid.Columns>
</DataGrid>
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FF00204E"/>
<RichTextBox Grid.Column="2" x:Name="Logtext" IsReadOnly="True" VerticalScrollBarVisibility="Visible" Background="White" SelectionBrush="White">
<FlowDocument>
<Paragraph>
<Run Text="LOG"/>
</Paragraph>
</FlowDocument>
</RichTextBox>
<!--遮罩-->
</Grid>
</UserControl>

99
View/LogView.xaml.cs

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
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 SunlightCentralizedControlManagement_SCCM_.View
{
/// <summary>
/// LogView.xaml 的交互逻辑
/// </summary>
public partial class LogView : UserControl
{
string Log_time = DateTime.Now.ToString("yyyy-MM-dd");
DataTable logdataTable = new DataTable(); //建立RRODUCT缓存
public LogView()
{
InitializeComponent();
comboBox_log.ItemsSource = new string[3] { "Log", "ERR", "Exchange" };
comboBox_log.Text = "Log";
logdataTable.Columns.Add("Name", typeof(string));
logdataTable.Columns.Add("Length", typeof(int));
logdataTable.Columns.Add("CreationTimeUtc", typeof(string));
logdataTable.Columns.Add("LastWriteTimeUtc", typeof(string));
LOG_file();
}
private void LOG_file()//建立列表
{
DirectoryInfo loginfo = new DirectoryInfo(System.Environment.CurrentDirectory + "\\"+comboBox_log.Text); //new文件夹
logdataTable.Clear();
foreach (var item in loginfo.GetFiles())
{
DataRow FileRow = logdataTable.NewRow();
FileRow["Name"] = item.Name;
FileRow["Length"] = item.Length / 1024;
FileRow["CreationTimeUtc"] = item.CreationTimeUtc;
FileRow["LastWriteTimeUtc"] = item.LastWriteTimeUtc;
logdataTable.Rows.Add(FileRow);
}
logdataTable.DefaultView.Sort = "Name DESC";
gridLog.ItemsSource = logdataTable.DefaultView.ToTable().DefaultView;
}
private void DataGrid_gridLogClick(object sender, MouseButtonEventArgs e)//数据表双击事件
{
int rownum = gridLog.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
/*定位选中行及指定列单元格文本信息*/
LOGDATA_file((gridLog.Columns[0].GetCellContent(gridLog.Items[rownum]) as TextBlock).Text.TrimEnd());//
}
}
private void LOGDATA_file(string dat) //读取文件显示到前端
{
Logtext.Document = new FlowDocument();
string filePath = System.Environment.CurrentDirectory + "\\"+comboBox_log.Text+"\\";
try
{
// 使用StreamReader读取文件
using (StreamReader reader = new StreamReader(filePath + dat))
{
// 读取文件直到文件的末尾
while (!reader.EndOfStream)
{
// 添加文件的每一行到RichTextBox
Logtext.AppendText(reader.ReadLine() + "\r\n");
}
}
}
catch (Exception ex)
{
// 处理可能发生的任何异常
MessageBox.Show("Error reading file: " + ex.Message);
}
}
private void comboBox_log_DropDownClosed(object sender, EventArgs e)
{
LOG_file();
}
}
}

4
View/ProductionPlanningEdit.xaml.cs

@ -108,12 +108,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
if (string.IsNullOrEmpty(comboBoxMachine.Text))
{
MessageBox.Show("Not Machine");
MessageBox.Show("Not Machine","SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
return;
}
if (string.IsNullOrEmpty(comboBoxProgram.Text))
{
MessageBox.Show("Not Program");
MessageBox.Show("Not Program", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
return;
}
string[] sArray = Regex.Split(comboBoxMachine.Text, @"\+", RegexOptions.IgnoreCase);

7
View/ProductionPlanningView.xaml.cs

@ -155,7 +155,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (DateTime.Now > DateTime.Parse(WorkOrder_dt.Select().First().Field<object>("EndTime").ToString()))
{
MessageBox.Show(Properties.Resources.EHCIP);//禁止编辑历史工艺
MessageBox.Show(Properties.Resources.EHCIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑历史工艺
}
else
{
@ -167,7 +167,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
else
{
MessageBox.Show(Properties.Resources.ENWOIP);//禁止编辑非等待中的工单
MessageBox.Show(Properties.Resources.ENWOIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑非等待中的工单
}
}
}//编辑
@ -235,7 +235,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
else
{
MessageBox.Show(Properties.Resources.WorkOrderNumder+ Select_WorkOrderNumder.Text + Properties.Resources.DoesNotExist);
MessageBox.Show(Properties.Resources.WorkOrderNumder+ Select_WorkOrderNumder.Text + Properties.Resources.DoesNotExist,
"SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}//搜索并打开
private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天

8
View/SYSSetView.xaml

@ -30,6 +30,14 @@
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_log" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="MathLog" Width="40" Height="30" Margin="10" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.log}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
<Grid Background="White" Margin="0,0,0,60">

4
View/SYSSetView.xaml.cs

@ -47,5 +47,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
Picture.Content = new View.EngineerSetView();
}
private void ListViewItem_log(object sender, MouseButtonEventArgs e)
{
Picture.Content = new View.LogView();
}
}
}

7
ViewModel/MainWindowViewModel.cs

@ -1,4 +1,5 @@
using LiveChartsCore.Geo;
using DyeingComputer.UserClass;
using LiveChartsCore.Geo;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenTK.Graphics.ES11;
@ -91,8 +92,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
await conn_SC.OpenAsync(); //连接数据库
//conn_SC.Close();
}
catch (Exception)
catch (Exception ex)
{
LogGing.LogGingDATA("[Database='" + ex + "']=SQLSERVER");
ERR_c++;
}
}

Loading…
Cancel
Save