Skip to content
This repository was archived by the owner on Mar 4, 2018. It is now read-only.

Commit 600a1ce

Browse files
committed
Error message boxes when FTP error occurs
1 parent 56605eb commit 600a1ce

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

IBMiTools/IBMi.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ namespace IBMiCmd.IBMiTools
88
{
99
class IBMi
1010
{
11+
readonly static Dictionary<string, string> FTPCodeMessages = new Dictionary<string, string>()
12+
{
13+
{ "426", "Connection closed; transfer aborted." },
14+
{ "530", "Configuration username and password incorrect." },
15+
{ "550", "File being access may not exist." }
16+
};
17+
1118
public static string _ConfigFile { get; set; }
1219

1320
private static Boolean _NotConnected = false;
14-
private static Boolean _Failed = false;
21+
private static string _Failed = "";
1522
private static Dictionary<string, string> _config = new Dictionary<string, string>();
1623
private static List<string> _output = new List<string>();
1724

@@ -202,7 +209,7 @@ private static Boolean RunFTP(string FileLoc)
202209

203210
_list.Clear();
204211
_NotConnected = false;
205-
_Failed = false;
212+
_Failed = "";
206213

207214
Process process = new Process();
208215
process.StartInfo.FileName = "cmd.exe";
@@ -221,7 +228,17 @@ private static Boolean RunFTP(string FileLoc)
221228
process.WaitForExit();
222229

223230
IBMiUtilities.DebugLog("FTP of command file " + FileLoc + " completed");
224-
return _Failed || _NotConnected;
231+
232+
if (_NotConnected)
233+
{
234+
MessageBox.Show("Not able to connect to " + GetConfig("system"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
235+
}
236+
else if (_Failed != "")
237+
{
238+
MessageBox.Show(FTPCodeMessages[_Failed], "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
239+
}
240+
241+
return _Failed != "" || _NotConnected;
225242
}
226243

227244
private static void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
@@ -250,7 +267,7 @@ private static void OutputHandler(object sendingProcess, DataReceivedEventArgs o
250267
case "426":
251268
case "530":
252269
case "550":
253-
_Failed = true;
270+
_Failed = outLine.Data.Substring(0, 3);
254271
_output.Add("> " + outLine.Data.Substring(4));
255272
break;
256273
default:

IBMiTools/IBMiUtilities.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,13 @@ internal static string GetLogPath()
130130

131131
internal static void Log(string m)
132132
{
133-
File.AppendAllText(_LogFile, DateTime.Now.ToString() + " : " + m + Environment.NewLine);
133+
try
134+
{
135+
File.AppendAllText(_LogFile, DateTime.Now.ToString() + " : " + m + Environment.NewLine);
136+
} catch (Exception e) { }
134137
}
135-
138+
139+
[System.Diagnostics.Conditional("DEBUG")]
136140
internal static void DebugLog(string m)
137141
{
138142
File.AppendAllText(_LogFile, DateTime.Now.ToString() + " : " + m + Environment.NewLine);

0 commit comments

Comments
 (0)