Compare commits

...
10 Commits
9 changed files with 264 additions and 38 deletions
+7
View File
@@ -24,6 +24,13 @@
Margin="10"
Click="btnSoftResetError_Click"/>
<Button
Content="RESET LỖI (ABNORMAL STORAGE)"
x:Name="btnSoftImportantError"
HorizontalAlignment="Stretch"
Height="40"
Margin="10"
Click="btnSoftImportantError_Click"/>
<Button
Content="MỞ NGĂN PHỤ"
x:Name="btnOpenEscrow"
HorizontalAlignment="Stretch"
+42
View File
@@ -97,5 +97,47 @@ namespace SafeBagDE70.Admin
}
private void btnSoftImportantError_Click(object sender, RoutedEventArgs e)
{
var state = AppData.GetCDMState();
if (state.IsNotesInEscrow>0||
state.IsNotesInRejectPocket>0||
state.IsNotesInHopper>0)
{
lblCounterStatus.Foreground = new SolidColorBrush(Colors.Red);
lblCounterStatus.Text = "Vẫn còn tiền trong máy, đề nghị lấy tiền ra khỏi các ngăn và kiểm tra tiền kẹt";
}
else
{
lblCounterStatus.Foreground = new SolidColorBrush(Colors.Green);
lblCounterStatus.Text = "Đang thực hiện Reset lỗi";
Log.Information("[ADMIN] Reset CDM Error");
var bSuccess = AppData.ResetAbnormalStorage605();
if (bSuccess)
{
Log.Information("[ADMIN] Reset CDM AbnormalStorage successfully");
lblCounterStatus.Foreground = new SolidColorBrush(Colors.Green);
lblCounterStatus.Text = "Reset lỗi thành công";
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
Task.Run(() =>
{
Thread.Sleep(10000);
Dispatcher.Invoke(() =>
{
lblCounterStatus.Text = "";
});
});
}
else
{
lblCounterStatus.Foreground = new SolidColorBrush(Colors.Red);
lblCounterStatus.Text = "Reset lỗi không thành công";
}
}
}
}
}
+80 -11
View File
@@ -666,7 +666,8 @@ namespace SafeBagDE70
bool bSuccess = false;
if(cCmdRsp!=null && cCmdRsp.recv_dat!=null)
{
if(cCmdRsp.recv_dat.dat[1] == 0x1C && cCmdRsp.recv_dat.dat[2] == 0x4A)
//if(cCmdRsp.recv_dat.dat[1] == 0x1C && cCmdRsp.recv_dat.dat[2] == 0x4A)
if (cCmdRsp.recv_dat.dat[1] == 0x1C)
{
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
@@ -692,46 +693,114 @@ namespace SafeBagDE70
}
return bSuccess;
}
private static void LogCmdData()
{
try
{
string strSend = cCmdRsp.GetSendDat(false);
string strRecv = cCmdRsp.GetRecvDat();
Log.Information($"[SEND] {strSend}");
Log.Information($"[RECV] {strRecv}");
}
catch (Exception e) {
Log.Fatal(e, "LogCmdData");
}
}
public static bool ResetAbnormalStorage605()
{
var cCmdRsp = AppData.cCmdRsp;
bool bSuccess = false;
if (cCmdRsp != null && cCmdRsp.recv_dat != null)
if (cCmdRsp != null)
{
if (cCmdRsp.recv_dat.dat[1] == 0x1C && cCmdRsp.recv_dat.dat[2] == 0x4A)
Log.Information("START ABNORMAL STORAGE RESET PROC");
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
LogCmdData();
if (cCmdRsp.recv_dat != null &&
((cCmdRsp.recv_dat.dat[18] & 0xF0) == 0xE0))
{
//0. Check notes in escrow or not?
//1. Event Fix
var recvData = cCmdRsp.recv_dat;
if (recvData.dat[14] == recvData.dat[16])
{
cCmdRsp.SendLock();
}
else
{
cCmdRsp.SendEventFix(recvData.dat[16]);
}
//2. UnLock
// cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
LogCmdData();
Thread.Sleep(1000);
//3. Lock with MODE IMPORTANT ERROR
var currentMode = cCmdRsp.GetLockParam().mode;
cCmdRsp.GetLockParam().mode = Mode.MODE_SECERROR;
cCmdRsp.SendLock();
LogCmdData();
Thread.Sleep(1000);
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
var recvData = cCmdRsp.recv_dat;
LogCmdData();
recvData = cCmdRsp.recv_dat;
var SR2 = recvData.dat[1];
var S2 = recvData.dat[recvData.leng - 1];
if (recvData.dat[1] == 0x1C && (S2==0xE2 || S2==0xE4))
var S2 = recvData.dat[18];
if (SR2 == 0x1C && (S2==0xE2 || S2==0xE4))
{
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET);
Thread.Sleep(2000);
LogCmdData();
Thread.Sleep(1000);
for (int i=0;i<10;i++)
{
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
LogCmdData();
Thread.Sleep(1000);
S2 = recvData.dat[18];
SR2 = recvData.dat[1];
if (SR2 == 0x07)
break;
}
Thread.Sleep(2000);
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
Thread.Sleep(1000);
LogCmdData();
Thread.Sleep(2000);
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
if (cCmdRsp.recv_dat.dat[1] == 0x04 && cCmdRsp.recv_dat.dat[2] == 0x41)
Thread.Sleep(2000);
LogCmdData();
if ((cCmdRsp.recv_dat.dat[1] == 0x07 || cCmdRsp.recv_dat.dat[1]==0x09) && cCmdRsp.recv_dat.dat[2] == 0x41)
{
//Wait until SR2=0x04
for(int i = 0; i < 10; i++)
{
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
LogCmdData();
Thread.Sleep(1000);
SR2 = recvData.dat[1];
if (SR2 == 0x04)
{
bSuccess = true;
}
}
}
}
else
{
}
Log.Information("END ABNORMAL STORAGE RESET PROC");
}
}
return bSuccess;
@@ -1024,7 +1093,7 @@ namespace SafeBagDE70
public int PrintingCountFromNPO = 0;//Transaction Count From Near Paper Out
public bool IsStopPrinting()
{
if (IsPrinterNearPaperOut && PrintingCountFromNPO >= 20)
if (IsPrinterNearPaperOut && PrintingCountFromNPO >= 50)
{
return true;
}
+23
View File
@@ -0,0 +1,23 @@
<UserControl x:Class="SafeBagDE70.ClockUC"
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:SafeBagDE70"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Border Background="Transparent" CornerRadius="10" Padding="10">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="txtTime"
FontSize="40"
FontWeight="Bold"
Foreground="Red"
HorizontalAlignment="Center" />
<TextBlock x:Name="txtDate"
FontSize="35"
Foreground="Red"
FontWeight="Bold"
HorizontalAlignment="Center" />
</StackPanel>
</Border>
</UserControl>
+42
View File
@@ -0,0 +1,42 @@
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.Threading;
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
{
/// <summary>
/// Interaction logic for ClockUC.xaml
/// </summary>
public partial class ClockUC : UserControl
{
private DispatcherTimer _timer;
public ClockUC()
{
InitializeComponent();
_timer = new DispatcherTimer()
{
Interval = TimeSpan.FromSeconds(1)
};
_timer.Tick += Timer_Tick;
_timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
txtTime.Text = DateTime.Now.ToString("HH:mm:ss");
txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
}
}
}
+6 -1
View File
@@ -10,7 +10,12 @@
ShowInTaskbar="False"
ShowNonClientArea="False"
IsFullScreen="True">
<Grid x:Name="gridMain">
<Grid >
<Grid x:Name="gridMain"/>
<local:ClockUC HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,130,80,0" />
</Grid>
</hc:Window>
+1 -1
View File
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>icon\logo.ico</ApplicationIcon>
<Version>1.1.0</Version>
<Version>1.1.3</Version>
</PropertyGroup>
<ItemGroup>
+51 -13
View File
@@ -77,9 +77,13 @@ namespace SafeBagDE70
CCmdRsp cCmdRsp = null;
bool bInitialized = false;
bool bOpenPort = true;
bool bIsMaintain = false;
MainWindow mainWindow = null;
Task taskCounting = null;
bool isSensorActivated = true;
bool isPrinterActivated = true;
public DepositSMUCv2()
{
InitializeComponent();
@@ -152,7 +156,10 @@ namespace SafeBagDE70
private bool InitSerialPorts()
{
var bInitDE70=InitSerialPortDE70();
var bInitSensor = InitSerialPortSensor();
if(isSensorActivated)
InitSerialPortSensor();
if (bInitDE70)
return true;
else
@@ -302,15 +309,15 @@ namespace SafeBagDE70
var state = GetCDMState();
if (state.IsNotesInEscrow > 0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", false, true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỀN RA KHỎI NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", false, true);
}
else if (state.IsNotesInRejectPocket > 0 || state.IsRejectPocketFull > 0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", false, true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỀN RA KHỎI NGĂN TIỀN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", false, true);
}
else if (state.IsNotesInHopper > 0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN NGĂN NỘP ĐỂ TIẾP TỤC", false, true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỀN RA KHỎI NGĂN NỘP ĐỂ TIẾP TỤC", false, true);
}
else if (state.IsCassetteFull != 0)
{
@@ -398,7 +405,9 @@ namespace SafeBagDE70
{
if (countSensorTimer % 10 == 0)
{
if(isPrinterActivated)
GetPrinterStatus();
GetCDMStatus();
AppData.GetandExecuteCommands();
@@ -416,6 +425,8 @@ namespace SafeBagDE70
}
countSensorTimer++;
sensorTimer.IsEnabled = false;
if (isSensorActivated)
GetSensorValue();
sensorTimer.IsEnabled = true;
}
@@ -425,7 +436,7 @@ namespace SafeBagDE70
}
sensorTimer.IsEnabled = true;
}
int nTry2Reset = 0;
private void GetCDMStatus()
{
if (!AppData.IsInTransaction)
@@ -437,14 +448,36 @@ namespace SafeBagDE70
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT;
AppData.DeviceStatus.Description = AppData.CDMSTATE.CDMStatus;
}
else if ((AppData.cCmdRsp.recv_dat.dat[18]&0xF0)==0xE0)
{
AppData.CDMSTATE.CDMStatus = "CDM: LỖI ABNORMAL STORAGE ERROR";
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.ERROR;
AppData.DeviceStatus.Description = AppData.CDMSTATE.CDMStatus;
}
else if (AppData.cCmdRsp.recv_dat.dat[1]==0x1C)
{
AppData.CDMSTATE.CDMStatus = "CDM: LỖI INITIALIZATION ERROR";
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.ERROR;
AppData.DeviceStatus.Description = AppData.CDMSTATE.CDMStatus;
if(nTry2Reset<2)
{
AppData.ResetCDMError();
nTry2Reset++;
AppData.GetCDMState();
var SR1 = AppData.cCmdRsp.recv_dat.dat[1];
if ((SR1 == 0x07) || (SR1 == 0x04))
{
AppData.CDMSTATE.CDMStatus = "CDM: LỖI INITIALIZATION ERROR --> RESET THÀNH CÔNG";
}
else
AppData.CDMSTATE.CDMStatus = "CDM: LỖI INITIALIZATION ERROR --> RESET KHÔNG THÀNH CÔNG";
}
}
else
{
nTry2Reset = 0;
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.NORMAL;
AppData.DeviceStatus.Description = AppData.CDMSTATE.CDMStatus;
}
@@ -1118,10 +1151,11 @@ namespace SafeBagDE70
Dispatcher.Invoke(() =>
{
var customerId = AppData.CurrentCustomerAccount == null ? "" : AppData.CurrentCustomerAccount.CustomerId;
str = $"PHIÊN GIAO DỊCH KHÔNG HỢP LỆ (SỐ TIỀN GIAO DỊCH KHÔNG KHỚP), VUI LÒNG BÁO CÁO LẠI CHI NHÁNH" +
$"\r\n MÃ GD: {AppData.GetTransactionCode()} " +
$"\r\nMÃ GD: {AppData.GetTransactionCode()} " +
$"\r\nMÁY: {Environment.MachineName}" +
$"\r\nMÃ NV: {AppData.CurrentCustomerAccount.CustomerId}";
$"\r\nMÃ NV: {customerId}";
Log.Information(str);
ShowError(str);
});
@@ -1202,17 +1236,17 @@ namespace SafeBagDE70
if (state.IsNotesInEscrow > 0)
{
btnEnd.IsEnabled = true;
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", true,true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỂN RA KHỎI NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", true,true);
}
else if (state.IsNotesInRejectPocket > 0 || state.IsRejectPocketFull > 0)
{
btnEnd.IsEnabled = true;
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", true, true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỂN RA KHỎI NGĂN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", true, true);
}
else if(state.IsNotesInHopper>0)
{
btnEnd.IsEnabled = true;
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN NGĂN NỘP ĐỂ TIẾP TỤC", true, true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỂN RA KHỎI NGĂN NỘP ĐỂ TIẾP TỤC", true, true);
}
else
{
@@ -1235,11 +1269,11 @@ namespace SafeBagDE70
InitLvCountItems();
if (state.IsNotesInEscrow > 0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỂN RA KHỎI NGĂN PHỤ HOẶC ẤN LƯU TRỮ ĐỂ TIẾP TỤC", true);
}
else if (state.IsNotesInRejectPocket > 0 || state.IsRejectPocketFull > 0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", true);
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỂN RA KHỎI NGĂN KHÔNG HỢP LỆ ĐỂ TIẾP TỤC", true);
}
else //if (double.Parse(lvCountItems[10].Value)== 0)
{
@@ -1284,6 +1318,8 @@ namespace SafeBagDE70
SyncData(data2Send);//Lưu CSDL và đồng bộ
//Reset all and ready to next session
if (isPrinterActivated)
{
if (printerFlag == true)
{
if (double.Parse(totalValue) > 0)
@@ -1291,6 +1327,8 @@ namespace SafeBagDE70
printerFlag = false;
}
}
String strNotify = $"BẠN VỪA THỰC HIỆN NỘP TIỀN VÀO MÁY CDM:\r\n"
+ $"SỐ LƯỢNG TỜ: {totalQuantity}\r\n"
@@ -1437,7 +1475,7 @@ namespace SafeBagDE70
}
else if (cdmState.IsNotesInEscrow != 0||cdmState.IsNotesInRejectPocket!=0||cdmState.IsNotesInHopper!=0)
{
mainWindow.ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG CÁC NGĂN ĐỂ TIẾP TỤC");
mainWindow.ShowInformationScreen("ĐỀ NGHỊ LẤY TIỀN RA KHỎI NGĂN NỘP HOẶC NGĂN REJECT ĐỂ TIẾP TỤC");
}
else
{