fix
This commit is contained in:
@@ -68,12 +68,13 @@ namespace SafeBagDE70.Admin
|
|||||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(5000);
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
lblCounterStatus.Text = "";
|
lblCounterStatus.Text = "";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
AppData.GetCassetteData();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -116,29 +117,30 @@ namespace SafeBagDE70.Admin
|
|||||||
{
|
{
|
||||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||||
}
|
}
|
||||||
if (cCmdRsp.recv_dat.dat[0] != 0x40)
|
//if (cCmdRsp.recv_dat.dat[0] != 0x40)
|
||||||
|
//{
|
||||||
|
// bSuccess = false;
|
||||||
|
//}
|
||||||
|
//if (bSuccess)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET);
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||||
|
if (cCmdRsp.recv_dat.dat[1] == 0x04 && cCmdRsp.recv_dat.dat[2] == 0x41)
|
||||||
{
|
{
|
||||||
bSuccess = false;
|
lblCounterStatus.Text = "Reset lỗi thành công";
|
||||||
}
|
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||||
if (bSuccess)
|
Task.Run(() =>
|
||||||
{
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET);
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
|
||||||
if (cCmdRsp.recv_dat.dat[1] == 0x04 && cCmdRsp.recv_dat.dat[2] == 0x41)
|
|
||||||
{
|
{
|
||||||
lblCounterStatus.Text = "Reset lỗi thành công";
|
Thread.Sleep(2000);
|
||||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
Dispatcher.Invoke(() =>
|
||||||
Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
Thread.Sleep(2000);
|
lblCounterStatus.Text = "";
|
||||||
Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblCounterStatus.Text = "";
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-2
@@ -53,7 +53,7 @@ namespace SafeBagDE70
|
|||||||
CDMStatus = 0,
|
CDMStatus = 0,
|
||||||
PrinterStatus = 0,
|
PrinterStatus = 0,
|
||||||
SensorStatus = 0,
|
SensorStatus = 0,
|
||||||
Notes = 0,
|
Notes = "",
|
||||||
OtherError = 0,
|
OtherError = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -121,6 +121,36 @@ namespace SafeBagDE70
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static byte[] GetCassetteData()
|
||||||
|
{
|
||||||
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_READ_CASSETTE);
|
||||||
|
var data = cCmdRsp.recv_dat.dat;
|
||||||
|
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
var recv_dat = cCmdRsp.recv_dat;
|
||||||
|
|
||||||
|
AppData.DeviceStatus.Notes = GetNotesString(recv_dat.dat);
|
||||||
|
str.Append("DATA:");
|
||||||
|
for (int i = 0; i < recv_dat.leng - 1; i++)
|
||||||
|
{
|
||||||
|
var dat = string.Format("{0:X2} ", recv_dat.dat[i]);
|
||||||
|
str.Append(dat);
|
||||||
|
}
|
||||||
|
Log.Information("[CASSETTE]" + str.ToString());
|
||||||
|
return (byte[])data.Clone();
|
||||||
|
}
|
||||||
|
public static string GetNotesString(byte[] cassetData)
|
||||||
|
{
|
||||||
|
int notes = 0;
|
||||||
|
int offset = 14;
|
||||||
|
string str = "";
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
notes = cassetData[2 * i + offset] * 256 + cassetData[2 * i + 1 + offset];
|
||||||
|
str += notes + ",";
|
||||||
|
}
|
||||||
|
return str.Trim(',');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public class CustomerAccount
|
public class CustomerAccount
|
||||||
@@ -215,6 +245,12 @@ namespace SafeBagDE70
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public enum COUNTINGSTATE
|
||||||
|
{
|
||||||
|
NORMAL=0,
|
||||||
|
AUTOEND=1,
|
||||||
|
FULLIFSTORE=2
|
||||||
|
}
|
||||||
public class CDMSTATE : INotifyPropertyChanged
|
public class CDMSTATE : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public int IsCassetteFull = 0;
|
public int IsCassetteFull = 0;
|
||||||
@@ -336,7 +372,7 @@ namespace SafeBagDE70
|
|||||||
public int PrinterStatus { get; set; }
|
public int PrinterStatus { get; set; }
|
||||||
public int SensorStatus { get; set; }
|
public int SensorStatus { get; set; }
|
||||||
public int OtherError { get; set; }
|
public int OtherError { get; set; }
|
||||||
public int? Notes { get; set; }
|
public string? Notes { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
}
|
}
|
||||||
public enum DeviceStatusCode {
|
public enum DeviceStatusCode {
|
||||||
|
|||||||
+107
-75
@@ -120,7 +120,7 @@ namespace SafeBagDE70
|
|||||||
StopTimers();
|
StopTimers();
|
||||||
ShowError(state.CDMStatus);
|
ShowError(state.CDMStatus);
|
||||||
}
|
}
|
||||||
GetCassetteData();
|
AppData.GetCassetteData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -231,7 +231,7 @@ namespace SafeBagDE70
|
|||||||
DoStoreStart();
|
DoStoreStart();
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
EndSession(1);
|
EndSession(COUNTINGSTATE.AUTOEND,"Tự động kết thúc");
|
||||||
});
|
});
|
||||||
Log.Information("7. Timout completed");
|
Log.Information("7. Timout completed");
|
||||||
});
|
});
|
||||||
@@ -631,24 +631,7 @@ namespace SafeBagDE70
|
|||||||
}
|
}
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
private byte[] GetCassetteData()
|
|
||||||
{
|
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_READ_CASSETTE);
|
|
||||||
var data=cCmdRsp.recv_dat.dat;
|
|
||||||
|
|
||||||
StringBuilder str=new StringBuilder();
|
|
||||||
var recv_dat = cCmdRsp.recv_dat;
|
|
||||||
|
|
||||||
AppData.DeviceStatus.Notes = GetNotes(recv_dat.dat);
|
|
||||||
str.Append("DATA:");
|
|
||||||
for (int i = 0; i < recv_dat.leng - 1; i++)
|
|
||||||
{
|
|
||||||
var dat = string.Format("{0:X2} ", recv_dat.dat[i]);
|
|
||||||
str.Append(dat);
|
|
||||||
}
|
|
||||||
Log.Information("[CASSETTE]" + str.ToString());
|
|
||||||
return (byte[])data.Clone();
|
|
||||||
}
|
|
||||||
private int GetNotes(byte[] cassetData)
|
private int GetNotes(byte[] cassetData)
|
||||||
{
|
{
|
||||||
int notes = 0;
|
int notes = 0;
|
||||||
@@ -659,6 +642,7 @@ namespace SafeBagDE70
|
|||||||
}
|
}
|
||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckStoreValid(byte[] previousCassetData, byte[] newCassetData,List<CountSession> countSessions)
|
private bool CheckStoreValid(byte[] previousCassetData, byte[] newCassetData,List<CountSession> countSessions)
|
||||||
{
|
{
|
||||||
var quantFromSession = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };//500.000->500
|
var quantFromSession = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };//500.000->500
|
||||||
@@ -686,54 +670,80 @@ namespace SafeBagDE70
|
|||||||
return bValid;
|
return bValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckPreStoreValid(byte[] previousCassetData, int maxNotes, List<CountSession> countSessions)
|
||||||
|
{
|
||||||
|
var quantFromSession = 0;//500.000->500
|
||||||
|
var quantFromCasset = 0;
|
||||||
|
bool bValid = true;
|
||||||
|
foreach (var session in countSessions)
|
||||||
|
{
|
||||||
|
if ((session.IsStored == false))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
quantFromSession += session.QuantityDenomi[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int offset = 14;
|
||||||
|
for (int i=0;i<10; i++)
|
||||||
|
{
|
||||||
|
quantFromCasset += previousCassetData[2 * i + offset] * 256 + previousCassetData[2 * i + 1 + offset];
|
||||||
|
}
|
||||||
|
if (quantFromCasset + quantFromSession > maxNotes)
|
||||||
|
bValid = false;
|
||||||
|
return bValid;
|
||||||
|
}
|
||||||
private void UpdateListViewCountItems()
|
private void UpdateListViewCountItems()
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(DispatcherPriority.Normal, () =>
|
Dispatcher.Invoke(DispatcherPriority.Normal, () =>
|
||||||
{
|
{
|
||||||
double sum = 0;
|
if (lvCountItems != null && lvCountItems.Count > 0)
|
||||||
if (sessions != null && sessions.Count > 0)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
double sum = 0;
|
||||||
|
if (sessions != null && sessions.Count > 0)
|
||||||
{
|
{
|
||||||
int quantity = 0;
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
int quantity = 0;
|
||||||
|
for (int j = 0; j < sessions.Count; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
quantity += sessions[j].QuantityDenomi[9 - i];
|
||||||
|
|
||||||
|
}
|
||||||
|
lvCountItems[i].Quantity = quantity.ToString();
|
||||||
|
sum += lvCountItems[i].getValue();
|
||||||
|
|
||||||
|
}
|
||||||
|
//Update amount of money
|
||||||
|
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||||
|
lvCountItems[10].Value = sum.ToString();
|
||||||
|
|
||||||
|
//Update Notes In Sesion
|
||||||
|
notesInSession.GenuineNotes = 0;
|
||||||
|
notesInSession.RejectNotes = 0;
|
||||||
|
|
||||||
for (int j = 0; j < sessions.Count; j++)
|
for (int j = 0; j < sessions.Count; j++)
|
||||||
{
|
{
|
||||||
|
if (sessions[j].IsStored == false)
|
||||||
quantity += sessions[j].QuantityDenomi[9 - i];
|
|
||||||
|
|
||||||
}
|
|
||||||
lvCountItems[i].Quantity = quantity.ToString();
|
|
||||||
sum += lvCountItems[i].getValue();
|
|
||||||
|
|
||||||
}
|
|
||||||
//Update amount of money
|
|
||||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
|
||||||
lvCountItems[10].Value = sum.ToString();
|
|
||||||
|
|
||||||
//Update Notes In Sesion
|
|
||||||
notesInSession.GenuineNotes = 0;
|
|
||||||
notesInSession.RejectNotes = 0;
|
|
||||||
|
|
||||||
for (int j = 0; j < sessions.Count; j++)
|
|
||||||
{
|
|
||||||
if (sessions[j].IsStored == false)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
{
|
||||||
notesInSession.GenuineNotes += sessions[j].QuantityDenomi[9 - i];
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
notesInSession.GenuineNotes += sessions[j].QuantityDenomi[9 - i];
|
||||||
|
}
|
||||||
|
notesInSession.RejectNotes += sessions[j].TempNotes.Sum();
|
||||||
}
|
}
|
||||||
notesInSession.RejectNotes += sessions[j].TempNotes.Sum();
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 11; i++)
|
||||||
|
{
|
||||||
|
lvCountItems[i].Quantity = "0";
|
||||||
|
lvCountItems[i].Value = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 11; i++)
|
|
||||||
{
|
|
||||||
lvCountItems[i].Quantity = "0";
|
|
||||||
lvCountItems[i].Value = "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -824,35 +834,46 @@ namespace SafeBagDE70
|
|||||||
|
|
||||||
//Debug.WriteLine(quantityStored);
|
//Debug.WriteLine(quantityStored);
|
||||||
|
|
||||||
var previousCassetData = GetCassetteData();
|
var previousCassetData = AppData.GetCassetteData();
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
if(CheckPreStoreValid(previousCassetData,300,sessions))
|
||||||
bSuccess=WaitUntilCountReady(10);
|
|
||||||
var newCasstData = GetCassetteData();
|
|
||||||
bool bValid= CheckStoreValid(previousCassetData,newCasstData,sessions);
|
|
||||||
if(bValid)
|
|
||||||
{
|
{
|
||||||
if (bSuccess)
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||||
|
bSuccess = WaitUntilCountReady(10);
|
||||||
|
var newCasstData = AppData.GetCassetteData();
|
||||||
|
bool bValid = CheckStoreValid(previousCassetData, newCasstData, sessions);
|
||||||
|
if (bValid)
|
||||||
{
|
{
|
||||||
foreach (var item in sessions)
|
if (bSuccess)
|
||||||
{
|
{
|
||||||
item.IsStored = true;
|
foreach (var item in sessions)
|
||||||
|
{
|
||||||
|
item.IsStored = true;
|
||||||
|
}
|
||||||
|
quantityStored = UpdateTotalQuantity();
|
||||||
|
Log.Information("Stored " + GetShortInforFromCountItems());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Error("Store FAIL " + GetShortInforFromCountItems());
|
||||||
}
|
}
|
||||||
quantityStored = UpdateTotalQuantity();
|
|
||||||
Log.Information("Stored " + GetShortInforFromCountItems());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Error("Store FAIL " + GetShortInforFromCountItems());
|
string 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";
|
||||||
|
Log.Information(str);
|
||||||
|
ShowError(str);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string 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";
|
string str = "KÉT ĐÃ ĐẦY ĐỀ NGHỊ LẤY LẠI TIỀN VÀ KẾT THÚC GIAO DỊCH, VUI LÒNG BÁO CÁO LẠI CHI NHÁNH";
|
||||||
Log.Information(str);
|
Log.Information(str);
|
||||||
ShowError(str);
|
DoCheck();
|
||||||
}
|
EndSession(COUNTINGSTATE.FULLIFSTORE,str);
|
||||||
|
}
|
||||||
Thread.Sleep(2000);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -959,7 +980,7 @@ namespace SafeBagDE70
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndSession(int _CountingState=0)
|
private void EndSession(COUNTINGSTATE _CountingState =0, string? strMessage=null)
|
||||||
{
|
{
|
||||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||||
|
|
||||||
@@ -986,7 +1007,7 @@ namespace SafeBagDE70
|
|||||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||||
GenuineNotes = quantityStored,
|
GenuineNotes = quantityStored,
|
||||||
CountingState= _CountingState
|
CountingState= (int)_CountingState
|
||||||
};
|
};
|
||||||
|
|
||||||
SyncData(data2Send);
|
SyncData(data2Send);
|
||||||
@@ -1000,9 +1021,20 @@ namespace SafeBagDE70
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String strNotify = $"BẠN VỪA THỰC HIỆN NỘP TIỀN VÀO MÁY CDM:\r\n"
|
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"
|
+ $"SỐ LƯỢNG TỜ: {totalQuantity}\r\n"
|
||||||
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
||||||
|
if (AppData.CurrentCustomerAccount != null)
|
||||||
|
{
|
||||||
|
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
||||||
|
strNotify = strTransactionCode + "\r\n" + strNotify;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(strMessage!=null)
|
||||||
|
{
|
||||||
|
strNotify += strMessage;
|
||||||
|
}
|
||||||
mainWindow.ShowInformationScreen(strNotify, false, false);
|
mainWindow.ShowInformationScreen(strNotify, false, false);
|
||||||
ResetSessions();
|
ResetSessions();
|
||||||
StartWelcomeTimer();
|
StartWelcomeTimer();
|
||||||
|
|||||||
Reference in New Issue
Block a user