This commit is contained in:
thuannd88
2024-09-06 10:15:39 +07:00
parent 7e927dfcc9
commit 8fb4e9ae92
8 changed files with 55 additions and 29 deletions
+4 -5
View File
@@ -19,7 +19,6 @@ namespace SafeBagDE70.API
{ {
public static class APIModels public static class APIModels
{ {
public static string URL = "http://203.171.20.94:9103/Safebag/";
public static async void SendHealthCheck_old(string? ID=null) public static async void SendHealthCheck_old(string? ID=null)
{ {
try try
@@ -30,7 +29,7 @@ namespace SafeBagDE70.API
// Pass the handler to httpclient(from you are calling api) // Pass the handler to httpclient(from you are calling api)
HttpClient httpClient = new HttpClient(clientHandler); HttpClient httpClient = new HttpClient(clientHandler);
using HttpResponseMessage response = await httpClient.GetAsync(URL + "HealthCheck?Id=" + ID); using HttpResponseMessage response = await httpClient.GetAsync(AppData.BaseURL + "HealthCheck?Id=" + ID);
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK) if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
{ {
@@ -57,7 +56,7 @@ namespace SafeBagDE70.API
string strJsonObj = JsonConvert.SerializeObject(deviceStatus); string strJsonObj = JsonConvert.SerializeObject(deviceStatus);
var content = new StringContent(strJsonObj, Encoding.UTF8, "application/json"); var content = new StringContent(strJsonObj, Encoding.UTF8, "application/json");
using HttpResponseMessage response = await httpClient.PostAsync(URL + "HealthCheck_v2", content); using HttpResponseMessage response = await httpClient.PostAsync(AppData.BaseURL + "HealthCheck_v2", content);
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK) if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
{ {
@@ -86,7 +85,7 @@ namespace SafeBagDE70.API
string strJsonObj = JsonConvert.SerializeObject(data2Send); string strJsonObj = JsonConvert.SerializeObject(data2Send);
var content = new StringContent(strJsonObj, Encoding.UTF8, "application/json"); var content = new StringContent(strJsonObj, Encoding.UTF8, "application/json");
using HttpResponseMessage response = await httpClient.PostAsync(URL + "UpdateCountingData", content); using HttpResponseMessage response = await httpClient.PostAsync(AppData.BaseURL + "UpdateCountingData", content);
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK) if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
{ {
@@ -105,7 +104,7 @@ namespace SafeBagDE70.API
{ {
try try
{ {
var url = URL + "GetAeonMallCustomers?tenantId="+tenantId; var url = AppData.BaseURL + "GetAeonMallCustomers?tenantId="+tenantId;
HttpClientHandler clientHandler = new HttpClientHandler(); HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; }; clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
+1 -1
View File
@@ -40,7 +40,7 @@ namespace SafeBagDE70.Admin
private async void btnGetUsers_Click(object sender, RoutedEventArgs e) private async void btnGetUsers_Click(object sender, RoutedEventArgs e)
{ {
var amCustomers= await APIModels.GetAeonMallCustomers(5); var amCustomers= await APIModels.GetAeonMallCustomers(AppData.TenantId);
using(var context = new CDMDbContext()) using(var context = new CDMDbContext())
{ {
var customers = context.Customers; var customers = context.Customers;
+2
View File
@@ -69,6 +69,8 @@ namespace SafeBagDE70
.CreateLogger(); .CreateLogger();
AppData.CDMPort = configuration["SerialPort:CDMPort"]; AppData.CDMPort = configuration["SerialPort:CDMPort"];
AppData.SensorPort = configuration["SerialPort:SensorPort"]; AppData.SensorPort = configuration["SerialPort:SensorPort"];
AppData.BaseURL = configuration["Device:BaseURL"];
AppData.TenantId = int.Parse("0" + configuration["Device:TenantId"]);
var maxNotes = int.Parse("0"+configuration["CDM:MaxNotes"]); var maxNotes = int.Parse("0"+configuration["CDM:MaxNotes"]);
if(maxNotes > 0) if(maxNotes > 0)
AppData.MaxNotes = maxNotes; AppData.MaxNotes = maxNotes;
+11 -4
View File
@@ -10,6 +10,7 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Controls; using System.Windows.Controls;
@@ -30,7 +31,10 @@ namespace SafeBagDE70
public static ListView logListView = null; public static ListView logListView = null;
public static int MaxLogCount = 500; public static int MaxLogCount = 500;
public static int MaxNotes = 300; public static int MaxNotes = 300;
public static string BaseURL = "";
public static int TenantId = 0;
public static DeviceStatus? DeviceStatus = null; public static DeviceStatus? DeviceStatus = null;
public static void Init() public static void Init()
{ {
@@ -55,7 +59,7 @@ namespace SafeBagDE70
DeviceStatus = new DeviceStatus DeviceStatus = new DeviceStatus
{ {
Device = Environment.MachineName, Device = Environment.MachineName,
TenantId = 5, TenantId = AppData.TenantId,
Status = 0, Status = 0,
CDMStatus = 0, CDMStatus = 0,
PrinterStatus = 0, PrinterStatus = 0,
@@ -70,8 +74,9 @@ namespace SafeBagDE70
public static void GetNewTransactionCode() public static void GetNewTransactionCode()
{ {
DateTime transactionDateTime = DateTime.Now; DateTime transactionDateTime = DateTime.Now;
string merchantCode = CurrentCustomerAccount.CustomerId;
var match = Regex.Match(CurrentCustomerAccount.CustomerId, @"\d+$");
string merchantCode_part = match.Value;
// Adjust transaction date if it's past cut-off time (12:00 noon) // Adjust transaction date if it's past cut-off time (12:00 noon)
DateTime prevadjustedDate = CurrentCustomerAccount.TransactionTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1); DateTime prevadjustedDate = CurrentCustomerAccount.TransactionTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
@@ -90,7 +95,7 @@ namespace SafeBagDE70
string transactionCountPart = transactionCount.ToString("D2"); // Ensure 2 digits string transactionCountPart = transactionCount.ToString("D2"); // Ensure 2 digits
// Combine all parts to form the transaction ID // Combine all parts to form the transaction ID
string transactionId = $"{datePart}{timePart}{merchantCode}{transactionCountPart}"; string transactionId = $"{datePart}{timePart}{merchantCode_part}{transactionCountPart}";
CurrentCustomerAccount.TransactionCode = transactionId; CurrentCustomerAccount.TransactionCode = transactionId;
CurrentCustomerAccount.TransactionTime = transactionDateTime; CurrentCustomerAccount.TransactionTime = transactionDateTime;
@@ -114,8 +119,9 @@ namespace SafeBagDE70
AppData.CDMSTATE.IsRejectPocketFull = data[3] & 0x40; AppData.CDMSTATE.IsRejectPocketFull = data[3] & 0x40;
AppData.CDMSTATE.IsNotesInRejectPocket = data[3] & 0x10; AppData.CDMSTATE.IsNotesInRejectPocket = data[3] & 0x10;
AppData.CDMSTATE.IsNotesInHopper = data[3] & 0x01; AppData.CDMSTATE.IsNotesInHopper = data[3] & 0x01;
AppData.CDMSTATE.IsStackerFull = (data[2] == 0x43?1:0);
if (data[0] == 0x40 && data[1] == 0x07 && data[2] == 0x41) if (data[0] == 0x40 && data[1] == 0x07)
AppData.CDMSTATE.IsError = 0; AppData.CDMSTATE.IsError = 0;
else else
AppData.CDMSTATE.IsError = 1; AppData.CDMSTATE.IsError = 1;
@@ -270,6 +276,7 @@ namespace SafeBagDE70
public int IsRejectPocketFull = 0; public int IsRejectPocketFull = 0;
public int IsNotesInRejectPocket = 0; public int IsNotesInRejectPocket = 0;
public int IsNotesInHopper = 0; public int IsNotesInHopper = 0;
public int IsStackerFull = 0;
public int IsError = 0; public int IsError = 0;
public RecvData? RecvDat = null; public RecvData? RecvDat = null;
public byte GetSR1() public byte GetSR1()
+2 -2
View File
@@ -108,7 +108,7 @@
{ {
SendDataSet(); SendDataSet();
send_dat.ret = SendData(); send_dat.ret = SendData();
Log.Information("[CMD_SEND] " + GetSendDat(false)); //Log.Information("[CMD_SEND] " + GetSendDat(false));
if (send_dat.ret != Constants.E_OK) if (send_dat.ret != Constants.E_OK)
{ {
@@ -117,7 +117,7 @@
} }
recv_dat.ret = WaitRsp(); recv_dat.ret = WaitRsp();
Log.Information("[CMD_RCV] " +GetRecvDat()); //Log.Information("[CMD_RCV] " +GetRecvDat());
if (recv_dat.ret != Constants.E_OK) if (recv_dat.ret != Constants.E_OK)
{ {
+29 -15
View File
@@ -619,14 +619,7 @@ namespace SafeBagDE70
AutoSerialGet(); AutoSerialGet();
bIsCounted = true; bIsCounted = true;
Log.Information("After AutoCount: " + GetShortInforFromCountItems()); Log.Information("After AutoCount: " + GetShortInforFromCountItems());
var state=GetCDMState();
if (state.IsError>0)
{
string str = "ĐÃ XẢY RA LỖI TRONG QUÁ TRÌNH NỘP TIỀN";
Log.Information(str);
DoCheck();
EndSession(COUNTINGSTATE.FULLIFSTORE, str);
}
}); });
@@ -1352,14 +1345,35 @@ namespace SafeBagDE70
Task.Run(() => Task.Run(() =>
{ {
taskCounting.Wait(); taskCounting.Wait();
Dispatcher.Invoke(() => var state = GetCDMState();
if (state.IsError > 0)
{ {
btnCountStart.IsEnabled = true; string str = "ĐÃ XẢY RA LỖI TRONG QUÁ TRÌNH NỘP TIỀN";
btnCheck.IsEnabled = true; Log.Information(str);
btnStoreStart.IsEnabled = true; DoCheck();
ResetTimers(); EndSession(COUNTINGSTATE.FULLIFSTORE, str);
Log.Information("2. Count completed"); }
}); else if (state.IsStackerFull>0) {
Dispatcher.Invoke(() =>
{
btnCheck.IsEnabled = true;
btnStoreStart.IsEnabled = true;
ResetTimers();
Log.Information("2. Count completed");
});
}
else
{
Dispatcher.Invoke(() =>
{
btnCountStart.IsEnabled = true;
btnCheck.IsEnabled = true;
btnStoreStart.IsEnabled = true;
ResetTimers();
Log.Information("2. Count completed");
});
}
}); });
+1 -1
View File
@@ -39,7 +39,7 @@
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel"> <StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel">
<TextBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/> <TextBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/>
<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/> <!--<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/>-->
<Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/> <Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/>
<Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" /> <Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
</StackPanel> </StackPanel>
+4
View File
@@ -17,6 +17,10 @@
"CDM": { "CDM": {
"MaxNotes": 300 "MaxNotes": 300
}, },
"Device": {
"BaseURL": "http://203.171.20.94:9103/Safebag/",
"TenantId": 5
},
"StateMachine": { "StateMachine": {
"States": [ "States": [
"Start", "Start",