Ejemplo n.º 1
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (DoValidate())
            {
                SelectedRegistryQueryInstance.Name                   = txtName.Text;
                SelectedRegistryQueryInstance.UseRemoteServer        = chkUseRemoteServer.Checked;
                SelectedRegistryQueryInstance.Server                 = txtServer.Text;
                SelectedRegistryQueryInstance.Path                   = txtPath.Text;
                SelectedRegistryQueryInstance.KeyName                = txtKey.Text;
                SelectedRegistryQueryInstance.ExpandEnvironmentNames = chkExpandEnvNames.Checked;
                SelectedRegistryQueryInstance.RegistryHive           = RegistryQueryInstance.GetRegistryHiveFromString(cboRegistryHive.Text);

                if (!chkValueIsANumber.Checked)
                {
                    SelectedRegistryQueryInstance.ReturnValueIsNumber = false;
                    SelectedRegistryQueryInstance.ReturnValueInARange = false;
                    SelectedRegistryQueryInstance.ReturnValueInverted = false;
                }
                else
                {
                    SelectedRegistryQueryInstance.ReturnValueIsNumber = true;
                    SelectedRegistryQueryInstance.ReturnValueInARange = chkValueIsInARange.Checked;
                    SelectedRegistryQueryInstance.ReturnValueInverted = !chkReturnValueNotInverted.Checked;
                }

                SelectedRegistryQueryInstance.SuccessValue = cboSuccessValue.Text;
                SelectedRegistryQueryInstance.WarningValue = cboWarningValue.Text;
                SelectedRegistryQueryInstance.ErrorValue   = cboErrorValue.Text;
                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
        }
