public static string DownloadMember(string Lib, string Obj, string Mbr) { string filetemp = Path.GetTempPath() + Mbr + "." + Obj; List <string> commands = new List <string>(); if (!File.Exists(filetemp)) { File.Create(filetemp).Close(); } Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); Mbr = Mbr.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.GetConfig("curlib"); } commands.Add("ASCII"); commands.Add("cd /QSYS.lib"); commands.Add("recv \"" + Lib + ".lib/" + Obj + ".file/" + Mbr + ".mbr\" \"" + filetemp + "\""); if (IBMi.RunCommands(commands.ToArray()) == false) { return(filetemp); } else { return(""); } }
internal static string[] RenderRemoteInstallScript(List <string> sourceFiles, string library) { List <string> cmd = new List <string> { "ASCII", "QUOTE RCMD CRTPF FILE(QTEMP/IICCLSRC) RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy IBMiCmd plugin')", "QUOTE RCMD CRTPF FILE(QTEMP/IICCMDSRC) RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy IBMiCmd plugin')", "QUOTE RCMD CRTPF FILE(QTEMP/IICRPGSRC) RCDLEN(240) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy IBMiCmd plugin')" }; foreach (string file in sourceFiles) { IBMiUtilities.DebugLog($"RenderRemoteInstallScript processsing {file}"); string fileName = file.Substring(file.LastIndexOf("\\") + 1); string member = fileName.Substring(fileName.LastIndexOf("-") + 1, fileName.LastIndexOf(".") - (fileName.LastIndexOf("-") + 1)); string sourceFile = null, crtCmd = null; switch (fileName.Substring(fileName.Length - 4)) { case ".CLP": sourceFile = "IICCLSRC"; crtCmd = getCompileCommandCL(library, member); break; case ".CMD": sourceFile = "IICCMDSRC"; crtCmd = getCompileCommandCmd(library, member); break; case ".RPG": sourceFile = "IICRPGSRC"; crtCmd = getCompileCommandRpg(library, member); break; default: sourceFile = "IICRPGSRC"; break; } cmd.Add($"SEND \"{ file }\" /home/{ IBMi.GetConfig("username") }/{ fileName }"); cmd.Add($"QUOTE RCMD CPYFRMSTMF FROMSTMF('/home/{ IBMi.GetConfig("username") }/{ fileName }') TOMBR('/QSYS.LIB/QTEMP.LIB/{ sourceFile }.FILE/{ member }.MBR')"); cmd.Add($"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ fileName }')"); if (crtCmd != null) { cmd.Add($"QUOTE RCMD { crtCmd }"); } } return(cmd.ToArray()); }
internal static string[] RenderCommandDescriptionCollection(string command) { IBMiUtilities.DebugLog("RenderCommandDescriptionCollection"); string[] cmd = new string[5]; // Run commands on remote int i = 0; cmd[i++] = "ASCII"; cmd[i++] = $"QUOTE RCMD CHGLIBL LIBL({ IBMi.GetConfig("datalibl").Replace(',', ' ')}) CURLIB({ IBMi.GetConfig("curlib") })"; cmd[i++] = $"QUOTE RCMD { IBMi.GetConfig("installlib") }/IICRTVCMD {command}"; cmd[i++] = $"RECV /home/{ IBMi.GetConfig("username") }/{ command }.cdml \"{ Main.FileCacheDirectory }{ command }.cdml\""; cmd[i] = $"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ command }.cdml')"; IBMiUtilities.DebugLog("RenderCommandDescriptionCollection - DONE!"); return(cmd); }
public static Boolean RunCommands(string[] list) { Boolean result = true; try { FlushOutput(); string tempfile = Path.GetTempFileName(); File.Move(tempfile, tempfile + ".ftp"); tempfile += ".ftp"; List <string> lines = new List <string>(); lines.Add("user " + _config["username"]); lines.Add(_config["password"]); lines.Add("bin"); lines.Add($"QUOTE RCMD CHGLIBL LIBL({ IBMi.GetConfig("datalibl").Replace(',', ' ')}) CURLIB({ IBMi.GetConfig("curlib") })"); foreach (string cmd in list) { if (cmd == null) { continue; } if (cmd.Trim() != "") { AddOutput("> " + cmd); IBMiUtilities.DebugLog("Collecting command for ftp file: " + cmd); lines.Add(cmd); } } #if DEBUG lines.Add("QUOTE RCMD DSPJOBLOG"); #endif lines.Add("quit"); File.WriteAllLines(tempfile, lines.ToArray()); result = RunFTP(tempfile); File.Delete(tempfile); } catch (Exception e) { IBMiUtilities.Log(e.ToString()); MessageBox.Show(e.ToString()); } return(result); }
internal static string[] RenderFFDCollectionScript(List <SourceLine> src, string[] tmp) { IBMiUtilities.DebugLog("RenderFFDCollectionScript"); string[] cmd = new string[(src.Count * 3) + 2]; int i = 0, t = 0; // Run commands on remote cmd[i++] = "ASCII"; cmd[i++] = $"QUOTE RCMD CHGLIBL LIBL({ IBMi.GetConfig("datalibl").Replace(',', ' ')}) CURLIB({ IBMi.GetConfig("curlib") })"; foreach (SourceLine sl in src) { cmd[i++] = $"QUOTE RCMD { IBMi.GetConfig("installlib") }/IICDSPFFD { sl.searchResult }"; cmd[i++] = $"RECV /home/{ IBMi.GetConfig("username") }/{ sl.searchResult }.tmp \"{ tmp[t++] }\""; cmd[i++] = $"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ sl.searchResult }.tmp')"; } IBMiUtilities.DebugLog("RenderFFDCollectionScript - DONE!"); return(cmd); }
public static bool UploadMember(string Local, string Lib, string Obj, string Mbr) { List <string> commands = new List <string>(); Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); Mbr = Mbr.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.GetConfig("curlib"); } commands.Add("ASCII"); commands.Add("cd /QSYS.lib"); commands.Add("put \"" + Local + "\" \"" + Lib + ".lib/" + Obj + ".file/" + Mbr + ".mbr\""); //Returns true if successful return(!IBMi.RunCommands(commands.ToArray())); }
public static string[] GetMemberList(string Lib, string Obj) { List <string> commands = new List <string>(); Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.GetConfig("curlib"); } commands.Add("cd /QSYS.lib/" + Lib + ".lib/" + Obj + ".file"); commands.Add("ls"); if (IBMi.RunCommands(commands.ToArray()) == false) { return(IBMi.GetListing()); } else { return(null); } }