sendevent
This commit is contained in:
+122
-27
@@ -41,6 +41,7 @@ using Button = System.Windows.Controls.Button;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
using Application = System.Windows.Application;
|
||||
using Control = System.Windows.Controls.Control;
|
||||
using static Azure.Core.HttpHeader;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
@@ -94,10 +95,13 @@ namespace SafeBagDE70
|
||||
try
|
||||
{
|
||||
lblName.Content= "Vietinbank " + Environment.MachineName;
|
||||
string? transactionCode = null;
|
||||
if (AppData.IsAuthenticated)
|
||||
{
|
||||
transactionCode = AppData.GetTransactionCode();
|
||||
lblUser.Content = $"Xin chào khách hàng: {AppData.CurrentCustomerAccount.Name} (Gian hàng {AppData.CurrentCustomerAccount.CustomerId})";
|
||||
lblTransactionCode.Content = $"Mã GD: {AppData.CurrentCustomerAccount.TransactionCode}";
|
||||
|
||||
lblTransactionCode.Content = $"Mã GD: {transactionCode}";
|
||||
}
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
AppData.cCmdRsp = cCmdRsp;
|
||||
@@ -120,10 +124,20 @@ namespace SafeBagDE70
|
||||
StopTimers();
|
||||
ShowError(state.CDMStatus);
|
||||
}
|
||||
AppData.GetCassetteData();
|
||||
|
||||
var data= AppData.GetCassetteData();
|
||||
if (transactionCode != null)
|
||||
{
|
||||
|
||||
AppData.DeviceStatus.Description = $"[CASSETTE]" + AppData.GetNotesString(data);
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
Log.Fatal(ex, "LỖI CỔNG KẾT NỐI");
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
}
|
||||
|
||||
@@ -332,7 +346,8 @@ namespace SafeBagDE70
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
|
||||
int prevPrinterStatus = -1;
|
||||
int prevSensorStatus = -1;
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
sensorTimer.IsEnabled = false;
|
||||
@@ -344,22 +359,27 @@ namespace SafeBagDE70
|
||||
{
|
||||
|
||||
var status = printerManager.GetStatus();
|
||||
|
||||
var strPrinterMessage = "";
|
||||
if(status.StsNOPAPER)
|
||||
{
|
||||
AppData.DeviceStatus.PrinterStatus = (int)PrinterStatusCode.PAPEROUT;
|
||||
StopTimers();
|
||||
ShowError("MÁY IN HẾT GIẤY! ĐỀ NGHỊ THAY GIẤY");
|
||||
strPrinterMessage = "MÁY IN HẾT GIẤY! ĐỀ NGHỊ THAY GIẤY";
|
||||
ShowError(strPrinterMessage);
|
||||
}
|
||||
else if(status.StsNEARENDPAP)
|
||||
{
|
||||
strPrinterMessage = "MÁY IN GẦN HẾT GIẤY";
|
||||
AppData.DeviceStatus.PrinterStatus = (int)PrinterStatusCode.NEARPAPEROUT;
|
||||
}
|
||||
|
||||
if(AppData.DeviceStatus.PrinterStatus!= prevPrinterStatus)
|
||||
{
|
||||
AppData.DeviceStatus.Description = strPrinterMessage;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
prevPrinterStatus = AppData.DeviceStatus.PrinterStatus;
|
||||
}
|
||||
AppData.DeviceStatus.Description = AppData.CDMSTATE.CDMStatus;
|
||||
AppData.DeviceStatus.DeviceTime = DateTime.Now;
|
||||
|
||||
|
||||
APIModels.SendHealthCheck(AppData.DeviceStatus);
|
||||
}
|
||||
|
||||
@@ -403,21 +423,29 @@ namespace SafeBagDE70
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
string strSensorMessage = "";
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: ĐÓNG";
|
||||
strSensorMessage = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: MỞ";
|
||||
strSensorMessage = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: ĐÓNG";
|
||||
strSensorMessage = "NGĂN KÉT: MỞ, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: MỞ";
|
||||
strSensorMessage = "NGĂN KÉT: MỞ, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
}
|
||||
lblStatus.Content = strSensorMessage;
|
||||
if (state!=prevSensorStatus)
|
||||
{
|
||||
AppData.DeviceStatus.Description=strSensorMessage;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
prevSensorStatus = state;
|
||||
}
|
||||
if (state > 0)
|
||||
{
|
||||
if (!bIsMaintain)
|
||||
@@ -425,7 +453,6 @@ namespace SafeBagDE70
|
||||
bIsMaintain = true;
|
||||
DoMaintaince();
|
||||
}
|
||||
|
||||
// TransitionToState("Maintainance");
|
||||
}
|
||||
else
|
||||
@@ -587,6 +614,30 @@ namespace SafeBagDE70
|
||||
{
|
||||
return JsonConvert.SerializeObject(lvCountItems);
|
||||
}
|
||||
private string GetQuantityFromSessions(List<CountSession> countSessions,bool? btoreFlag=null)
|
||||
{
|
||||
var quantFromSession = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };//500.000->500
|
||||
foreach (var session in countSessions)
|
||||
{
|
||||
if(btoreFlag == null)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
quantFromSession[i] += session.QuantityDenomi[i];
|
||||
}
|
||||
else if ((session.IsStored == btoreFlag))
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
quantFromSession[i] += session.QuantityDenomi[i];
|
||||
}
|
||||
}
|
||||
string str = "";
|
||||
for (int i = 0; i < quantFromSession.Length; i++)
|
||||
{
|
||||
str += quantFromSession[i] + ",";
|
||||
}
|
||||
str = str.Trim(',');
|
||||
return str;
|
||||
}
|
||||
|
||||
private bool DoCountStart()
|
||||
{
|
||||
@@ -614,12 +665,24 @@ namespace SafeBagDE70
|
||||
|
||||
taskCounting = Task.Run(() =>
|
||||
{
|
||||
var str = "BEFORE COUNT";
|
||||
str+="\r\nSTORED: "+ GetQuantityFromSessions(sessions,true);
|
||||
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
|
||||
AppData.DeviceStatus.Description = str;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
|
||||
Log.Information("Before AutoCount: " + GetShortInforFromCountItems());
|
||||
bIsCounted = false;
|
||||
AutoSerialGet();
|
||||
bIsCounted = true;
|
||||
Log.Information("After AutoCount: " + GetShortInforFromCountItems());
|
||||
|
||||
|
||||
str = "AFTER COUNT";
|
||||
str+= "\r\nSTORED: " + GetQuantityFromSessions(sessions, true);
|
||||
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
|
||||
AppData.DeviceStatus.Description = str;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -754,6 +817,12 @@ namespace SafeBagDE70
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
var str = "BEFORE CHECK";
|
||||
str += "\r\nSTORED: " + GetQuantityFromSessions(sessions, true);
|
||||
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
|
||||
AppData.DeviceStatus.Description = str;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
|
||||
Log.Information("Before Check: "+GetShortInforFromCountItems());
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
@@ -768,6 +837,12 @@ namespace SafeBagDE70
|
||||
|
||||
|
||||
Log.Information("After Check: "+GetShortInforFromCountItems());
|
||||
|
||||
str = "AFTER CHECK";
|
||||
str += "\r\nSTORED: " + GetQuantityFromSessions(sessions, true);
|
||||
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
|
||||
AppData.DeviceStatus.Description = str;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -835,11 +910,23 @@ namespace SafeBagDE70
|
||||
//Debug.WriteLine(quantityStored);
|
||||
|
||||
var previousCassetData = AppData.GetCassetteData();
|
||||
if(CheckPreStoreValid(previousCassetData, AppData.MaxNotes, sessions))
|
||||
|
||||
var str = "BEFORE STORE [CASSETTE]" + AppData.GetNotesString(previousCassetData);
|
||||
str += "\r\nSTORED: " + GetQuantityFromSessions(sessions, true);
|
||||
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
|
||||
|
||||
AppData.DeviceStatus.Description = str;
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
|
||||
if (CheckPreStoreValid(previousCassetData, AppData.MaxNotes, sessions))
|
||||
{
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
bSuccess = WaitUntilCountReady(10);
|
||||
var newCasstData = AppData.GetCassetteData();
|
||||
|
||||
AppData.DeviceStatus.Description = "AFTER STORE [CASSETTE]" + AppData.GetNotesString(newCasstData);
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
|
||||
bool bValid = CheckStoreValid(previousCassetData, newCasstData, sessions);
|
||||
if (bValid)
|
||||
{
|
||||
@@ -859,16 +946,15 @@ namespace SafeBagDE70
|
||||
}
|
||||
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";
|
||||
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
|
||||
{
|
||||
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";
|
||||
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);
|
||||
@@ -911,6 +997,10 @@ namespace SafeBagDE70
|
||||
if (cCmdRsp.recv_dat.dat[0]!=0x40)
|
||||
{
|
||||
bSuccess = false;
|
||||
|
||||
var state = GetCDMState();
|
||||
AppData.DeviceStatus.Description = "START_ERROR:" + state.GetFullStatus();
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -997,11 +1087,14 @@ namespace SafeBagDE70
|
||||
Log.Information(currentMethod);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
|
||||
|
||||
if (double.Parse(totalValue) > 0)
|
||||
{
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
TransactionCode = AppData.CurrentCustomerAccount.TransactionCode,
|
||||
TransactionCode = AppData.GetTransactionCode(),
|
||||
Sessions = sessions,
|
||||
MachineId = Environment.MachineName,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
@@ -1027,7 +1120,7 @@ namespace SafeBagDE70
|
||||
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
||||
if (AppData.CurrentCustomerAccount != null)
|
||||
{
|
||||
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
||||
var strTransactionCode = AppData.GetTransactionCode();
|
||||
strNotify = "MÃ GD: "+strTransactionCode + "\r\n" + strNotify;
|
||||
|
||||
}
|
||||
@@ -1048,7 +1141,7 @@ namespace SafeBagDE70
|
||||
var strNotify = "";
|
||||
if (AppData.CurrentCustomerAccount != null)
|
||||
{
|
||||
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
||||
var strTransactionCode = AppData.GetTransactionCode();
|
||||
strNotify = "MÃ GD: "+strTransactionCode + "\r\n" + strNotify;
|
||||
|
||||
}
|
||||
@@ -1067,6 +1160,8 @@ namespace SafeBagDE70
|
||||
{
|
||||
mainWindow.ShowWelcomeScreen();
|
||||
}
|
||||
if (AppData.CurrentCustomerAccount != null)
|
||||
AppData.CurrentCustomerAccount.TransactionCode = "";
|
||||
//SendData2Server
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1193,7 +1288,7 @@ namespace SafeBagDE70
|
||||
Log.Information("PrintReceipt");
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = AppData.CurrentCustomerAccount.TransactionCode;// "TRA04052024CDM";
|
||||
var tradingCode = AppData.GetTransactionCode();// "TRA04052024CDM";
|
||||
var storeAccountNumber = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
@@ -1324,17 +1419,15 @@ namespace SafeBagDE70
|
||||
{
|
||||
btnCountStart.IsEnabled = true;
|
||||
ResetTimers();
|
||||
Log.Information("1. Start completed");
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStart.IsEnabled = true;
|
||||
btnLogout.IsEnabled = true;
|
||||
}
|
||||
if (bResult)
|
||||
Log.Information("1. Start completed");
|
||||
else
|
||||
Log.Information("1. Start failed");
|
||||
|
||||
Log.Information("1. Start failed");
|
||||
}
|
||||
}
|
||||
else if(btn==btnCountStart)
|
||||
{
|
||||
@@ -1350,6 +1443,8 @@ namespace SafeBagDE70
|
||||
{
|
||||
string str = "ĐÃ XẢY RA LỖI TRONG QUÁ TRÌNH NỘP TIỀN";
|
||||
Log.Information(str);
|
||||
AppData.DeviceStatus.Description = "COUNT_ERROR:"+state.GetFullStatus();
|
||||
APIModels.SendEvent(AppData.DeviceStatus);
|
||||
DoCheck();
|
||||
EndSession(COUNTINGSTATE.FULLIFSTORE, str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user