Util - Rename AddOrUpdateAppSettings to UpsertAppSettings

This commit is contained in:
DucDangAnh 2020-07-17 15:01:16 +07:00
parent 68d84387b8
commit 6284909fd8
4 changed files with 16 additions and 16 deletions

View File

@ -154,7 +154,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-IN"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneInIn(); UpdateLaneInIn();
@ -163,7 +163,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneInOut(); UpdateLaneInOut();
@ -172,7 +172,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-IN"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneOutIn(); UpdateLaneOutIn();
@ -181,7 +181,7 @@ namespace AIParkingApplication
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e) private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "OUT-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem); UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes(); StopAllLanes();
UpdateLaneOutOut(); UpdateLaneOutOut();
@ -262,7 +262,7 @@ namespace AIParkingApplication
} }
else else
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateLaneInOut(); UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected(); toolStripMenuItemSwitchLaneInOut.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT"); appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT");
@ -271,7 +271,7 @@ namespace AIParkingApplication
} }
catch (Exception ex) catch (Exception ex)
{ {
Util.AddOrUpdateAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT"); Util.UpsertAppSettings(CURRENT_LANE_SETTING_KEY, "IN-OUT");
UpdateLaneInOut(); UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected(); toolStripMenuItemSwitchLaneInOut.DisableSelected();
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}"); Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");

View File

@ -152,7 +152,7 @@ namespace AIParkingApplication
} }
catch (Exception ex) catch (Exception ex)
{ {
Util.AddOrUpdateAppSettings("USE_PRINTER", "false"); Util.UpsertAppSettings("USE_PRINTER", "false");
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER. ex: {ex.Message }"); appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: USE_PRINTER. ex: {ex.Message }");
} }
} }

View File

@ -98,9 +98,9 @@ namespace AIParkingApplication
if (loginResult.IsLoginSuccess) if (loginResult.IsLoginSuccess)
{ {
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", txtUsername.Text); Util.UpsertAppSettings("DEFAULT_USERNAME", txtUsername.Text);
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", txtPassword.Text); Util.UpsertAppSettings("DEFAULT_PASSWORD", txtPassword.Text);
Util.AddOrUpdateAppSettings("DEFAULT_WEB_SERVER", txtServerAddress.Text); Util.UpsertAppSettings("DEFAULT_WEB_SERVER", txtServerAddress.Text);
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show(); new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show();
Hide(); Hide();
applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}"); applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}");
@ -130,10 +130,10 @@ namespace AIParkingApplication
{ {
txtUsername.Text = string.Empty; txtUsername.Text = string.Empty;
txtPassword.Text = string.Empty; txtPassword.Text = string.Empty;
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", string.Empty); Util.UpsertAppSettings("DEFAULT_USERNAME", string.Empty);
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", string.Empty); Util.UpsertAppSettings("DEFAULT_PASSWORD", string.Empty);
Util.AddOrUpdateAppSettings("AUTO_LOGIN", "false"); Util.UpsertAppSettings("AUTO_LOGIN", "false");
Util.AddOrUpdateAppSettings("DEFAULT_WEB_SERVER", "127.0.0.1:80"); Util.UpsertAppSettings("DEFAULT_WEB_SERVER", "127.0.0.1:80");
chkAutoLogin.Checked = false; chkAutoLogin.Checked = false;
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}"); Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD"); applicationLogger.Log(LogLevel.Error, "Không thể đọc cấu hình tài khoản mặc định: DEFAULT_USERNAME, DEFAULT_PASSWORD");
@ -147,7 +147,7 @@ namespace AIParkingApplication
private void chkAutoLogin_CheckedChanged(object sender, EventArgs e) private void chkAutoLogin_CheckedChanged(object sender, EventArgs e)
{ {
Util.AddOrUpdateAppSettings("AUTO_LOGIN", (sender as CheckBox).Checked.ToString().ToLower()); Util.UpsertAppSettings("AUTO_LOGIN", (sender as CheckBox).Checked.ToString().ToLower());
} }
} }
} }

View File

@ -113,7 +113,7 @@ namespace AIParkingApplication
int.TryParse(hostParts[1], out port); int.TryParse(hostParts[1], out port);
} }
public static void AddOrUpdateAppSettings(string key, string value) public static void UpsertAppSettings(string key, string value)
{ {
try try
{ {