fix bugs
This commit is contained in:
@@ -12,6 +12,8 @@ using System.Text.Json.Serialization;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace SafeBagDE70.API
|
namespace SafeBagDE70.API
|
||||||
{
|
{
|
||||||
@@ -99,7 +101,37 @@ namespace SafeBagDE70.API
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static async Task<List<AeonMallCustomer>> GetAeonMallCustomers(int tenantId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = URL + "GetAeonMallCustomers?tenantId="+tenantId;
|
||||||
|
HttpClientHandler clientHandler = new HttpClientHandler();
|
||||||
|
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
|
||||||
|
|
||||||
|
// Pass the handler to httpclient(from you are calling api)
|
||||||
|
HttpClient client = new HttpClient(clientHandler);
|
||||||
|
|
||||||
|
HttpResponseMessage response = await client.GetAsync(url);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string jsonResponse = await response.Content.ReadAsStringAsync();
|
||||||
|
var tenants = JsonConvert.DeserializeObject<List<AeonMallCustomer>>(jsonResponse);
|
||||||
|
return tenants;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Error($"Error: {response.StatusCode}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Fatal($"Exception: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static string GetMACAddress()
|
private static string GetMACAddress()
|
||||||
@@ -130,6 +162,26 @@ namespace SafeBagDE70.API
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class AeonMallCustomer
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
public long? CreatorUserId { get; set; }
|
||||||
|
public long? DeleterUserId { get; set; }
|
||||||
|
public DateTime? DeletionTime { get; set; }
|
||||||
|
public bool IsDeleted { get; set; }
|
||||||
|
public DateTime? LastModificationTime { get; set; }
|
||||||
|
public long? LastModifierUserId { get; set; }
|
||||||
|
public int? TenantId { get; set; }
|
||||||
|
public string? Cards { get; set; }
|
||||||
|
public string? TenantCode { get; set; }
|
||||||
|
public string? TenantName { get; set; }
|
||||||
|
public string? TenantShortName { get; set; }
|
||||||
|
public string? OpenningDate { get; set; }
|
||||||
|
public string? Note { get; set; }
|
||||||
|
public string? Type { get; set; }
|
||||||
|
public string? TimeTag { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
Margin="10"
|
Margin="10"
|
||||||
Click="DashboardButton_Click"/>
|
Click="DashboardButton_Click"/>
|
||||||
<Button
|
<Button
|
||||||
Content="Quản lý vận hành"
|
Content="Quản lý người dùng"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Height="40"
|
Height="40"
|
||||||
Margin="10"
|
Margin="10"
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ namespace SafeBagDE70.Admin
|
|||||||
{
|
{
|
||||||
LogViewerUC loguc;
|
LogViewerUC loguc;
|
||||||
AdminConfigurationUC configuration;
|
AdminConfigurationUC configuration;
|
||||||
|
UserManageUC userManage;
|
||||||
public AdminWindow()
|
public AdminWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
loguc= new LogViewerUC();
|
loguc= new LogViewerUC();
|
||||||
configuration = new AdminConfigurationUC();
|
configuration = new AdminConfigurationUC();
|
||||||
|
userManage=new UserManageUC();
|
||||||
this.MainContentControl.Content = loguc;
|
this.MainContentControl.Content = loguc;
|
||||||
this.Loaded += AdminWindow_Loaded;
|
this.Loaded += AdminWindow_Loaded;
|
||||||
}
|
}
|
||||||
@@ -43,7 +45,7 @@ namespace SafeBagDE70.Admin
|
|||||||
|
|
||||||
private void UserManagementButton_Click(object sender, RoutedEventArgs e)
|
private void UserManagementButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
this.MainContentControl.Content = userManage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DashboardButton_Click(object sender, RoutedEventArgs e)
|
private void DashboardButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<UserControl x:Class="SafeBagDE70.Admin.UserManageUC"
|
||||||
|
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.Admin"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="Realtime Logs" FontSize="20" Margin="10"/>
|
||||||
|
<ListView x:Name="LogListView" Height="500" Margin="10"/>
|
||||||
|
<Button Content="Get Users" Width="200" Margin="10" x:Name="btnGetUsers" Click="btnGetUsers_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SafeBagDE70.API;
|
||||||
|
using SafeBagDE70.Model;
|
||||||
|
using Serilog;
|
||||||
|
using Serilog.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
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.Admin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for LogViewerUC.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class UserManageUC : UserControl
|
||||||
|
{
|
||||||
|
private ObservableCollection<string> _logItems = new ObservableCollection<string>();
|
||||||
|
|
||||||
|
public UserManageUC()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LogInfoButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void btnGetUsers_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var amCustomers= await APIModels.GetAeonMallCustomers(5);
|
||||||
|
using(var context = new CDMDbContext())
|
||||||
|
{
|
||||||
|
var customers = context.Customers;
|
||||||
|
context.Customers.RemoveRange(customers);
|
||||||
|
context.SaveChanges();
|
||||||
|
foreach (var amCustomer in amCustomers)
|
||||||
|
{
|
||||||
|
var customer = new Customer
|
||||||
|
{
|
||||||
|
AccountNumber = amCustomer.TenantCode,
|
||||||
|
AccountHolder = amCustomer.TenantName,
|
||||||
|
TenantName = amCustomer.TenantShortName,
|
||||||
|
TenantCode = amCustomer.TenantCode,
|
||||||
|
PinCode = amCustomer.TenantCode,
|
||||||
|
UpdatedTime = DateTime.Now,
|
||||||
|
};
|
||||||
|
customers.Add(customer);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -69,6 +69,10 @@ namespace SafeBagDE70
|
|||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
AppData.CDMPort = configuration["SerialPort:CDMPort"];
|
AppData.CDMPort = configuration["SerialPort:CDMPort"];
|
||||||
AppData.SensorPort = configuration["SerialPort:SensorPort"];
|
AppData.SensorPort = configuration["SerialPort:SensorPort"];
|
||||||
|
var maxNotes = int.Parse("0"+configuration["CDM:MaxNotes"]);
|
||||||
|
if(maxNotes > 0)
|
||||||
|
AppData.MaxNotes = maxNotes;
|
||||||
|
|
||||||
StateMachineConfig = new StateMachineConfig();
|
StateMachineConfig = new StateMachineConfig();
|
||||||
configuration.GetSection("StateMachine").Bind(StateMachineConfig);
|
configuration.GetSection("StateMachine").Bind(StateMachineConfig);
|
||||||
Log.Information("START APP");
|
Log.Information("START APP");
|
||||||
|
|||||||
+24
-11
@@ -29,20 +29,27 @@ namespace SafeBagDE70
|
|||||||
public static ObservableCollection<string> logCollection = new ObservableCollection<string>();
|
public static ObservableCollection<string> logCollection = new ObservableCollection<string>();
|
||||||
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 DeviceStatus? DeviceStatus = null;
|
public static DeviceStatus? DeviceStatus = null;
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
|
||||||
customerAccounts = new List<CustomerAccount>{
|
customerAccounts = new List<CustomerAccount>();
|
||||||
new CustomerAccount{Name="NGUYỄN ĐÌNH THUẬN",CustomerId="HUE_0000000001",QRCode="HUE_0000000001",PINCode="H0001" },
|
using (var context = new CDMDbContext())
|
||||||
new CustomerAccount{Name="HOÀNG VĂN HIỆP",CustomerId="HUE_0000000002",QRCode="HUE_0000000002",PINCode="H0002" },
|
{
|
||||||
new CustomerAccount{Name="PHẠM NGỌC HƯNG",CustomerId="HUE_0000000003",QRCode="HUE_0000000003",PINCode="H0003" },
|
var customers = context.Customers;
|
||||||
new CustomerAccount{Name="AMHUE-ESTELLETEST",CustomerId="00DZAMHUE0004",QRCode="00DZAMHUE0004",PINCode="H0004" },
|
foreach(var customer in customers)
|
||||||
new CustomerAccount{Name="AMHUE-ECCOTEST",CustomerId="00DZAMHUE0005",QRCode="00DZAMHUE0005",PINCode="H0005" },
|
{
|
||||||
new CustomerAccount{Name="AMHUE-ALDOTEST",CustomerId="00DZAMHUE0006",QRCode="00DZAMHUE0006",PINCode="H0006" },
|
var ca = new CustomerAccount
|
||||||
new CustomerAccount{Name="AMHUE-MLBTEST",CustomerId="00DZAMHUE0007",QRCode="00DZAMHUE0007",PINCode="H0007" },
|
{
|
||||||
new CustomerAccount{Name="AMHUE-PEDROTEST",CustomerId="00DZAMHUE0008",QRCode="00DZAMHUE0008",PINCode="H0008" }
|
Name = customer.TenantName,
|
||||||
};
|
CustomerId = customer.AccountNumber,
|
||||||
|
QRCode = customer.AccountNumber,
|
||||||
|
PINCode = customer.PinCode
|
||||||
|
};
|
||||||
|
customerAccounts.Add(ca);
|
||||||
|
}
|
||||||
|
}
|
||||||
CurrentCustomerAccount = customerAccounts[0];
|
CurrentCustomerAccount = customerAccounts[0];
|
||||||
CDMSTATE=new CDMSTATE();
|
CDMSTATE=new CDMSTATE();
|
||||||
DeviceStatus = new DeviceStatus
|
DeviceStatus = new DeviceStatus
|
||||||
@@ -107,9 +114,14 @@ 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;
|
||||||
|
|
||||||
|
if (data[0] == 0x40 && data[1] == 0x07 && data[2] == 0x41)
|
||||||
|
AppData.CDMSTATE.IsError = 0;
|
||||||
|
else
|
||||||
|
AppData.CDMSTATE.IsError = 1;
|
||||||
|
|
||||||
AppData.CDMSTATE.RequestTime = DateTime.Now;
|
AppData.CDMSTATE.RequestTime = DateTime.Now;
|
||||||
AppData.CDMSTATE.UpdateCDMStatus(cCmdRsp.recv_dat);
|
AppData.CDMSTATE.UpdateCDMStatus(cCmdRsp.recv_dat);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -258,6 +270,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 IsError = 0;
|
||||||
public RecvData? RecvDat = null;
|
public RecvData? RecvDat = null;
|
||||||
public byte GetSR1()
|
public byte GetSR1()
|
||||||
{
|
{
|
||||||
|
|||||||
+35
-5
@@ -591,7 +591,6 @@ namespace SafeBagDE70
|
|||||||
private bool DoCountStart()
|
private bool DoCountStart()
|
||||||
{
|
{
|
||||||
bool bSuccess = true;
|
bool bSuccess = true;
|
||||||
printerFlag = false;
|
|
||||||
|
|
||||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||||
try
|
try
|
||||||
@@ -620,6 +619,14 @@ 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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -835,7 +842,7 @@ namespace SafeBagDE70
|
|||||||
//Debug.WriteLine(quantityStored);
|
//Debug.WriteLine(quantityStored);
|
||||||
|
|
||||||
var previousCassetData = AppData.GetCassetteData();
|
var previousCassetData = AppData.GetCassetteData();
|
||||||
if(CheckPreStoreValid(previousCassetData,300,sessions))
|
if(CheckPreStoreValid(previousCassetData, AppData.MaxNotes, sessions))
|
||||||
{
|
{
|
||||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||||
bSuccess = WaitUntilCountReady(10);
|
bSuccess = WaitUntilCountReady(10);
|
||||||
@@ -1028,18 +1035,41 @@ namespace SafeBagDE70
|
|||||||
if (AppData.CurrentCustomerAccount != null)
|
if (AppData.CurrentCustomerAccount != null)
|
||||||
{
|
{
|
||||||
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
||||||
strNotify = strTransactionCode + "\r\n" + strNotify;
|
strNotify = "MÃ GD: "+strTransactionCode + "\r\n" + strNotify;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(strMessage!=null)
|
if(strMessage!=null)
|
||||||
{
|
{
|
||||||
strNotify += strMessage;
|
strNotify += strMessage;
|
||||||
}
|
}
|
||||||
mainWindow.ShowInformationScreen(strNotify, false, false);
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
mainWindow.ShowInformationScreen(strNotify, false, false);
|
||||||
|
});
|
||||||
ResetSessions();
|
ResetSessions();
|
||||||
StartWelcomeTimer();
|
StartWelcomeTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if(strMessage!=null)
|
||||||
|
{
|
||||||
|
var strNotify = "";
|
||||||
|
if (AppData.CurrentCustomerAccount != null)
|
||||||
|
{
|
||||||
|
var strTransactionCode = AppData.CurrentCustomerAccount.TransactionCode;
|
||||||
|
strNotify = "MÃ GD: "+strTransactionCode + "\r\n" + strNotify;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (strMessage != null)
|
||||||
|
{
|
||||||
|
strNotify += strMessage;
|
||||||
|
}
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
mainWindow.ShowInformationScreen(strNotify, false, false);
|
||||||
|
});
|
||||||
|
ResetSessions();
|
||||||
|
StartWelcomeTimer();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mainWindow.ShowWelcomeScreen();
|
mainWindow.ShowWelcomeScreen();
|
||||||
@@ -1171,7 +1201,7 @@ namespace SafeBagDE70
|
|||||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||||
var tradingCode = AppData.CurrentCustomerAccount.TransactionCode;// "TRA04052024CDM";
|
var tradingCode = AppData.CurrentCustomerAccount.TransactionCode;// "TRA04052024CDM";
|
||||||
var storeAccountNumber = 686868686688;
|
var storeAccountNumber = AppData.CurrentCustomerAccount.CustomerId;
|
||||||
var currentTime = DateTime.Now;
|
var currentTime = DateTime.Now;
|
||||||
var printDocument = new PrintDocument();
|
var printDocument = new PrintDocument();
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace SafeBagDE70.Model
|
|||||||
internal class CDMDbContext:DbContext
|
internal class CDMDbContext:DbContext
|
||||||
{
|
{
|
||||||
public DbSet<History> Histories { get; set; }
|
public DbSet<History> Histories { get; set; }
|
||||||
|
public DbSet<Customer> Customers { get; set; }
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=CDMLOCAL;User Id=cdm;Password=Navis@123;Trusted_Connection=False;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=CDMLOCAL;User Id=cdm;Password=Navis@123;Trusted_Connection=False;TrustServerCertificate=True");
|
||||||
@@ -35,4 +36,14 @@ namespace SafeBagDE70.Model
|
|||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
|
public class Customer
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? TenantName { get; set; }
|
||||||
|
public string? TenantCode { get; set; }
|
||||||
|
public string? AccountNumber { get; set; }
|
||||||
|
public string? AccountHolder { get; set; }
|
||||||
|
public string? PinCode { get; set; }
|
||||||
|
public DateTime? UpdatedTime { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
"CDMPort": "COM4",
|
"CDMPort": "COM4",
|
||||||
"SensorPort": "COM3"
|
"SensorPort": "COM3"
|
||||||
},
|
},
|
||||||
|
"CDM": {
|
||||||
|
"MaxNotes": 300
|
||||||
|
},
|
||||||
"StateMachine": {
|
"StateMachine": {
|
||||||
"States": [
|
"States": [
|
||||||
"Start",
|
"Start",
|
||||||
|
|||||||
Reference in New Issue
Block a user