Files
DE70/Admin/AdminConfigurationUC.xaml.cs
T
Nguyen Dinh Thuan 8cb760e4a4 - Tăng thời gian hiện Reset Counter
- Sửa lại Task gửi dữ liệu
2024-09-20 19:50:58 +07:00

102 lines
3.1 KiB
C#

using DE70_CMDv2;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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 SafeBagDE70.Admin
{
/// <summary>
/// Interaction logic for AdminConfigurationUC.xaml
/// </summary>
public partial class AdminConfigurationUC : UserControl
{
public AdminConfigurationUC()
{
InitializeComponent();
}
private void btnResetCounter_Click(object sender, RoutedEventArgs e)
{
Log.Information("[ADMIN] reset cdm counter");
bool bResetCDMCounter = AppData.ResetCDMCounter();
if(!bResetCDMCounter)
{
bResetCDMCounter = AppData.ResetCDMCounter();
}
if (bResetCDMCounter)
{
Log.Information("[ADMIN] reset counter successfully");
lblCounterStatus.Text = "TRẠNG THÁI: KHỞI TẠO BỘ ĐẾM THÀNH CÔNG";
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
Task.Run(() =>
{
Thread.Sleep(30000);
Dispatcher.Invoke(() =>
{
lblCounterStatus.Text = "";
});
});
}
else
{
Log.Information("[ADMIN] reset counter fail");
}
}
private void btnOpenEscrow_Click(object sender, RoutedEventArgs e)
{
Log.Information("[ADMIN] Do Check");
var mainWindow = ((MainWindow)Application.Current.MainWindow);
if (mainWindow!=null)
mainWindow.DoCheck();
}
private void btnGetCDMState_Click(object sender, RoutedEventArgs e)
{
var state = AppData.GetCDMState();
lblDeviceStatus.Text = state.GetFullStatus();
}
private void btnSoftResetError_Click(object sender, RoutedEventArgs e)
{
try
{
Log.Information("[ADMIN] Reset CDM Error");
if (AppData.ResetCDMError())
{
Log.Information("[ADMIN] Reset CDM Error successfully");
lblCounterStatus.Text = "Reset lỗi thành công";
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
Task.Run(() =>
{
Thread.Sleep(10000);
Dispatcher.Invoke(() =>
{
lblCounterStatus.Text = "";
});
});
}
}
catch (Exception ex) {
Log.Fatal(ex, "SoftReset");
}
}
}
}