Пример #1
0
 private void userSettings_Load(object sender, EventArgs e)
 {
     textBox1.Text        = IBMi.GetConfig("system");
     textBox2.Text        = IBMi.GetConfig("username");
     textBox3.Text        = IBMi.GetConfig("password");
     numericUpDown1.Value = Convert.ToInt32(IBMi.GetConfig("clrcdlen"));
 }
Пример #2
0
        private static string replaceVars(string cmd)
        {
            OpenMember currentMember = null;
            string     path          = Path.GetFileName(NppFunctions.GetCurrentFileName());

            string[] name;

            if (path.Contains("."))
            {
                name = path.Split('.');
            }
            else
            {
                name    = new string[2];
                name[0] = path;
                name[1] = "";
            }

            cmd = cmd.Replace("%file%", name[0]);
            cmd = cmd.Replace("%ext%", name[1]);

            cmd = cmd.Replace("%host%", IBMi.GetConfig("system"));
            cmd = cmd.Replace("%user%", IBMi.GetConfig("user"));
            cmd = cmd.Replace("%curlib%", IBMi.GetConfig("curlib"));

            if (OpenMembers.Contains(path))
            {
                currentMember = OpenMembers.GetMember(path);
                cmd           = cmd.Replace("%openlib%", currentMember.GetLibrary());
                cmd           = cmd.Replace("%openspf%", currentMember.GetObject());
                cmd           = cmd.Replace("%openmbr%", currentMember.GetMember());
            }

            return(cmd);
        }
Пример #3
0
        public uploadMember()
        {
            InitializeComponent();
            StringBuilder path = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);

            if (!OpenMembers.Contains(path.ToString()))
            {
                MessageBox.Show("Unable to save this file to a member. You are only able to save to member which has been opened in this same Notepad++ session.");
                this._CloseOnShow = true; return;
            }

            this._Member = OpenMembers.GetMember(path.ToString());

            if (this._Member.GetSystemName() != IBMi.GetConfig("system"))
            {
                MessageBox.Show("You can only save this member when you are connected to " + this._Member.GetSystemName() + ".");
                this._CloseOnShow = true; return;
            }

            textBox1.Text = this._Member.GetLibrary();
            textBox2.Text = this._Member.GetObject();
            textBox3.Text = this._Member.GetMember();
            textBox4.Text = this._Member.GetSystemName();
            textBox5.Text = Path.GetFileName(this._Member.GetLocalFile());
        }
Пример #4
0
        private void OpenMember(string Lib, string Obj, string Mbr, Boolean Editing)
        {
            Thread gothread = new Thread((ThreadStart) delegate {
                string resultFile = IBMiUtilities.DownloadMember(Lib, Obj, Mbr);
                if (Main.CommandWindow != null)
                {
                    Main.CommandWindow.loadNewOutput();
                }

                if (resultFile != "")
                {
                    NppFunctions.OpenFile(resultFile, !Editing);
                    if (Editing)
                    {
                        OpenMembers.AddMember(IBMi.GetConfig("system"), resultFile, Lib, Obj, Mbr);
                    }
                }
                else
                {
                    MessageBox.Show("Unable to download member " + Lib + "/" + Obj + "." + Mbr + ". Please check it exists and that you have access to the remote system.");
                }
            });

            gothread.Start();
        }
Пример #5
0
 private void userSettings_Load(object sender, EventArgs e)
 {
     textBox1.Text = IBMi.GetConfig("system");
     textBox2.Text = IBMi.GetConfig("username");
     textBox3.Text = IBMi.GetConfig("password");
     textBox4.Text = IBMi.GetConfig("relicdir");
     textBox5.Text = IBMi.GetConfig("reliclib");
 }
