/// <summary> /// Executes remote commands on the configured server to collect data on externally /// referenced tables that is then put into both memory and the file cache /// </summary> internal static void LaunchFFDCollection() { Thread thread = new Thread((ThreadStart) delegate { List <SourceLine> src = ParseCurrentFileForExtName(); if (src.Count == 0) { return; } // Generate temporary files to receive data string[] tmp = new string[src.Count]; for (int i = 0; i < src.Count; i++) { tmp[i] = Path.GetTempFileName(); } // Receive record formats via remote command IICDSPFFD IBMi.RunCommands(IBMiCommandRender.RenderFFDCollectionScript(src, tmp)); // Get all record formats to local temp files // Load Context & Cleanup temp files for (int i = 0; i < src.Count; i++) { try { RPGParser.LoadFFD(tmp[i], src[i]); } catch (Exception e) { IBMiUtilities.Log(e.ToString()); // TODO: Show error? } finally { File.Delete(tmp[i]); } } }); thread.Start(); }
internal static void CommandMenuInit() { StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath); iniFilePath = sbIniFilePath.ToString(); if (!Directory.Exists(iniFilePath)) { Directory.CreateDirectory(iniFilePath); } IBMi.loadConfig(iniFilePath + PluginName + ".cfg"); PluginBase.SetCommand(0, "About IBMiCmd", myMenuFunction, new ShortcutKey(false, false, false, Keys.None)); PluginBase.SetCommand(1, "IBM i Remote System Setup", remoteSetup); PluginBase.SetCommand(2, "IBM i Command Entry", commandDialog); PluginBase.SetCommand(3, "IBM i Error Listing", errorDialog); PluginBase.SetCommand(4, "IBM i Command Bindings", bindsDialog); PluginBase.SetCommand(5, "IBM i Compile Bind Creator", launchPrompter); PluginBase.SetCommand(6, "IBM i RPG Conversion", launchConversion, new ShortcutKey(true, false, false, Keys.F4)); }
internal static string[] RenderRemoteInstallScript(List <string> sourceFiles, string library) { // Make room for <upload, copy, delete, compile> for each file string[] cmd = new string[sourceFiles.Count * 4 + 3]; int i = 0; cmd[i++] = "ASCII"; cmd[i++] = "QUOTE RCMD CRTPF FILE(QTEMP/NPPCLSRC) RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy NPP plugin commands')"; cmd[i++] = "QUOTE RCMD CRTPF FILE(QTEMP/NPPCMDSRC) RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy NPP plugin commands')"; foreach (string file in sourceFiles) { 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 = "NPPCLSRC"; crtCmd = $"CRTCLPGM PGM({library}/{member}) SRCFILE(QTEMP/NPPCLSRC) SRCMBR({member}) REPLACE(*YES) TEXT('{Main.PluginDescription}')"; break; case ".cmd": sourceFile = "NPPCMDSRC"; crtCmd = $"CRTCMD CMD({library}/{member}) PGM({library}/{member}) SRCFILE(QTEMP/NPPCMDSRC) SRCMBR({member}) REPLACE(*YES) TEXT('{Main.PluginDescription}')"; break; default: continue; } cmd[i++] = $"SEND { file } /home/{ IBMi.GetConfig("username") }/{ fileName }"; cmd[i++] = $"QUOTE RCMD CPYFRMSTMF FROMSTMF('/home/{ IBMi.GetConfig("username") }/{ fileName }') TOMBR('/QSYS.LIB/QTEMP.LIB/{ sourceFile }.FILE/{ member }.MBR')"; cmd[i++] = $"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ fileName }')"; cmd[i++] = $"QUOTE RCMD { crtCmd }"; } return(cmd); }
internal static void CommandMenuInit() { StringBuilder pluginsConfigDir = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, pluginsConfigDir); ConfigDirectory = $"{ pluginsConfigDir.ToString() }\\{ PluginName }\\"; FileCacheDirectory = $"{ConfigDirectory}cache\\"; if (!Directory.Exists(ConfigDirectory)) { Directory.CreateDirectory(ConfigDirectory); } if (!Directory.Exists(FileCacheDirectory)) { Directory.CreateDirectory(FileCacheDirectory); } IBMiUtilities.CreateLog(ConfigDirectory + PluginName); RPGParser.LoadFileCache(); IBMi.LoadConfig(ConfigDirectory + PluginName); //if (IBMi.GetConfig("localDefintionsInstalled") == "false") //{ // IBMiNPPInstaller.InstallLocalDefinitions(); //} PluginBase.SetCommand(0, "About IBMiCmd", About, new ShortcutKey(false, false, false, Keys.None)); PluginBase.SetCommand(1, "IBM i Remote System Setup", RemoteSetup); PluginBase.SetCommand(2, "IBM i Command Entry", CommandDialog); PluginBase.SetCommand(3, "IBM i Error Listing", ErrorDialog); PluginBase.SetCommand(4, "IBM i Command Bindings", BindsDialog); PluginBase.SetCommand(5, "IBM i RPG Conversion", LaunchConversion, new ShortcutKey(true, false, false, Keys.F4)); PluginBase.SetCommand(6, "IBM i Relic Build", LaunchRBLD, new ShortcutKey(true, false, false, Keys.F5)); PluginBase.SetCommand(7, "IBM i Refresh Definitions", BuildSourceContext, new ShortcutKey(true, false, false, Keys.F6)); PluginBase.SetCommand(8, "IBM i Auto Complete", AutoComplete, new ShortcutKey(false, true, false, Keys.Space)); PluginBase.SetCommand(9, "IBM i Library List", LiblDialog, new ShortcutKey(true, false, false, Keys.F7)); PluginBase.SetCommand(10, "IBM i Remote Install Plugin Server", RemoteInstall); }
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")}/NPPDSPFFD {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 void runCommands(string[] commands) { IBMi.RunCommands(commands); loadNewCommands(); }
internal static void CommandMenuInit() { StringBuilder pluginsConfigDir = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, pluginsConfigDir); ConfigDirectory = $"{ pluginsConfigDir.ToString() }\\{ PluginName }\\"; SystemsDirectory = $"{ConfigDirectory}systems\\"; FileCacheDirectory = $"{ConfigDirectory}cache\\"; if (!Directory.Exists(ConfigDirectory)) { Directory.CreateDirectory(ConfigDirectory); } if (!Directory.Exists(SystemsDirectory)) { Directory.CreateDirectory(SystemsDirectory); } if (!Directory.Exists(FileCacheDirectory)) { Directory.CreateDirectory(FileCacheDirectory); } IBMiUtilities.CreateLog(ConfigDirectory + PluginName); RPGParser.LoadFileCache(); CLParser.LoadFileCache(); if (File.Exists(ConfigDirectory + "dftcfg")) { Config.SwitchToConfig(File.ReadAllText(ConfigDirectory + "dftcfg")); } else { LoadConfigSelect(); if (Config.GetConfigs().Length == 0) { return; } if (IBMi._ConfigFile == "" || IBMi._ConfigFile == null) { string UseConfig = Config.GetConfigs()[0]; MessageBox.Show("No config selected. Defaulted to " + UseConfig + "."); Config.SwitchToConfig(UseConfig); } } //if (IBMi.GetConfig("localDefintionsInstalled") == "false") //{ // IBMiNPPInstaller.InstallLocalDefinitions(); //} bool ExperimentalFeatures = (IBMi.GetConfig("experimental") == "true"); int ItemOrder = 0; PluginBase.SetCommand(ItemOrder++, "About IBMiCmd", About, new ShortcutKey(false, false, false, Keys.None)); PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null); PluginBase.SetCommand(ItemOrder++, "Select Remote System", LoadConfigSelect); PluginBase.SetCommand(ItemOrder++, "Remote System Setup", RemoteSetup); PluginBase.SetCommand(ItemOrder++, "Library List", LiblDialog, new ShortcutKey(true, false, false, Keys.F7)); if (ExperimentalFeatures) { PluginBase.SetCommand(ItemOrder++, "Remote Install Plugin Server", RemoteInstall); } PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null); PluginBase.SetCommand(ItemOrder++, "Command Entry", CommandDialog); PluginBase.SetCommand(ItemOrder++, "Error Listing", ErrorDialog); PluginBase.SetCommand(ItemOrder++, "Command Bindings", BindsDialog); PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null); PluginBase.SetCommand(ItemOrder++, "Member Listing", MemberListing); PluginBase.SetCommand(ItemOrder++, "Open Source Member", OpenMember, new ShortcutKey(true, false, true, Keys.A)); //PluginBase.SetCommand(ItemOrder++, "Upload Source Member", UploadMember, new ShortcutKey(true, false, true, Keys.X)); PluginBase.SetCommand(ItemOrder++, "Open Include/Copy", OpenInclude, new ShortcutKey(true, false, false, Keys.F12)); PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null); PluginBase.SetCommand(ItemOrder++, "Format CL file", ManageCL, new ShortcutKey(true, false, false, Keys.F4)); PluginBase.SetCommand(ItemOrder++, "RPG Line Conversion", LaunchConversion, new ShortcutKey(true, false, false, Keys.F5)); PluginBase.SetCommand(ItemOrder++, "RPG File Conversion", LaunchFileConversion, new ShortcutKey(true, false, false, Keys.F6)); PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null); PluginBase.SetCommand(ItemOrder++, "Display File Editor", DisplayEdit); if (ExperimentalFeatures) { PluginBase.SetCommand(ItemOrder++, "Refresh Extname Definitions", BuildSourceContext); } if (ExperimentalFeatures) { PluginBase.SetCommand(ItemOrder++, "Extname Content Assist", AutoComplete, new ShortcutKey(false, true, false, Keys.Space)); } if (ExperimentalFeatures) { PluginBase.SetCommand(ItemOrder++, "Prompt CL Command", PromptCommand, new ShortcutKey(true, false, false, Keys.F4)); } }
internal static void ManageCL() { CLFile.CorrectLines(NppFunctions.GetCurrentFileName(), Convert.ToInt32(IBMi.GetConfig("clrcdlen"))); NppFunctions.RefreshWindow(NppFunctions.GetCurrentFileName()); }
/// <summary> /// TODO: ? /// </summary> internal static void RebuildRelic() { Thread gothread = new Thread((ThreadStart) delegate { IBMiUtilities.DebugLog("RebuildRelic!"); string tmpFile = Path.GetTempFileName(); IBMi.AddOutput("Starting build of '" + IBMi.GetConfig("relicdir") + "' into " + IBMi.GetConfig("reliclib")); if (Main.CommandWindow != null) { Main.CommandWindow.loadNewCommands(); } IBMi.RunCommands(IBMiCommandRender.RenderRelicRebuildScript(tmpFile)); IBMi.AddOutput(""); foreach (string line in File.ReadAllLines(tmpFile)) { IBMi.AddOutput($"> { line }"); } IBMi.AddOutput(""); IBMi.AddOutput("End of build."); File.Delete(tmpFile); if (Main.CommandWindow != null) { Main.CommandWindow.loadNewCommands(); } IBMiUtilities.DebugLog("RebuildRelic - DONE!"); }); gothread.Start(); }
internal static void LaunchRBLD() { DialogResult outp = MessageBox.Show("Confirm build of '" + IBMi.GetConfig("relicdir") + "' into " + IBMi.GetConfig("reliclib") + "?", "Relic Build", MessageBoxButtons.YesNo); if (outp == DialogResult.Yes) { IBMiNPPInstaller.RebuildRelic(); } }