change-优化系统启动速度及界面

dev
liuwf 1 week ago
parent c5885a87ee
commit 594a80c610

@ -239,14 +239,20 @@ namespace SlnMesnac.Business
/// </summary> /// </summary>
private void SendFirstPmCode() private void SendFirstPmCode()
{ {
MesPrdBarcodeInfo mesPrdBarcodeInfo = _barCodeTaskService.Query(x => x.PrintFlag == "0" && x.BindStatus == 0).OrderBy(x => x.PrdBarcodeId).FirstOrDefault(); try
if(mesPrdBarcodeInfo != null)
{ {
udpServer.SendMessage(mesPrdBarcodeInfo.PrdBarcodeInfo); MesPrdBarcodeInfo mesPrdBarcodeInfo = _barCodeTaskService.Query(x => x.PrintFlag == "0" && x.BindStatus == 0).OrderBy(x => x.PrdBarcodeId).FirstOrDefault();
} if (mesPrdBarcodeInfo != null)
else {
udpServer.SendMessage(mesPrdBarcodeInfo.PrdBarcodeInfo);
}
else
{
_logger.LogError("可喷码数不足,请检查原因");
}
}catch (Exception ex)
{ {
_logger.LogError("可喷码数不足,请检查原因"); _logger.LogError("SendFirstPmCode获取数据库最早未喷印未绑定条码异常:" + ex.Message);
} }
} }
@ -279,7 +285,7 @@ namespace SlnMesnac.Business
var plc = base.GetPlcByKey("plc"); var plc = base.GetPlcByKey("plc");
if (plc == null) if (plc == null || plc.IsConnected== false)
{ {
_logger.LogInformation("2F读取小包出口信号,PLC连接信息为空......"); _logger.LogInformation("2F读取小包出口信号,PLC连接信息为空......");
Thread.Sleep(3000); Thread.Sleep(3000);

@ -202,7 +202,7 @@ namespace SlnMesnac.Business
RefreshMesProdList(); RefreshMesProdList();
var plc = base.GetPlcByKey("plc"); var plc = base.GetPlcByKey("plc");
if (plc == null) if (plc == null || !plc.IsConnected)
{ {
//throw new ArgumentException($"PLC连接信息为空"); //throw new ArgumentException($"PLC连接信息为空");
RefreshMessage($"PLC连接信息为空"); RefreshMessage($"PLC连接信息为空");

@ -65,7 +65,7 @@ namespace SlnMesnac.Rfid.Factory
try try
{ {
_tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"{ip}:{port}")); _tcpClient.Setup(new TouchSocketConfig().SetRemoteIPHost($"{ip}:{port}"));
_tcpClient.Connect(); _tcpClient.Connect(2000);
return true; return true;
} }
catch (Exception e) catch (Exception e)

@ -15,6 +15,8 @@ using SlnMesnac.Common;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
namespace SlnMesnac.WPF namespace SlnMesnac.WPF
{ {
@ -83,6 +85,7 @@ namespace SlnMesnac.WPF
{ {
try try
{ {
HandleException(e.Exception); HandleException(e.Exception);
} }
catch (Exception ex) catch (Exception ex)
@ -96,9 +99,29 @@ namespace SlnMesnac.WPF
} }
private static void HandleException(Exception ex) private static void HandleException(Exception ex)
{ {
Log.Warning($"全局异常捕获处理: {ex.Message}");
}
// 记录异常的详细信息
Log.Warning($"全局异常捕获处理: {ex.Message}");
// 获取堆栈跟踪信息
StackTrace stackTrace = new StackTrace(ex, true);
// 遍历堆栈跟踪的每一帧
for (int i = 0; i < stackTrace.FrameCount; i++)
{
StackFrame frame = stackTrace.GetFrame(i);
// 获取文件名、行号和方法名
string fileName = frame.GetFileName();
int lineNumber = frame.GetFileLineNumber();
string methodName = frame.GetMethod().Name;
// 记录堆栈信息
Log.Warning($" 在文件 {fileName} 中,第 {lineNumber} 行,方法 {methodName} 抛出异常");
}
}
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程) //非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {

@ -32,7 +32,7 @@
<TextBlock Visibility="Collapsed" x:Name="BagsAmountTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/> <TextBlock Visibility="Collapsed" x:Name="BagsAmountTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button Visibility="Collapsed" x:Name="AmountChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="CadetBlue" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="AmountChangeButton_Click"/> <Button Visibility="Collapsed" x:Name="AmountChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="CadetBlue" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="AmountChangeButton_Click"/>
<Button x:Name="MachineStopHistoryButton" Content="停机记录历史" FontSize="25" Foreground="White" Background="CadetBlue" Width="200" Height="60" Margin="300 0 20 0" HorizontalAlignment="Left" Click="MachineStopHistoryButton_Click"/> <Button x:Name="MachineStopHistoryButton" Content="停机记录" FontSize="25" Foreground="White" Background="CadetBlue" Width="200" Height="60" Margin="300 0 20 0" HorizontalAlignment="Left" Click="MachineStopHistoryButton_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>

@ -59,6 +59,7 @@ namespace SlnMesnac.WPF.ViewModel
{ {
PagenationModel = new PagenationModel<T>() PagenationModel = new PagenationModel<T>()
{ {
FindPreCommand = new RelayCommand(OnPreCommand), FindPreCommand = new RelayCommand(OnPreCommand),
FindNextCommand = new RelayCommand(OnNextCommand), FindNextCommand = new RelayCommand(OnNextCommand),
FindTargetCommand = new RelayCommand(OnGoCommand) FindTargetCommand = new RelayCommand(OnGoCommand)
@ -108,7 +109,7 @@ namespace SlnMesnac.WPF.ViewModel
machineNameDic.Add(1021, "2楼喷码机"); machineNameDic.Add(1021, "2楼喷码机");
PagenationModel.Total = await getListTotal(); PagenationModel.Total = await getListTotal();
PagenationModel.computePage(); PagenationModel.computePage();
await RefreshWcsTaskDataGrid(PagenationModel.Current, PagenationModel.PageSize); await RefreshWcsTaskDataGrid(PagenationModel.Current, 20);
} }
private async Task<int> getListTotal() private async Task<int> getListTotal()
{ {

Loading…
Cancel
Save