Skip to content

Commit 910fd93

Browse files
authored
Merge pull request #7 from Sandip124/feat/overall-update
Feat/overall update
2 parents ad0d2c7 + d8fe10d commit 910fd93

12 files changed

+272
-61
lines changed

Assets/Fonts/Inter-Bold.ttf

309 KB
Binary file not shown.

Assets/Fonts/Inter-Regular.ttf

303 KB
Binary file not shown.

Helper/ApplyFont.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using postgres_database_restore_tool.Providers;
2+
using System.Windows.Forms;
3+
4+
namespace postgres_database_restore_tool.Helper
5+
{
6+
internal static class ApplyFont
7+
{
8+
public static Control ApplyRegularFont(this Control control, float? size = null)
9+
{
10+
control.Font = FontProvider.GetRegularFont(size ?? control.Font.Size);
11+
return control;
12+
}
13+
14+
public static Control ApplyBoldFont(this Control control, float? size = null)
15+
{
16+
control.Font = FontProvider.GetBoldFont(size ?? control.Font.Size);
17+
return control;
18+
}
19+
}
20+
}

Helper/CommandExecutor.cs

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ public static class CommandExecutor
99
{
1010
public static void Execute(string commandType, string user, string database)
1111
{
12-
var proc = new Process();
13-
proc.StartInfo.FileName = "psql";
14-
proc.StartInfo.Arguments = $@"-U {user} -c ""{commandType} database """"{database}""""";
15-
proc.StartInfo.RedirectStandardOutput = true;
16-
proc.StartInfo.RedirectStandardError = true;
17-
proc.StartInfo.UseShellExecute = false;
18-
proc.StartInfo.CreateNoWindow = true;
19-
proc.Start();
20-
var output = proc.StandardOutput.ReadToEnd();
21-
var error = proc.StandardError.ReadToEnd();
22-
proc.WaitForExit();
23-
if (proc.ExitCode != 0)
12+
var fileName = "psql";
13+
var arguments = $@"-U {user} -c ""{commandType} database """"{database}""""";
14+
15+
var process = ExecuteCommand(fileName, arguments);
16+
process.Start();
17+
var output = process.StandardOutput.ReadToEnd();
18+
var error = process.StandardError.ReadToEnd();
19+
process.WaitForExit();
20+
if (process.ExitCode != 0)
2421
{
25-
proc.Close();
22+
process.Close();
2623
throw new Exception("Error restoring database: " + error);
2724
}
28-
29-
proc.Close();
25+
process.Close();
3026
}
3127

3228
public static void ExecuteRestore(UserConnectionVo connection)
@@ -43,33 +39,44 @@ public static void ExecuteRestore(UserConnectionVo connection)
4339
break;
4440
}
4541

46-
var proc = new Process();
42+
43+
string fileName;
44+
string arguments;
45+
4746
if (connection.IsForPgDump)
4847
{
49-
proc.StartInfo.FileName = "psql";
50-
proc.StartInfo.Arguments = $@"-U {connection.UserName} ""{connection.DatabaseName}"" < ""{connection.RestoreFileLocation}""";
48+
fileName = "psql";
49+
arguments = $@"-U {connection.UserName} ""{connection.DatabaseName}"" < ""{connection.RestoreFileLocation}""";
5150
}
5251
else
5352
{
54-
proc.StartInfo.FileName = "pg_dump";
55-
proc.StartInfo.Arguments = $@"-U {connection.UserName} -d ""{connection.DatabaseName}"" ""{connection.RestoreFileLocation}""";
53+
fileName = "pg_dump";
54+
arguments = $@"-U {connection.UserName} -d ""{connection.DatabaseName}"" ""{connection.RestoreFileLocation}""";
5655
}
5756

58-
proc.StartInfo.RedirectStandardOutput = true;
59-
proc.StartInfo.RedirectStandardError = true;
60-
proc.StartInfo.UseShellExecute = false;
61-
proc.StartInfo.CreateNoWindow = true;
62-
proc.Start();
63-
var output = proc.StandardOutput.ReadToEnd();
64-
var error = proc.StandardError.ReadToEnd();
65-
proc.WaitForExit();
66-
if (proc.ExitCode != 0)
57+
var process = ExecuteCommand(fileName, arguments);
58+
process.Start();
59+
var output = process.StandardOutput.ReadToEnd();
60+
var error = process.StandardError.ReadToEnd();
61+
process.WaitForExit();
62+
if (process.ExitCode != 0)
6763
{
68-
proc.Close();
64+
process.Close();
6965
throw new Exception("Error restoring database.Details: " + error);
7066
}
67+
process.Close();
68+
}
7169

72-
proc.Close();
70+
private static Process ExecuteCommand(string fileName, string arguments)
71+
{
72+
var proc = new Process();
73+
proc.StartInfo.FileName = fileName;
74+
proc.StartInfo.Arguments = arguments;
75+
proc.StartInfo.RedirectStandardOutput = true;
76+
proc.StartInfo.RedirectStandardError = true;
77+
proc.StartInfo.UseShellExecute = false;
78+
proc.StartInfo.CreateNoWindow = true;
79+
return proc;
7380
}
7481
}
7582
}

MainWindow.Designer.cs

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)