Пример #1
0
        void tsmi_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = sender as ToolStripMenuItem;

            if (tsmi == null || tsmi.Tag == null)
            {
                return;
            }
            if (ctxPublishes.Tag == null)
            {
                return;
            }
            int rownum = (int)ctxPublishes.Tag;

            string[] m;
            if (!GetMachineNameAndSelectedPub(rownum, out m))
            {
                return;
            }
            string machineName = m[0];
            RemotePublishLocation rpl;

            if (!PublishManager.GetRemotePublishLocationByComputerName(machineName, out rpl))
            {
                MessageBox.Show(this, "Could not find a remote publish location for " + machineName + ".", "Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (computerStatus[machineName.ToLower()].isPublishing == true)
            {
                MessageBox.Show(this, "A Publish is already in progress for this computer. Wait for it to complete...", "Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            computerStatus[machineName.ToLower()].isPublishing = true;
            Trace.WriteLine("Starting to publish : " + (string)cmbPublishes.SelectedItem);
            bool dobackup = false;



            if (Properties.Settings.Default.autoBackupPublishes)
            {
                dobackup = true;
            }
            else
            {
                DialogResult r = MessageBox.Show(this, "Create backup of publish " + (string)tsmi.Tag + " on computer " + machineName + "?", "Backup Exiting Publish", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                dobackup = (r == DialogResult.Yes);
                if (r == DialogResult.Cancel)
                {
                    computerStatus[machineName.ToLower()].isPublishing = false;
                    return;
                }
            }


            PublishManager.SendPublishToRemoteComputer(Publish.Load((string)tsmi.Tag, pubRoot), rpl, pubRoot, new EventHandler <Publisher.PublishManager.SendPublishEventArgs>(delegate(object o, Publisher.PublishManager.SendPublishEventArgs args)
            {
                this.BeginInvoke(new MethodInvoker(delegate()
                {
                    computerStatus[machineName.ToLower()].isPublishing = false;
                    Publish p = o as Publish;
                    if (args.ok)
                    {
                        MessageBox.Show(this, "The Publish " + p.name + " Succeeded.", "Publisher", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(this, "The Publish Failed. Check Trace for more info.", "Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }));
            }), dobackup);
        }
Пример #2
0
        private void btnExecutePublishLocally_Click(object sender, EventArgs e)
        {
            Publish p = Publish.Load((string)cmbPublishes.SelectedItem, pubRoot);

            p.Start(pubRoot);
        }