Exemple #1
0
        public void isValidQSYSObjectNameTest()
        {
            string testInput = null; // null

            Assert.IsFalse(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = ""; // empty
            Assert.IsFalse(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "1asd"; // begins with #
            Assert.IsFalse(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "abcdefghjklmno"; // too long
            Assert.IsFalse(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "a"; // Valid
            Assert.IsTrue(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "abc123"; // Valid
            Assert.IsTrue(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "abc_123"; // Valid
            Assert.IsTrue(IBMiUtilities.IsValidQSYSObjectName(testInput));

            testInput = "abc_123_zz"; // Valid
            Assert.IsTrue(IBMiUtilities.IsValidQSYSObjectName(testInput));
        }
Exemple #2
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();
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!IBMiUtilities.IsValidQSYSObjectName(toolStripTextBox1.Text))
            {
                MessageBox.Show("Library name is not valid.");
                return;
            }
            if (!IBMiUtilities.IsValidQSYSObjectName(toolStripTextBox2.Text))
            {
                MessageBox.Show("Object name is not valid.");
                return;
            }

            UpdateListing(toolStripTextBox1.Text, toolStripTextBox2.Text);
        }
Exemple #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            string installLibrary = "";

            if (IBMiUtilities.IsValidQSYSObjectName(textBox1.Text.Trim()))
            {
                installLibrary += textBox1.Text.Trim();
            }
            else
            {
                label1.Text += " - Invalid Library Specified";
                label1.Update();
                return;
            }

            IBMiNPPInstaller.InstallRemoteLib(installLibrary);

            this.Close();
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.isReadonly = checkBox1.Checked;
            textBox1.Text   = textBox1.Text.ToUpper();
            textBox2.Text   = textBox2.Text.ToUpper();
            textBox3.Text   = textBox3.Text.ToUpper();

            if (!IBMiUtilities.IsValidQSYSObjectName(textBox1.Text))
            {
                MessageBox.Show("Library name is not valid.");
                return;
            }
            if (!IBMiUtilities.IsValidQSYSObjectName(textBox2.Text))
            {
                MessageBox.Show("Object name is not valid.");
                return;
            }
            if (!IBMiUtilities.IsValidQSYSObjectName(textBox3.Text))
            {
                MessageBox.Show("Member name is not valid.");
                return;
            }

            string resultFile = IBMiUtilities.DownloadMember(textBox1.Text, textBox2.Text, textBox3.Text);

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

            if (resultFile != "")
            {
                //Open File
                NppFunctions.OpenFile(resultFile, this.isReadonly);
                OpenMembers.AddMember(textBox4.Text, resultFile, textBox1.Text, textBox2.Text, textBox3.Text, !this.isReadonly);

                this.Close();
            }
            else
            {
                MessageBox.Show("Unable to download member " + textBox1.Text + "/" + textBox2.Text + "." + textBox3.Text + ". Please check it exists and that you have access to the remote system.");
            }
        }
Exemple #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            label2.Text = "";
            label2.Update();

            string s = "";

            foreach (string item in textBox1.Text.Trim().Split(','))
            {
                if (IBMiUtilities.IsValidQSYSObjectName(item.Trim()))
                {
                    s += item.Trim() + ',';
                }
                else
                {
                    label2.Text = "Invalid Library List Syntax. Valid syntax is < LIB,LIB,LIB >";
                    label2.Update();
                    return;
                }
            }

            if (IBMiUtilities.IsValidQSYSObjectName(textBox2.Text.Trim()))
            {
                IBMi.SetConfig("curlib", textBox2.Text.Trim()); //Remove last comma
            }
            else
            {
                label2.Text = "Invalid Current Library Syntax. Valid syntax is < LIB >";
                label2.Update();
                return;
            }

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

            this.Close();
        }
Exemple #8
0
        public static string GetCommandAtColumn(string curLine, int curPos)
        {
            if (curPos > curLine.Length)
            {
                return("");
            }
            StringBuilder sb = new StringBuilder();

            // Scan Backwards
            for (int i = curPos; i >= 0; i--)
            {
                if (i == curPos && curLine[i] == ' ')
                {
                    return("");
                }
                else
                {
                    if (curLine[i] == ' ' || curLine[i] == '\'')
                    {
                        break;
                    }
                    else
                    {
                        sb.Append(curLine[i]);
                    }
                }
            }

            // Scan Forward
            for (int i = curPos + 1; i < curLine.Length; i++)
            {
                if (i == curPos && curLine[i] == ' ')
                {
                    break;
                }
                else
                {
                    if (curLine[i] == ' ' || curLine[i] == '\'')
                    {
                        break;
                    }
                    else
                    {
                        sb.Insert(0, curLine[i]);
                    }
                }
            }

            char[] buffer = sb.ToString().ToCharArray();
            Array.Reverse(buffer);
            string command = new string(buffer);

            if (IBMiUtilities.IsValidQSYSObjectName(command))
            {
                return(command);
            }
            else
            {
                return("");
            }
        }