AIParkingApplicationForm - add applicationLogger
This commit is contained in:
parent
e1f1320671
commit
8778a976db
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using NLog;
|
||||||
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -22,15 +23,19 @@ namespace AIParkingApplication
|
||||||
private EngineApiController engineApiController;
|
private EngineApiController engineApiController;
|
||||||
private string doorAccessControlDeviceIP;
|
private string doorAccessControlDeviceIP;
|
||||||
|
|
||||||
|
private Logger applicationLogger;
|
||||||
|
|
||||||
public AIParkingApplicationForm(ApiController apiController, string serverIPAddress, Config configOnWeb)
|
public AIParkingApplicationForm(ApiController apiController, string serverIPAddress, Config configOnWeb)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.apiController = apiController;
|
this.apiController = apiController;
|
||||||
this.configOnWeb = configOnWeb;
|
this.configOnWeb = configOnWeb;
|
||||||
|
applicationLogger = LogManager.GetLogger(AppConstant.APPLICATION_LOGGER_NAME);
|
||||||
|
|
||||||
ReadAccessControlDeviceIPConfigurationFile();
|
ReadAccessControlDeviceIPConfigurationFile();
|
||||||
if (string.IsNullOrEmpty(doorAccessControlDeviceIP) || !Util.IsValidIPAddress(doorAccessControlDeviceIP))
|
if (string.IsNullOrEmpty(doorAccessControlDeviceIP) || !Util.IsValidIPAddress(doorAccessControlDeviceIP))
|
||||||
{
|
{
|
||||||
|
applicationLogger.Log(LogLevel.Error, "Kiểm tra lại cấu hình IP thiết bị mở cửa!");
|
||||||
MessageBox.Show("Kiểm tra lại cấu hình IP thiết bị mở cửa! (C3200)", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Kiểm tra lại cấu hình IP thiết bị mở cửa! (C3200)", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
@ -55,6 +60,7 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
applicationLogger.Log(LogLevel.Error, "Cấu hình URL của Engine nhận diện biển số lỗi!");
|
||||||
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +155,7 @@ namespace AIParkingApplication
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneInIn();
|
UpdateLaneInIn();
|
||||||
|
applicationLogger.Log(LogLevel.Info, "Chuyển làn: IN-IN");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
|
||||||
|
@ -157,6 +164,7 @@ namespace AIParkingApplication
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneInOut();
|
UpdateLaneInOut();
|
||||||
|
applicationLogger.Log(LogLevel.Info, "Chuyển làn: IN-OUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
|
||||||
|
@ -165,6 +173,7 @@ namespace AIParkingApplication
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneOutIn();
|
UpdateLaneOutIn();
|
||||||
|
applicationLogger.Log(LogLevel.Info, "Chuyển làn: OUT-IN");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
|
||||||
|
@ -173,6 +182,7 @@ namespace AIParkingApplication
|
||||||
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
|
||||||
StopAllLanes();
|
StopAllLanes();
|
||||||
UpdateLaneOutOut();
|
UpdateLaneOutOut();
|
||||||
|
applicationLogger.Log(LogLevel.Info, "Chuyển làn: OUT-OUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMenuStripItemStatus(ToolStripMenuItem selectedToolStripMenuItem)
|
private void UpdateMenuStripItemStatus(ToolStripMenuItem selectedToolStripMenuItem)
|
||||||
|
@ -225,27 +235,29 @@ namespace AIParkingApplication
|
||||||
if (lane0 == "in" && lane1 == "in")
|
if (lane0 == "in" && lane1 == "in")
|
||||||
{
|
{
|
||||||
UpdateLaneInIn();
|
UpdateLaneInIn();
|
||||||
|
applicationLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: IN-IN");
|
||||||
}
|
}
|
||||||
if (lane0 == "in" && lane1 == "out")
|
if (lane0 == "in" && lane1 == "out")
|
||||||
{
|
{
|
||||||
UpdateLaneInOut();
|
UpdateLaneInOut();
|
||||||
|
applicationLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: IN-OUT");
|
||||||
}
|
}
|
||||||
if (lane0 == "out" && lane1 == "in")
|
if (lane0 == "out" && lane1 == "in")
|
||||||
{
|
{
|
||||||
UpdateLaneOutIn();
|
UpdateLaneOutIn();
|
||||||
|
applicationLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: OUT-IN");
|
||||||
}
|
}
|
||||||
if (lane0 == "out" && lane1 == "out")
|
if (lane0 == "out" && lane1 == "out")
|
||||||
{
|
{
|
||||||
UpdateLaneOutOut();
|
UpdateLaneOutOut();
|
||||||
|
applicationLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: OUT-OUT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
||||||
UpdateLaneInOut();
|
UpdateLaneInOut();
|
||||||
|
applicationLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,6 +266,7 @@ namespace AIParkingApplication
|
||||||
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
|
||||||
UpdateLaneInOut();
|
UpdateLaneInOut();
|
||||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
|
||||||
|
applicationLogger.Log(LogLevel.Error, $"Đọc config làn lỗi khi khởi động app!\texMessage: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +278,9 @@ namespace AIParkingApplication
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
|
||||||
doorAccessControlDeviceIP = string.Empty;
|
doorAccessControlDeviceIP = string.Empty;
|
||||||
|
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
|
||||||
|
applicationLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi(DOOR_ACCESS_DEVICE_CONTROL_IP)!\texMessage: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,6 +292,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
|
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
|
applicationLogger.Log(LogLevel.Error, $"Đóng ứng dụng");
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
{
|
{
|
||||||
public static class AppConstant
|
public static class AppConstant
|
||||||
{
|
{
|
||||||
#region Application Messages
|
|
||||||
public const string APPLICATION_IS_RUNNNING = "AIParkingApplication: Ứng dụng đã chạy!";
|
public const string APPLICATION_IS_RUNNNING = "AIParkingApplication: Ứng dụng đã chạy!";
|
||||||
public const string ERROR_TITLE = "Lỗi";
|
public const string ERROR_TITLE = "Lỗi";
|
||||||
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
|
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
|
||||||
#endregion
|
|
||||||
|
|
||||||
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
|
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
|
||||||
public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico";
|
public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico";
|
||||||
|
|
||||||
|
public const string APPLICATION_LOGGER_NAME = "ApplicationLogger";
|
||||||
|
public const string PING_SERVER_LOGGER_NAME = "PingServerLogger";
|
||||||
|
public const string PING_DOOR_DEVICE_CONTROL_ACCESS_LOGGER_NAME = "PingDoorDeviceControlAccessLogger";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user