Skip to content

Commit 42c130e

Browse files
committed
merge master and fix conflict
2 parents c70d123 + ad0d2c7 commit 42c130e

File tree

7 files changed

+18
-23
lines changed

7 files changed

+18
-23
lines changed

Constants/ActionTypeConstants.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace postgres_database_restore_tool.Constants
22
{
3-
internal class ActionTypeConstants
3+
internal static class ActionTypeConstants
44
{
5-
public const string DropAndRestore = "Drop_and_Restore";
6-
public const string CreateAndRestore = "Create_and_Restore";
5+
public const string DropAndRestore = "Drop and Restore";
6+
public const string CreateAndRestore = "Create and Restore";
77
}
88
}

Constants/CommandTypeConstants.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
namespace postgres_database_restore_tool.Constants
22
{
3-
internal class CommandTypeConstants
3+
internal static class CommandTypeConstants
44
{
5-
public const string PgRestore = "pg_restore";
6-
public const string PgDump = "pg_dump";
7-
5+
public static (string key, string value) PgRestore = ("PG Restore", "pg_restore");
6+
public static (string key, string value) PgDump = ("PG Dump", "pg_dump");
87
}
9-
}
8+
}

Helper/CommandExecutor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ public static void ExecuteRestore(UserConnectionVo connection)
3939
break;
4040
}
4141

42+
4243
string fileName;
4344
string arguments;
4445

45-
if (connection.DatabaseBackupType == CommandTypeConstants.PgDump)
46+
if (connection.IsForPgDump)
4647
{
4748
fileName = "psql";
4849
arguments = $@"-U {connection.UserName} ""{connection.DatabaseName}"" < ""{connection.RestoreFileLocation}""";
4950
}
5051
else
5152
{
52-
fileName = connection.DatabaseBackupType;
53+
fileName = "pg_dump";
5354
arguments = $@"-U {connection.UserName} -d ""{connection.DatabaseName}"" ""{connection.RestoreFileLocation}""";
5455
}
5556

MainWindow.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.ComponentModel;
@@ -51,8 +51,8 @@ private void OnFormLoad(object sender, EventArgs e)
5151

5252
var commandType = new List<string>()
5353
{
54-
CommandTypeConstants.PgRestore,
55-
CommandTypeConstants.PgDump
54+
CommandTypeConstants.PgRestore.key,
55+
CommandTypeConstants.PgDump.key
5656
};
5757
var actionTypes = new List<string>()
5858
{
@@ -129,7 +129,7 @@ private void OnRestore(object sender, EventArgs e)
129129
Password = PasswordElm.Text.Trim(),
130130
DatabaseName = DatabaseElem.Text.Trim(),
131131
ActionTypeValue = ActionSelectorElem.SelectedValue.ToString(),
132-
DatabaseBackupType = TypeSelectorElem.SelectedValue.ToString(),
132+
IsForPgDump = (TypeSelectorElem.SelectedValue.ToString() == CommandTypeConstants.PgDump.key),
133133
RestoreFileLocation = TargetLocation.FileName.Trim(),
134134
}
135135
.Validate();
@@ -194,4 +194,4 @@ private void RememberPassword_CheckedChanged(object sender, EventArgs e)
194194
}
195195
}
196196
}
197-
}
197+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# postgres-database-restore-service
22
## Overview
3-
![image](https://user-images.githubusercontent.com/71131016/151153077-7ed11a50-2060-4aed-ace0-d776a9b83951.png)
3+
![image](https://user-images.githubusercontent.com/71131016/183951344-49cda8d3-2549-45d6-a645-d0a87f2ee820.png)
44

Validator/UserConnectionValidator.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ public static UserConnectionVo Validate(this UserConnectionVo connectionVo)
2626
{
2727
throw new Exception("Restore file is not selected");
2828
}
29-
30-
if (string.IsNullOrEmpty(connectionVo.DatabaseBackupType))
31-
{
32-
throw new Exception("Please select database backup type");
33-
}
34-
29+
3530
if (string.IsNullOrEmpty(connectionVo.ActionTypeValue))
3631
{
3732
throw new Exception("Please select action type");

ValueObject/UserConnectionVo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class UserConnectionVo
66
public string Password { get; set; }
77
public string DatabaseName { get; set; }
88
public string RestoreFileLocation { get; set; }
9-
public string DatabaseBackupType { get; set; }
9+
public bool IsForPgDump { get; set; }
1010
public string ActionTypeValue { get; set; }
1111

1212
}

0 commit comments

Comments
 (0)