Exemplo n.º 1
0
        /// <summary>
        /// Installs the remote objects that the plugin requires on the server
        /// </summary>
        internal static void InstallRemoteLib(string library = "QGPL")
        {
            Thread thread = new Thread((ThreadStart) delegate {
                IBMiUtilities.DebugLog($"InstallRemoteLib -> {library}!");
                try
                {
                    List <string> sourceFiles = GenerateRemoteSource();

                    IBMi.RunCommands(IBMiCommandRender.RenderRemoteInstallScript(sourceFiles, library));

                    // Cleanup temp files
                    foreach (string file in sourceFiles)
                    {
                        File.Delete(file);
                    }

                    IBMi.SetConfig("installlib", library);
                } catch (Exception e) {
                    IBMiUtilities.Log(e.ToString()); // TODO: Show error?
                }
                IBMiUtilities.DebugLog("InstallRemoteLib - DONE!");

                if (Main.CommandWindow != null)
                {
                    Main.CommandWindow.loadNewOutput();
                }
            });

            thread.Start();
        }
Exemplo n.º 2
0
        private static void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
        {
            if (outLine.Data != null)
            {
                IBMiUtilities.Log(outLine.Data);
                if (outLine.Data.Length >= 5)
                {
                    if (outLine.Data.Trim() == "Not connected.")
                    {
                        if (!_NotConnected)
                        {
                            _output.Add("Not connected to " + _config["system"]);
                        }
                        _NotConnected = true;
                    }
                    else
                    {
                        switch (outLine.Data.Substring(0, 3))
                        {
                        case "125":
                            _getList = true;
                            break;

                        case "250":
                            _getList = false;
                            _output.Add("> " + outLine.Data.Substring(4));
                            break;

                        case "150":
                            _output.Add("> " + outLine.Data.Substring(4));
                            break;

                        case "426":
                        case "530":
                        case "550":
                            _Failed = outLine.Data.Substring(0, 3);
                            _output.Add("> " + outLine.Data.Substring(4));
                            break;

                        default:
                            if (_getList)
                            {
                                _list.Add(outLine.Data);
                            }
                            break;
                        }
                        if (GetConfig("experimental") == "true")
                        {
                            _output.Add("* " + outLine.Data);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        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);
        }