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,12 +117,14 @@ 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;
|
// bSuccess = false;
|
||||||
}
|
//}
|
||||||
if (bSuccess)
|
//if (bSuccess)
|
||||||
{
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET);
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET);
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
@@ -141,7 +144,6 @@ namespace SafeBagDE70.Admin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Log.Fatal(ex, "SoftReset");
|
Log.Fatal(ex, "SoftReset");
|
||||||
}
|
}
|
||||||
|
|||||||
+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 {
|
||||||
|
|||||||
+59
-27
@@ -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,9 +670,33 @@ 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, () =>
|
||||||
|
{
|
||||||
|
if (lvCountItems != null && lvCountItems.Count > 0)
|
||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
if (sessions != null && sessions.Count > 0)
|
if (sessions != null && sessions.Count > 0)
|
||||||
@@ -734,6 +742,8 @@ namespace SafeBagDE70
|
|||||||
lvCountItems[i].Value = "0";
|
lvCountItems[i].Value = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -824,12 +834,14 @@ namespace SafeBagDE70
|
|||||||
|
|
||||||
//Debug.WriteLine(quantityStored);
|
//Debug.WriteLine(quantityStored);
|
||||||
|
|
||||||
var previousCassetData = GetCassetteData();
|
var previousCassetData = AppData.GetCassetteData();
|
||||||
|
if(CheckPreStoreValid(previousCassetData,300,sessions))
|
||||||
|
{
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||||
bSuccess=WaitUntilCountReady(10);
|
bSuccess = WaitUntilCountReady(10);
|
||||||
var newCasstData = GetCassetteData();
|
var newCasstData = AppData.GetCassetteData();
|
||||||
bool bValid= CheckStoreValid(previousCassetData,newCasstData,sessions);
|
bool bValid = CheckStoreValid(previousCassetData, newCasstData, sessions);
|
||||||
if(bValid)
|
if (bValid)
|
||||||
{
|
{
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
{
|
{
|
||||||
@@ -852,7 +864,16 @@ namespace SafeBagDE70
|
|||||||
ShowError(str);
|
ShowError(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
DoCheck();
|
||||||
|
EndSession(COUNTINGSTATE.FULLIFSTORE,str);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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