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

Commit 4690d6a

Browse files
committed
config check
1 parent 3903896 commit 4690d6a

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

IBMiTools/IBMi.cs

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,70 @@ class IBMi
1818
private static Boolean _getList = false;
1919
private static List<string> _list = new List<string>();
2020

21+
private static void CheckExist(string key, string value)
22+
{
23+
if (!_config.ContainsKey(key))
24+
_config.Add(key, value);
25+
}
26+
2127
public static void LoadConfig(string FileLoc, string System = "mysystem")
2228
{
2329
_config.Clear();
2430
_ConfigFile = FileLoc;
2531
string[] data;
2632
if (!File.Exists(_ConfigFile))
2733
{
28-
_config.Add("system", System);
29-
_config.Add("username", "myuser");
30-
_config.Add("password", "mypass");
31-
_config.Add("datalibl", "SYSTOOLS");
32-
_config.Add("curlib", "SYSTOOLS");
33-
_config.Add("installlib", "QGPL");
34-
_config.Add("experimental", "false");
35-
36-
_config.Add("localDefintionsInstalled", "false");
37-
38-
_config.Add("binds", "MBR_CRTBNDRPG|MBR_CRTSQLRPGI|MBR_CRTBNDCL|MBR_CRTBNDC|IFS_CRTBNDRPG");
39-
_config.Add("MBR_CRTBNDRPG", "CRTBNDRPG PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) OPTION(*EVENTF) DBGVIEW(*SOURCE)|ERRORS %openlib% %openmbr%");
40-
_config.Add("MBR_CRTSQLRPGI", "CRTSQLRPGI OBJ(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) COMMIT(*NONE) OPTION(*EVENTF *XREF)|ERRORS %openlib% %openmbr%");
41-
_config.Add("MBR_CRTBNDCL", "CRTBNDCL PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) OPTION(*EVENTF)|ERRORS %openlib% %openmbr%");
42-
_config.Add("MBR_CRTBNDC", "CRTBNDC PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) DBGVIEW(*SOURCE)|ERRORS %openlib% %openmbr%");
43-
_config.Add("IFS_CRTBNDRPG", "CRTBNDRPG PGM(%curlib%/%file%) SRCSTMF('%file%.%ext%') OPTION(*EVENTF) DBGVIEW(*SOURCE)|ERRORS %curlib% %file%");
34+
CheckExist("system", System);
35+
CheckExist("username", "myuser");
36+
CheckExist("password", "mypass");
37+
CheckExist("datalibl", "SYSTOOLS");
38+
CheckExist("curlib", "SYSTOOLS");
39+
CheckExist("clrcdlen", "80");
40+
CheckExist("installlib", "QGPL");
41+
CheckExist("experimental", "false");
42+
43+
CheckExist("localDefintionsInstalled", "false");
44+
45+
CheckExist("binds", "MBR_CRTBNDRPG|MBR_CRTSQLRPGI|MBR_CRTBNDCL|MBR_CRTBNDC|IFS_CRTBNDRPG");
46+
CheckExist("MBR_CRTBNDRPG", "CRTBNDRPG PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) OPTION(*EVENTF) DBGVIEW(*SOURCE)|ERRORS %openlib% %openmbr%");
47+
CheckExist("MBR_CRTSQLRPGI", "CRTSQLRPGI OBJ(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) COMMIT(*NONE) OPTION(*EVENTF *XREF)|ERRORS %openlib% %openmbr%");
48+
CheckExist("MBR_CRTBNDCL", "CRTBNDCL PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) OPTION(*EVENTF)|ERRORS %openlib% %openmbr%");
49+
CheckExist("MBR_CRTBNDC", "CRTBNDC PGM(%openlib%/%openmbr%) SRCFILE(%openlib%/%openspf%) DBGVIEW(*SOURCE)|ERRORS %openlib% %openmbr%");
50+
CheckExist("IFS_CRTBNDRPG", "CRTBNDRPG PGM(%curlib%/%file%) SRCSTMF('%file%.%ext%') OPTION(*EVENTF) DBGVIEW(*SOURCE)|ERRORS %curlib% %file%");
4451

4552
PrintConfig();
4653

4754
MessageBox.Show("You will now be prompted to enter in a Remote System.");
4855
Main.RemoteSetup();
4956
}
50-
51-
_config.Clear();
52-
53-
foreach (string Line in File.ReadAllLines(_ConfigFile))
57+
else
5458
{
55-
data = Line.Split('=');
56-
for (int i = 0; i < data.Length; i++) data[i] = data[i].Trim();
57-
58-
if (_config.ContainsKey(data[0]))
59-
{
60-
_config[data[0]] = data[1];
61-
}
62-
else
59+
foreach (string Line in File.ReadAllLines(_ConfigFile))
6360
{
64-
_config.Add(data[0], data[1]);
61+
data = Line.Split('=');
62+
for (int i = 0; i < data.Length; i++) data[i] = data[i].Trim();
63+
64+
if (_config.ContainsKey(data[0]))
65+
{
66+
_config[data[0]] = data[1];
67+
}
68+
else
69+
{
70+
_config.Add(data[0], data[1]);
71+
}
6572
}
73+
74+
CheckExist("system", System);
75+
CheckExist("username", "myuser");
76+
CheckExist("password", "mypass");
77+
CheckExist("datalibl", "SYSTOOLS");
78+
CheckExist("curlib", "SYSTOOLS");
79+
CheckExist("clrcdlen", "80");
80+
CheckExist("installlib", "QGPL");
81+
CheckExist("experimental", "false");
6682
}
83+
84+
6785
}
6886

6987
private static void PrintConfig()

0 commit comments

Comments
 (0)