Esempio n. 1
0
        private void btnNextPRG_Click(object sender, EventArgs e)
        {

            int i = 1;

            RBCXMLGen.SCOService.OrchestratorContext context = new RBCXMLGen.SCOService.OrchestratorContext(new Uri(serviceRoot));
            context.Credentials = new System.Net.NetworkCredential(user, password, domain);

            foreach (object itemChecked in cblPRG.CheckedItems)
            {
                try
                {
                    var runbooks2 = from runbook in context.Runbooks
                                    where runbook.Name == itemChecked.ToString()
                                    select runbook;

                    foreach (var item in runbooks2)
                    {
                        dictionary.Add(item.Id, item.Name);

                        Label lblLable = new Label();
                        lblLable.Name = i.ToString();
                        lblLable.Location = new System.Drawing.Point(439, intVertOffSetPRG);
                        lblLable.Text = itemChecked.ToString();
                        this.tabPRG.Controls.Add(lblLable);

                        TextBox txtBox = new TextBox();
                        txtBox.Name = itemChecked.ToString();
                        txtBox.Location = new System.Drawing.Point(553, intVertOffSetPRG);
                        this.tabPRG.Controls.Add(txtBox);
                    }

                    intVertOffSetPRG += 30;
                    i++;
                }
                catch
                {
                    MessageBox.Show("Error: Runbook has already been added to the CM formatting list. Please uncheck any duplicate Runbooks.");
                }

            }

        }
Esempio n. 2
0
        private void btnFetch_Click(object sender, EventArgs e)
        {
            if (rb2007.Checked)
            {
                genPass = 1;
            }

            if (rb2012.Checked)
            {
                genPass = 1;
            }

            if (genPass == 0)
            {
                MessageBox.Show("Select CM Platform");
                return;
            }
            else
            {
                if (rb2012.Checked)
                {
                    try
                    {
                        RegistryKey rk1 = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\ConfigMgr10\\Setup");
                        adminUI = (rk1.GetValue("UI Installation Directory").ToString());
                    }
                    catch
                    {
                        try
                        {
                            RegistryKey rk2 = Registry.LocalMachine.CreateSubKey("Software\\Wow6432Node\\Microsoft\\ConfigMgr10\\Setup");
                            adminUI = (rk2.GetValue("UI Installation Directory").ToString());

                        }
                        catch
                        {
                            MessageBox.Show("Error: CM 2012 Console not found, or the execution account does not have permissions to read from the registry.");
                            this.Close();
                        }
                    }
                }

                if (rb2007.Checked)
                {
                    try
                    {
                        RegistryKey rk1 = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\ConfigMgr\\Setup");
                        adminUI = (rk1.GetValue("UI Installation Directory").ToString());
                    }
                    catch
                    {
                        try
                        {
                            RegistryKey rk2 = Registry.LocalMachine.CreateSubKey("Software\\Wow6432Node\\Microsoft\\ConfigMgr\\Setup");
                            adminUI = (rk2.GetValue("UI Installation Directory").ToString());

                        }
                        catch
                        {
                            MessageBox.Show("Error: CM 2007 Console not found, or the execution account does not have permissions to read from the registry.");
                            this.Close();
                        }
                    }
                }
            }

            try
            {
                serviceRoot = txtURL.Text;
                user = txtUserName.Text;
                password = txtPassword.Text;
                domain = txtDomain.Text;

                RBCXMLGen.SCOService.OrchestratorContext context = new RBCXMLGen.SCOService.OrchestratorContext(new Uri(serviceRoot));
                context.Credentials = new System.Net.NetworkCredential(user, password, domain);

                //Gather a list of all Runbooks
                var runbooks = from runbook in context.Runbooks
                               select runbook;

                //Gather a list of all Parameters
                var paramaters = from runbookparameter in context.RunbookParameters
                                 select runbookparameter;


                foreach (var item in paramaters)
                {
                    if (item.Name == "Computer Name:")
                    {
                        foreach (var item2 in runbooks)
                        {
                            if (item2.Id == item.RunbookId)
                            {
                                cblCOM.Items.Add(item2.Name);
                            }
                        }
                    }



                    if (item.Name == "Collection ID:")
                    {
                        foreach (var item2 in runbooks)
                        {
                            if (item2.Id == item.RunbookId)
                            {
                                cblCOL.Items.Add(item2.Name);
                            }
                        }
                    }


                    if (item.Name == "Program Name:")
                    {
                        foreach (var item2 in runbooks)
                        {
                            if (item2.Id == item.RunbookId)
                            {
                                cblPRG.Items.Add(item2.Name);
                            }
                        }
                    }
                }

            }
            catch
            {
                MessageBox.Show("Error: Web Service URL may be entered incorrectly, proper permission has not been established, or credentials have been entered incorrectly.");
            }

        }