Ejemplo n.º 2
0
        private void cmdTest_Click(object sender, EventArgs e)
        {
            if (DoValidate())
            {
                string lastStep = "Initialize values";
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    RegistryQueryInstance testQueryInstance = new RegistryQueryInstance();
                    testQueryInstance.Name                   = txtName.Text;
                    testQueryInstance.UseRemoteServer        = chkUseRemoteServer.Checked;
                    testQueryInstance.Server                 = txtServer.Text;
                    testQueryInstance.Path                   = txtPath.Text;
                    testQueryInstance.KeyName                = txtKey.Text;
                    testQueryInstance.ExpandEnvironmentNames = chkExpandEnvNames.Checked;
                    testQueryInstance.RegistryHive           = RegistryQueryInstance.GetRegistryHiveFromString(cboRegistryHive.Text);

                    if (!chkValueIsANumber.Checked)
                    {
                        testQueryInstance.ReturnValueIsNumber = false;
                        testQueryInstance.ReturnValueInARange = false;
                        testQueryInstance.ReturnValueInverted = false;
                    }
                    else
                    {
                        testQueryInstance.ReturnValueIsNumber = true;
                        testQueryInstance.ReturnValueInARange = chkValueIsInARange.Checked;
                        testQueryInstance.ReturnValueInverted = !chkReturnValueNotInverted.Checked;
                    }

                    testQueryInstance.SuccessValue = cboSuccessValue.Text;
                    testQueryInstance.WarningValue = cboWarningValue.Text;
                    testQueryInstance.ErrorValue   = cboErrorValue.Text;

                    object returnValue = null;
                    returnValue = testQueryInstance.GetValue();
                    MonitorStates state = testQueryInstance.EvaluateValue(returnValue);
                    if (state == MonitorStates.Good)
                    {
                        MessageBox.Show(string.Format("Success!\r\nValue return: {0}", returnValue), "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (state == MonitorStates.Warning)
                    {
                        MessageBox.Show(string.Format("Warning!\r\nValue return: {0}", returnValue), "Test", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Error!\r\nValue return: {0}", returnValue), "Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Failed!\r\nLast step: {0}\r\n{1}", lastStep, ex.Message), "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
Ejemplo n.º 3
0
        public void ReadConfiguration(XmlDocument config)
        {
            XmlElement root = config.DocumentElement;

            Queries.Clear();
            foreach (XmlElement queryNode in root.SelectNodes("queries/query"))
            {
                RegistryQueryInstance queryEntry = new RegistryQueryInstance();
                queryEntry.Name                   = queryNode.ReadXmlElementAttr("name", "");
                queryEntry.UseRemoteServer        = bool.Parse(queryNode.ReadXmlElementAttr("useRemoteServer", "False"));
                queryEntry.Server                 = queryNode.ReadXmlElementAttr("server", "");
                queryEntry.RegistryHive           = RegistryQueryInstance.GetRegistryHiveFromString(queryNode.ReadXmlElementAttr("registryHive", ""));
                queryEntry.Path                   = queryNode.ReadXmlElementAttr("path", "");
                queryEntry.KeyName                = queryNode.ReadXmlElementAttr("keyName", "");
                queryEntry.ExpandEnvironmentNames = bool.Parse(queryNode.ReadXmlElementAttr("expandEnvironmentNames", "False"));

                queryEntry.ReturnValueIsNumber = bool.Parse(queryNode.ReadXmlElementAttr("returnValueIsNumber", "False"));
                queryEntry.SuccessValue        = queryNode.ReadXmlElementAttr("successValue", "");
                queryEntry.WarningValue        = queryNode.ReadXmlElementAttr("warningValue", "");
                queryEntry.ErrorValue          = queryNode.ReadXmlElementAttr("errorValue", "");
                queryEntry.ReturnValueInARange = bool.Parse(queryNode.ReadXmlElementAttr("returnValueInARange", "False"));
                queryEntry.ReturnValueInverted = bool.Parse(queryNode.ReadXmlElementAttr("returnValueInverted", "False"));
                Queries.Add(queryEntry);
            }
        }
Ejemplo n.º 4
0
 private void txtPath_Leave(object sender, EventArgs e)
 {
     if (txtPath.Text.Length > 0 && txtPath.Text.ToUpper().StartsWith("HKEY_"))
     {
         string[] parts = txtPath.Text.Split('\\');
         if (parts.Length > 1)
         {
             Microsoft.Win32.RegistryHive rh = RegistryQueryInstance.GetRegistryHiveFromString(parts[0]);
             cboRegistryHive.Text = rh.ToString();
             txtPath.Text         = txtPath.Text.Substring(parts[0].Length + 1);
         }
     }
 }
Ejemplo n.º 5
0
        private void LoadList()
        {
            if (SelectedRegistryQueryConfig != null)
            {
                lvwQueries.Items.Clear();

                foreach (RegistryQueryInstance queryInstance in SelectedRegistryQueryConfig.Queries)
                {
                    ListViewItem lvi = new ListViewItem(queryInstance.Name);
                    lvi.SubItems.Add((queryInstance.UseRemoteServer ? queryInstance.Server + "\\" : "") + RegistryQueryInstance.GetRegistryHiveFromString(queryInstance.RegistryHive.ToString()).ToString() + "\\" + queryInstance.Path);
                    lvi.SubItems.Add(queryInstance.KeyName);
                    lvi.SubItems.Add(queryInstance.SuccessValue);
                    lvi.SubItems.Add(queryInstance.WarningValue);
                    lvi.SubItems.Add(queryInstance.ErrorValue);
                    lvi.Tag = queryInstance;
                    lvwQueries.Items.Add(lvi);
                }
                CheckOKEnabled();
            }
        }
Ejemplo n.º 6
0
 private void editToolStripButton_Click(object sender, EventArgs e)
 {
     if (lvwQueries.SelectedItems.Count > 0 && lvwQueries.SelectedItems[0].Tag is RegistryQueryInstance)
     {
         EditRegistryQueryInstance editQueryInstance = new EditRegistryQueryInstance();
         editQueryInstance.SelectedRegistryQueryInstance = (RegistryQueryInstance)lvwQueries.SelectedItems[0].Tag;
         if (editQueryInstance.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             ListViewItem lvi = lvwQueries.SelectedItems[0];
             lvi.Text             = editQueryInstance.SelectedRegistryQueryInstance.Name;
             lvi.SubItems[1].Text = (editQueryInstance.SelectedRegistryQueryInstance.UseRemoteServer ? editQueryInstance.SelectedRegistryQueryInstance.Server + "\\" : "") + RegistryQueryInstance.GetRegistryHiveFromString(editQueryInstance.SelectedRegistryQueryInstance.RegistryHive.ToString()).ToString() + "\\" + editQueryInstance.SelectedRegistryQueryInstance.Path;
             lvi.SubItems[2].Text = editQueryInstance.SelectedRegistryQueryInstance.KeyName;
             lvi.SubItems[3].Text = editQueryInstance.SelectedRegistryQueryInstance.SuccessValue;
             lvi.SubItems[4].Text = editQueryInstance.SelectedRegistryQueryInstance.WarningValue;
             lvi.SubItems[5].Text = editQueryInstance.SelectedRegistryQueryInstance.ErrorValue;
             lvi.Tag = editQueryInstance.SelectedRegistryQueryInstance;
         }
     }
 }
Ejemplo n.º 7
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            EditRegistryQueryInstance editQueryInstance = new EditRegistryQueryInstance();

            editQueryInstance.SelectedRegistryQueryInstance = new RegistryQueryInstance();
            if (editQueryInstance.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ListViewItem lvi = new ListViewItem(editQueryInstance.SelectedRegistryQueryInstance.Name);
                lvi.SubItems.Add((editQueryInstance.SelectedRegistryQueryInstance.UseRemoteServer ? editQueryInstance.SelectedRegistryQueryInstance.Server + "\\" : "") + RegistryQueryInstance.GetRegistryHiveFromString(editQueryInstance.SelectedRegistryQueryInstance.RegistryHive.ToString()).ToString() + "\\" + editQueryInstance.SelectedRegistryQueryInstance.Path);
                lvi.SubItems.Add(editQueryInstance.SelectedRegistryQueryInstance.KeyName);
                lvi.SubItems.Add(editQueryInstance.SelectedRegistryQueryInstance.SuccessValue);
                lvi.SubItems.Add(editQueryInstance.SelectedRegistryQueryInstance.WarningValue);
                lvi.SubItems.Add(editQueryInstance.SelectedRegistryQueryInstance.ErrorValue);
                lvi.Tag = editQueryInstance.SelectedRegistryQueryInstance;
                lvwQueries.Items.Add(lvi);
                CheckOKEnabled();
                CheckButtonsEnable();
            }
        }
Ejemplo n.º 8
0
 private void LoadList()
 {
     if (SelectedRegistryQueryConfig != null)
     {
         lvwDetails.Items.Clear();
         foreach (RegistryQueryInstance rq in SelectedRegistryQueryConfig.Queries)
         {
             ListViewItem lvi = new ListViewItem(rq.Name);
             lvi.SubItems.Add((rq.UseRemoteServer ? "[" + rq.Server + "]\\" : "") + RegistryQueryInstance.GetRegistryHiveFromString(rq.RegistryHive.ToString()).ToString() + "\\" + rq.Path + "\\@[" + rq.KeyName + "]");
             lvi.SubItems.Add("-");
             lvi.Tag = rq;
             lvwDetails.Items.Add(lvi);
         }
     }
     RefreshList();
 }