Пример #6
0
        public static void HandleTrigger(SCNotification Notification)
        {
            Thread     gothread;
            string     path = GetCurrentFileName();
            OpenMember member;

            switch (Notification.nmhdr.code)
            {
            case (uint)NppMsg.NPPN_READY:
                break;

            case (uint)SciMsg.SCN_MODIFIED:
                break;

            case (uint)NppMsg.NPPN_FILEBEFOREOPEN:
                break;

            case (uint)NppMsg.NPPN_FILEOPENED:
                break;

            case (uint)NppMsg.NPPN_FILESAVED:
                member = OpenMembers.GetMember(path);
                if (member != null)
                {
                    gothread = new Thread((ThreadStart) delegate {
                        if (member.IsEditable())
                        {
                            if (member.GetSystemName() == IBMi.GetConfig("system"))
                            {
                                bool UploadResult = IBMiUtilities.UploadMember(member.GetLocalFile(), member.GetLibrary(), member.GetObject(), member.GetMember());
                                if (UploadResult == false)
                                {
                                    System.Windows.Forms.MessageBox.Show("Failed to upload to " + member.GetMember() + " on " + member.GetSystemName() + ".");
                                }
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Unable to upload to " + member.GetMember() + ". You must be connected to " + member.GetSystemName() + " in order to save this file.");
                            }
                            if (Main.CommandWindow != null)
                            {
                                Main.CommandWindow.loadNewOutput();
                            }
                        }
                    });
                    gothread.Start();
                }
                break;

            case (uint)NppMsg.NPPN_FILEBEFORECLOSE:
                if (OpenMembers.Contains(path))
                {
                    OpenMembers.RemoveMember(path);
                    File.Delete(path);
                }
                break;
            }
        }
Пример #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            label2.Text = "";
            label2.Update();

            //Add a default library
            if (listBox1.Items.Count == 0)
            {
                listBox1.Items.Add("SYSTOOLS");
            }

            string s = "";

            foreach (string item in listBox1.Items)
            {
                if (IBMiUtilities.IsValidQSYSObjectName(item.Trim()))
                {
                    s += item.Trim() + ',';
                }
                else
                {
                    label2.Text = "Invalid library: " + item.Trim();
                    label2.Update();
                    return;
                }
            }

            if (!IBMiUtilities.IsValidQSYSObjectName(textBox2.Text.Trim()))
            {
                label2.Text = "Invalid current library.";
                label2.Update();
                return;
            }

            string origLibl = IBMi.GetConfig("datalibl");
            string origCur  = IBMi.GetConfig("curlib");

            IBMi.SetConfig("datalibl", s.Remove(s.Length - 1, 1)); //Remove last comma
            IBMi.SetConfig("curlib", textBox2.Text.Trim());        //Remove last comma

            Boolean hasFailed = IBMi.RunCommands(new string[0]);

            if (hasFailed)
            {
                IBMi.SetConfig("datalibl", origLibl);
                IBMi.SetConfig("curlib", origCur);

                MessageBox.Show("Library list contains invalid libraries.", "Library list", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (Main.CommandWindow != null)
                {
                    Main.CommandWindow.loadNewOutput();
                }
            }
            else
            {
                this.Close();
            }
        }
