Beispiel #1
0
        void BtnApplyClick(object sender, EventArgs e)
        {
            //Applies the tag to the systems in the list
            try {
                if (cboTags.Text != "" & this.mcafeeApi != null)
                {
                    if (this.mcafeeApi.doesTagExist(cboTags.Text) == false)
                    {
                        DialogResult createTag = MessageBox.Show(string.Format("Tag {0} does not exist.\n\nDo you want to create tag now?", cboTags.Text),
                                                                 "Tag missing", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);

                        if (createTag == DialogResult.Yes)
                        {
                            this.mcafeeApi.CreateTag(cboTags.Text);
                        }
                        else
                        {
                            return;
                        }
                    }
                    int numApplied = mcafeeApi.ApplyTag(rtbSystems.Lines.ToList(), cboTags.Text);
                    if (chkVerify.Checked == true)
                    {
                        VerifyTag("Apply", cboTags.Text);
                    }
                    MessageBox.Show(string.Format("Tag {0} applied to {1} machine(s).", cboTags.Text, numApplied), string.Format("Applied: {0}", cboTags.Text), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }