diff --git a/Admin/UserManageUC.xaml b/Admin/UserManageUC.xaml
index fa407db..76ee2f6 100644
--- a/Admin/UserManageUC.xaml
+++ b/Admin/UserManageUC.xaml
@@ -8,9 +8,8 @@
d:DesignHeight="450" d:DesignWidth="800">
-
-
+
diff --git a/Admin/UserManageUC.xaml.cs b/Admin/UserManageUC.xaml.cs
index eac572b..937b622 100644
--- a/Admin/UserManageUC.xaml.cs
+++ b/Admin/UserManageUC.xaml.cs
@@ -40,29 +40,37 @@ namespace SafeBagDE70.Admin
private async void btnGetUsers_Click(object sender, RoutedEventArgs e)
{
- var amCustomers= await APIModels.GetAeonMallCustomers(AppData.TenantId);
- using(var context = new CDMDbContext())
+ try
{
- var customers = context.Customers;
- context.Customers.RemoveRange(customers);
- context.SaveChanges();
- foreach (var amCustomer in amCustomers)
+ var amCustomers = await APIModels.GetAeonMallCustomers(AppData.TenantId);
+ using (var context = new CDMDbContext())
{
- var customer = new Customer
+ var customers = context.Customers;
+ context.Customers.RemoveRange(customers);
+ context.SaveChanges();
+ foreach (var amCustomer in amCustomers)
{
- AccountNumber = amCustomer.TenantCode,
- AccountHolder = amCustomer.TenantName,
- TenantName = amCustomer.TenantShortName,
- TenantCode = amCustomer.TenantCode,
- PinCode = amCustomer.TenantCode,
- UpdatedTime = DateTime.Now,
- };
- customers.Add(customer);
+ 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();
}
- context.SaveChanges();
+ lblStatus.Foreground = new SolidColorBrush(Colors.Green);
+ lblStatus.Content = "Updated customers: " + amCustomers.Count;
+ }
+ catch(Exception ex)
+ {
+ lblStatus.Foreground = new SolidColorBrush(Colors.Red);
+ lblStatus.Content= ex.Message;
}
-
-
}
}
diff --git a/App.xaml.cs b/App.xaml.cs
index 6e444b9..7950444 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -84,6 +84,78 @@ namespace SafeBagDE70
System.Windows.MessageBox.Show(ex.Message);
}
}
+ private static void LoadConfig2()
+ {
+ try
+ {
+ AppData.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version;
+ VKeyboard.Listen(e => e.Text);
+ var configuration = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json")
+ .Build();
+ InitLogger(configuration);
+ AppData.CDMPort = configuration["SerialPort:CDMPort"];
+ 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"]);
+ if (maxNotes > 0)
+ AppData.MaxNotes = maxNotes;
+
+ StateMachineConfig = new StateMachineConfig();
+ configuration.GetSection("StateMachine").Bind(StateMachineConfig);
+ Log.Information("START APP");
+ }
+ catch (Exception ex)
+ {
+ System.Windows.MessageBox.Show(ex.Message);
+ }
+ }
+ private static void InitLogger(IConfigurationRoot configuration)
+ {
+ var logPath = configuration["Serilog:WriteTo:0:Args:path"];
+ var rollingIntervalSetting = configuration["Serilog:WriteTo:0:Args:rollingInterval"];
+
+ // Ensure the path is relative to the application's directory
+ var resolvedLogPath = Path.IsPathRooted(logPath)
+ ? logPath
+ : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logPath);
+
+ // Parse the rollingInterval from string to enum
+ RollingInterval rollingInterval = Enum.TryParse(rollingIntervalSetting, out RollingInterval interval)
+ ? interval
+ : RollingInterval.Day; // Default to 'Day' if parsing fails
+
+ // Ensure the directory exists
+ var logDirectory = Path.GetDirectoryName(resolvedLogPath);
+ if (!Directory.Exists(logDirectory))
+ {
+ Directory.CreateDirectory(logDirectory);
+ }
+
+ // Configure Serilog to write logs to the resolved log path
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.File(
+ path: resolvedLogPath,
+ rollingInterval: rollingInterval
+ )
+ .WriteTo.Sink(new RealTimeLogSink())
+ .CreateLogger();
+
+ try
+ {
+ Log.Information("Application Starting...");
+ // Your application code here
+ }
+ catch (Exception ex)
+ {
+ Log.Fatal(ex, "Application failed to start.");
+ }
+ finally
+ {
+ Log.CloseAndFlush();
+ }
+ }
private void LoadDualScreens()
{
try
diff --git a/AppData.cs b/AppData.cs
index 7503bea..2887c43 100644
--- a/AppData.cs
+++ b/AppData.cs
@@ -39,6 +39,7 @@ namespace SafeBagDE70
{
try
{
+ InitUsers();
CDMSTATE = new CDMSTATE();
DeviceStatus = new DeviceStatus
{
@@ -51,12 +52,10 @@ namespace SafeBagDE70
Notes = "",
OtherError = 0,
};
- InitUsers();
-
}
catch (Exception ex)
{
- Log.Fatal(ex, "AppInit");
+ Log.Fatal(ex, "AppInit: "+ex.Message);
}
}
@@ -85,12 +84,18 @@ namespace SafeBagDE70
public static CDMSTATE? CDMSTATE = null;
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time
+ public static string GetNumberPartFromMerchantCode(string merchantCode)
+ {
+ if (merchantCode == null) return "";
+ var match = Regex.Match(merchantCode, @"\d+$");
+ string merchantCode_part = match.Value;
+ return merchantCode_part;
+ }
public static void CreateNewTransactionCode()
{
DateTime transactionDateTime = DateTime.Now;
- var match = Regex.Match(CurrentCustomerAccount.CustomerId, @"\d+$");
- string merchantCode_part = match.Value;
+ string merchantCode_part = GetNumberPartFromMerchantCode(CurrentCustomerAccount.CustomerId);
// 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);
@@ -142,7 +147,7 @@ namespace SafeBagDE70
AppData.CDMSTATE.IsNotesInHopper = data[3] & 0x01;
AppData.CDMSTATE.IsStackerFull = (data[2] == 0x43?1:0);
- if (data[0] == 0x40 && data[1] == 0x07)
+ if (data[0] == 0x40 && (data[1] == 0x07 || data[1]==0x09))
AppData.CDMSTATE.IsError = 0;
else
AppData.CDMSTATE.IsError = 1;
@@ -351,8 +356,8 @@ namespace SafeBagDE70
if (RecvDat.leng > 18)
{
var dat = RecvDat.dat;
- strStatus += "S1: "+ AppData.cCmdRsp.GetD1Summary(dat[17]);
- strStatus += "\r\nS2: " + AppData.cCmdRsp.GetD2Summary(dat[18]);
+ strStatus += "S1: "+ AppData.cCmdRsp.GetS1Summary(dat[17]);
+ strStatus += "\r\nS2: " + AppData.cCmdRsp.GetS2Summary(dat[18]);
}
}
return strStatus;
diff --git a/DepositSMUCv2.xaml.cs b/DepositSMUCv2.xaml.cs
index 719c17e..301ef5b 100644
--- a/DepositSMUCv2.xaml.cs
+++ b/DepositSMUCv2.xaml.cs
@@ -317,15 +317,18 @@ namespace SafeBagDE70
public void InitLvCountItems()
{
- if (lvCount.Items.Count == 11) {
- foreach(var item in lvCountItems)
- {
- item.Quantity = "0";
- }
- }
- else
+ Dispatcher.Invoke(() =>
{
- lvCountItems = new ObservableCollection()
+ if (lvCount.Items.Count == 11)
+ {
+ foreach (var item in lvCountItems)
+ {
+ item.Quantity = "0";
+ }
+ }
+ else
+ {
+ lvCountItems = new ObservableCollection()
{
new LvCountItem{Name = "500",Quantity = "0"},
new LvCountItem{Name = "1000",Quantity = "0"},
@@ -339,11 +342,9 @@ namespace SafeBagDE70
new LvCountItem{Name = "500000",Quantity = "0"},
new LvCountItem{Name = "Tổng",Quantity = "0",Value="0"},
};
- }
-
-
- lvCount.ItemsSource = lvCountItems;
-
+ }
+ lvCount.ItemsSource = lvCountItems;
+ });
//lvCountItems[0].Quantity = "10";
}
int prevPrinterStatus = -1;
@@ -1293,8 +1294,10 @@ namespace SafeBagDE70
var currentTime = DateTime.Now;
var printDocument = new PrintDocument();
- System.Drawing.Image LogoAeonMall = System.Drawing.Image.FromFile("Logo\\logoAeonmall.png");
- System.Drawing.Image LogoVietin = System.Drawing.Image.FromFile("Logo\\logoVietin.png");
+ var strLogoAM= System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logo\\logoAeonmall.png");
+ var strLogoVietin = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logo\\logoVietin.png");
+ System.Drawing.Image LogoAeonMall = System.Drawing.Image.FromFile(strLogoAM);
+ System.Drawing.Image LogoVietin = System.Drawing.Image.FromFile(strLogoVietin);
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
printDocument.PrintPage += (sender, e) =>
@@ -1334,7 +1337,7 @@ namespace SafeBagDE70
e.Graphics.DrawString("Tên Gian hàng: " + shopName, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 5 + 65));
e.Graphics.DrawString("Số tài khoản gian hàng: " + storeAccountNumber, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 6 + 65));
e.Graphics.DrawString("Nội dung giao dịch: Nop doanh so tien mat_", new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 7 + 65));
- e.Graphics.DrawString(shopCode, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 8 + 65));
+ e.Graphics.DrawString(AppData.GetNumberPartFromMerchantCode(shopCode), new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 8 + 65));
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 9 + 65));
e.Graphics.DrawString("*****Xin cám ơn*****", new Font("Arial", 7), System.Drawing.Brushes.Black, new PointF(120, lineSpace * 10 + 65));
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 6c6f244..f12ef61 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace SafeBagDE70.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));