Пример #8
0
        private static OpenMember HandleRPG(string Copy)
        {
            if (Copy.StartsWith("/COPY") || Copy.StartsWith("/INCLUDE"))
            {
                string   lib, obj, mbr;
                string[] data = Copy.Split(' ');
                string[] pieces;

                if (data.Length != 2)
                {
                    return(null);
                }
                data[1] = data[1].Trim();

                pieces = data[1].Split(',');
                if (pieces.Length == 2)
                {
                    mbr    = pieces[1];
                    obj    = pieces[0];
                    pieces = pieces[0].Split('/');
                    if (pieces.Length == 2)
                    {
                        obj = pieces[1];
                        lib = pieces[0];
                    }
                    else
                    {
                        lib = "*CURLIB";
                    }
                }
                else
                {
                    mbr = data[1];
                    obj = "QRPGLESRC";
                    lib = "*CURLIB";
                }

                if (lib == "*CURLIB")
                {
                    lib = IBMi.GetConfig("curlib");
                }

                if (IBMiUtilities.IsValidQSYSObjectName(lib) && IBMiUtilities.IsValidQSYSObjectName(obj) && IBMiUtilities.IsValidQSYSObjectName(mbr))
                {
                    return(new OpenMember("", "", lib, obj, mbr));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #9
0
        private void libraryList_Load(object sender, EventArgs e)
        {
            this.Text = "Library List for " + IBMi.GetConfig("system");

            string[] libl = IBMi.GetConfig("datalibl").Split(',');
            foreach (string lib in libl)
            {
                listBox1.Items.Add(lib);
            }

            textBox2.Text = IBMi.GetConfig("curlib");
        }
Пример #10
0
        private void wrkwithBind(object sender, System.EventArgs e)
        {
            if (treeView1.SelectedNode != null)
            {
                editingBind     = treeView1.SelectedNode.Text;
                editingBindCmds = IBMi.GetConfig(editingBind).Split('|');

                wrkWithBind();

                treeView1.SelectedNode.Tag = string.Join("|", editingBindCmds);
            }
            else
            {
                MessageBox.Show("Please select a binding to edit.");
            }
        }
Пример #11
0
        public void publishErrors()
        {
            Invoke((MethodInvoker) delegate
            {
                int totalErrors = 0;
                TreeNode curNode;

                treeView1.Nodes.Clear(); //Clear out the nodes

                //Add the node that allows object change
                curNode                    = new TreeNode("Double click to change object");
                curNode.Tag                = "CHG";
                curNode.ImageIndex         = 0;
                curNode.SelectedImageIndex = 0;
                treeView1.Nodes.Add(curNode);

                //Add the errors
                TreeNode curErr;
                foreach (int fileid in ErrorHandle.getFileIDs())
                {
                    curNode = new TreeNode(ErrorHandle.getFilePath(fileid));
                    foreach (LineError error in ErrorHandle.getErrors(fileid))
                    {
                        if (error.getSev() >= 20)
                        {
                            totalErrors              += 1;
                            curErr                    = curNode.Nodes.Add(error.getCode() + ": " + error.getData().Trim() + " (" + error.getLine().ToString() + ")");
                            curErr.Tag                = error.getLine().ToString() + ',' + error.getColumn().ToString();
                            curErr.ImageIndex         = 2;
                            curErr.SelectedImageIndex = 2;
                        }
                    }

                    //Only add a node if there is something to display
                    if (curNode.Nodes.Count > 0)
                    {
                        curNode.ImageIndex         = 1;
                        curNode.SelectedImageIndex = 1;
                        treeView1.Nodes.Add(curNode);
                    }
                }

                toolStripStatusLabel1.Text = "Total errors: " + totalErrors.ToString();
                toolStripStatusLabel2.Text = IBMi.GetConfig("system") + ":" + ErrorHandle.doName();
                toolStripStatusLabel3.Text = DateTime.Now.ToString("h:mm:ss tt");
            });
        }
Пример #12
0
        public void cmdBindings_Load()
        {
            TreeNode curNode;

            bindings = new List <string>();

            foreach (string bind in IBMi.GetConfig("binds").Split('|'))
            {
                bindings.Add(bind.Trim());
            }
            treeView1.Nodes.Clear();
            foreach (string bind in bindings)
            {
                curNode     = treeView1.Nodes.Add(bind);
                curNode.Tag = IBMi.GetConfig(bind);
            }
        }
Пример #13
0
        public static void getErrors(string lib, string obj)
        {
            string filetemp = Path.GetTempFileName();

            List <string> commands = new List <string>();

            lib = lib.Trim().ToUpper();
            obj = obj.Trim().ToUpper();

            if (lib == "*CURLIB")
            {
                lib = IBMi.GetConfig("curlib");
            }

            commands.Add("ASCII");
            commands.Add("cd /QSYS.lib");
            commands.Add("recv \"" + lib + ".lib/EVFEVENT.file/" + obj + ".mbr\" \"" + filetemp + "\"");

            IBMi.RunCommands(commands.ToArray());

            ErrorHandle.doName(lib.ToUpper() + '/' + obj.ToUpper());
            ErrorHandle.setLines(File.ReadAllLines(filetemp));
        }
Пример #14
0
 private void installRemote_Load(object sender, EventArgs e)
 {
     textBox1.Text = IBMi.GetConfig("installlib");
 }
Пример #15
0
 public openMember()
 {
     InitializeComponent();
     textBox4.Text     = IBMi.GetConfig("system");
     checkBox1.Checked = true;
 }
Пример #16
0
 private void libraryList_Load(object sender, EventArgs e)
 {
     textBox1.Text = IBMi.GetConfig("datalibl");
     textBox2.Text = IBMi.GetConfig("curlib");
 }
Пример #17
0
 public void UpdateSystemName()
 {
     toolStripLabel1.Text = IBMi.GetConfig("system");
     listView1.Clear();
 }