Exemple #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)");
            }
        }