Exemplo n.º 1
0
        private void pushButton_Click(object sender, EventArgs e)
        {
            string        LocalFile;
            List <string> Commands = new List <string>();
            Dictionary <string, string> PushList = new Dictionary <string, string>();

            string[] Path;

            if (runCommands.Checked)
            {
                foreach (var Member in CreateSPFs)
                {
                    Commands.Add("CRTSRCPF FILE(" + lib.Text.Trim() + "/" + Member.Key + ") RCDLEN(" + Member.Value.ToString() + ")");
                }

                foreach (string Member in DeleteMembers)
                {
                    Path = Member.Split('/');
                    Commands.Add("RMVM FILE(" + lib.Text.Trim() + "/" + Path[0] + ") MBR(" + Path[1] + ")");
                }

                foreach (var Member in CreateMembers)
                {
                    Path = Member.Key.Trim().Split('/');
                    Commands.Add("ADDPFM FILE(" + lib.Text.Trim() + "/" + Path[0] + ") MBR(" + Path[1] + ") SRCTYPE(" + Member.Value.Trim() + ")");
                }
            }

            foreach (ListViewItem Member in memberLog.Items)
            {
                if (Member.Checked)
                {
                    Path      = Member.Text.Trim().Split('/');
                    LocalFile = IBMiUtils.GetLocalFile(lib.Text.Trim(), Path[0], Path[1], UploadMembers[Path[0] + '/' + Path[1]]);
                    PushList.Add(LocalFile, "/QSYS.lib/" + lib.Text.Trim() + ".lib/" + Path[0] + ".file/" + Path[1] + ".mbr");
                }
            }

            Boolean Success = IBMi.RunCommands(Commands.ToArray());

            if (Success)
            {
                foreach (var File in PushList)
                {
                    if (IBMi.UploadFile(File.Key, File.Value) == false)
                    {
                        Success = false;
                    }
                }

                if (Success)
                {
                    MessageBox.Show("Push to server was successful.");
                    MemberCache.EditsClear();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Push to server was not successful (stage 2)");
                }
            }
            else
            {
                MessageBox.Show("Push to server was not successful (stage 1)");
            }
        }
Exemplo n.º 2
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!IBMiUtils.IsValueObjectName(objectName.Text))
            {
                MessageBox.Show("Object name is not valid.");
                objectName.Focus();
                return;
            }
            if (objectType.Text == "")
            {
                MessageBox.Show("Object type is not valid.");
                objectType.Focus();
                return;
            }
            if (IBMiUtils.IsValueObjectName(objectLib.Text) == false && objectLib.Text != "*LIBL")
            {
                MessageBox.Show("Object library name is not valid.");
                objectLib.Focus();
                return;
            }
            if (objectActivation.Text == "")
            {
                MessageBox.Show("Object activation is not valid.");
                objectType.Focus();
                return;
            }

            BindingEntry Entry = new BindingEntry();

            Entry.BindingLib   = Library;
            Entry.BindingObj   = Object;
            Entry.Name         = objectName.Text.Trim();
            Entry.Library      = objectLib.Text.Trim();
            Entry.Type         = objectType.Text;
            Entry.Activation   = objectActivation.Text;
            Entry.CreationDate = "";
            Entry.CreationTime = "";

            string command  = "ADDBNDDIRE BNDDIR(" + Library + "/" + Object + ") OBJ((" + Entry.Library + "/" + Entry.Name + " " + Entry.Type + " " + Entry.Activation + "))";
            Thread gothread = new Thread((ThreadStart) delegate
            {
                if (IBMi.RunCommands(new string[1] {
                    command
                }) == false)
                {
                    ListViewItem Item = new ListViewItem(new string[6] {
                        Entry.Name, Entry.Type, Entry.Library, Entry.Activation, Entry.CreationDate, Entry.CreationTime
                    });
                    Item.Tag = Entry;
                    this.Invoke((MethodInvoker) delegate
                    {
                        entriesList.Items.Add(Item);
                    });
                }
                else
                {
                    MessageBox.Show("Unable to create binding entry.");
                }
            });

            gothread.Start();
        }