Exemple #1
0
        public void ReadConfiguration(string configurationString)
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(configurationString);
            XmlElement root = config.DocumentElement;

            Entries.Clear();
            foreach (XmlElement queryNode in root.SelectNodes("directoryServices/query"))
            {
                DirectoryServicesQueryCollectorConfigEntry dirSrvsQryEntry = new DirectoryServicesQueryCollectorConfigEntry();
                dirSrvsQryEntry.Name                = queryNode.ReadXmlElementAttr("name", "");
                dirSrvsQryEntry.DomainController    = queryNode.ReadXmlElementAttr("domainController", "");
                dirSrvsQryEntry.PropertiesToLoad    = queryNode.ReadXmlElementAttr("propertiesToLoad", "sAMAccountName");
                dirSrvsQryEntry.UseRowCountAsValue  = queryNode.ReadXmlElementAttr("useRowCountAsValue", false);
                dirSrvsQryEntry.MaxRowsToEvaluate   = queryNode.ReadXmlElementAttr("maxRows", 1);
                dirSrvsQryEntry.ReturnCheckSequence = CollectorReturnValueCompareEngine.CheckSequenceTypeFromString(queryNode.ReadXmlElementAttr("returnCheckSequence", "gwe"));
                XmlNode queryFilterNode = queryNode.SelectSingleNode("queryFilter");
                dirSrvsQryEntry.QueryFilterText = queryFilterNode.InnerText;
                XmlNode goodConditionNode = queryNode.SelectSingleNode("goodCondition");
                dirSrvsQryEntry.GoodResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(goodConditionNode.ReadXmlElementAttr("resultMatchType", "match"));
                dirSrvsQryEntry.GoodScriptText      = goodConditionNode.InnerText;
                XmlNode warningConditionNode = queryNode.SelectSingleNode("warningCondition");
                dirSrvsQryEntry.WarningResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(warningConditionNode.ReadXmlElementAttr("resultMatchType", "match"));
                dirSrvsQryEntry.WarningScriptText      = warningConditionNode.InnerText;
                XmlNode errorConditionNode = queryNode.SelectSingleNode("errorCondition");
                dirSrvsQryEntry.ErrorResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(errorConditionNode.ReadXmlElementAttr("resultMatchType", "match"));
                dirSrvsQryEntry.ErrorScriptText      = errorConditionNode.InnerText;
                Entries.Add(dirSrvsQryEntry);
            }
        }
        internal CollectorState GetState(string scriptResultText)
        {
            return(CollectorReturnValueCompareEngine.GetState(ReturnCheckSequence,
                                                              GoodResultMatchType, GoodScriptText,
                                                              WarningResultMatchType, WarningScriptText,
                                                              ErrorResultMatchType, ErrorScriptText,
                                                              scriptResultText));

            //CollectorState currentState = CollectorState.Good;

            //if (ReturnCheckSequence == ReturnCheckSequenceType.GWE)
            //{
            //    if (MatchGoodResult(scriptResultText))
            //        currentState = CollectorState.Good;
            //    else if (MatchWarningResult(scriptResultText))
            //        currentState = CollectorState.Warning;
            //    else
            //        currentState = CollectorState.Error;
            //}
            //else
            //{
            //    if (MatchErrorResult(scriptResultText))
            //        currentState = CollectorState.Error;
            //    else if (MatchWarningResult(scriptResultText))
            //        currentState = CollectorState.Warning;
            //    else
            //        currentState = CollectorState.Good;
            //}
            //return currentState;
        }
Exemple #3
0
        public void ReadConfiguration(string configurationString)
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(configurationString);
            Entries.Clear();
            XmlElement root = config.DocumentElement;

            foreach (XmlElement powerShellScriptRunnerNode in root.SelectNodes("powerShellScripts/powerShellScriptRunner"))
            {
                PowerShellScriptRunnerEntry entry = new PowerShellScriptRunnerEntry();
                entry.Name = powerShellScriptRunnerNode.ReadXmlElementAttr("name", "");
                entry.ReturnCheckSequence = CollectorReturnValueCompareEngine.CheckSequenceTypeFromString(powerShellScriptRunnerNode.ReadXmlElementAttr("returnCheckSequence", "gwe"));
                XmlNode testScriptNode = powerShellScriptRunnerNode.SelectSingleNode("testScript");
                entry.TestScript = testScriptNode.InnerText;

                XmlNode goodScriptNode = powerShellScriptRunnerNode.SelectSingleNode("goodScript");
                entry.GoodResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(goodScriptNode.ReadXmlElementAttr("resultMatchType", "match"));
                entry.GoodScriptText      = goodScriptNode.InnerText;

                XmlNode warningScriptNode = powerShellScriptRunnerNode.SelectSingleNode("warningScript");
                entry.WarningResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(warningScriptNode.ReadXmlElementAttr("resultMatchType", "match"));
                entry.WarningScriptText      = warningScriptNode.InnerText;

                XmlNode errorScriptNode = powerShellScriptRunnerNode.SelectSingleNode("errorScript");
                entry.ErrorResultMatchType = CollectorReturnValueCompareEngine.MatchTypeFromString(errorScriptNode.ReadXmlElementAttr("resultMatchType", "match"));
                entry.ErrorScriptText      = errorScriptNode.InnerText;

                Entries.Add(entry);
            }
        }
 public CollectorState GetState(object value)
 {
     return(CollectorReturnValueCompareEngine.GetState(ReturnCheckSequence,
                                                       GoodResultMatchType, GoodScriptText,
                                                       WarningResultMatchType, WarningScriptText,
                                                       ErrorResultMatchType, ErrorScriptText,
                                                       value));
 }
Exemple #5
0
        private void DirectoryServicesQueryEditEntry_Load(object sender, EventArgs e)
        {
            DirectoryServicesQueryCollectorConfigEntry selectedEntry = (DirectoryServicesQueryCollectorConfigEntry)SelectedEntry;

            #region Load Match types
            cboSuccessMatchType.Items.Clear();
            cboSuccessMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboSuccessMatchType.Items.Count > 0)
            {
                cboSuccessMatchType.SelectedIndex = 0;
            }
            cboWarningMatchType.Items.Clear();
            cboWarningMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboWarningMatchType.Items.Count > 0)
            {
                cboWarningMatchType.SelectedIndex = 0;
            }
            cboErrorMatchType.Items.Clear();
            cboErrorMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboErrorMatchType.Items.Count > 0)
            {
                cboErrorMatchType.SelectedIndex = 0;
            }
            #endregion

            if (selectedEntry != null)
            {
                txtName.Text                      = selectedEntry.Name;
                txtDomainController.Text          = selectedEntry.DomainController;
                txtQueryText.Text                 = selectedEntry.QueryFilterText;
                txtPropertiestToLoad.Text         = selectedEntry.PropertiesToLoad;
                optEWG.Checked                    = selectedEntry.ReturnCheckSequence == CollectorReturnValueCheckSequenceType.EWG;
                chkUseRowCount.Checked            = selectedEntry.UseRowCountAsValue;
                maxRowsNumericUpDown.Value        = selectedEntry.MaxRowsToEvaluate;
                txtSuccess.Text                   = selectedEntry.GoodScriptText;
                cboSuccessMatchType.SelectedIndex = (int)selectedEntry.GoodResultMatchType;
                txtWarning.Text                   = selectedEntry.WarningScriptText;
                cboWarningMatchType.SelectedIndex = (int)selectedEntry.WarningResultMatchType;
                txtError.Text                     = selectedEntry.ErrorScriptText;
                cboErrorMatchType.SelectedIndex   = (int)selectedEntry.ErrorResultMatchType;
            }
        }
        private void PowerShellScriptRunnerEditEntry_Load(object sender, EventArgs e)
        {
            PowerShellScriptRunnerEntry selectedEntry = (PowerShellScriptRunnerEntry)SelectedEntry;

            #region Load Match types
            cboSuccessMatchType.Items.Clear();
            cboSuccessMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboSuccessMatchType.Items.Count > 0)
            {
                cboSuccessMatchType.SelectedIndex = 0;
            }
            cboWarningMatchType.Items.Clear();
            cboWarningMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboWarningMatchType.Items.Count > 0)
            {
                cboWarningMatchType.SelectedIndex = 0;
            }
            cboErrorMatchType.Items.Clear();
            cboErrorMatchType.Items.AddRange(CollectorReturnValueCompareEngine.ReturnValueCompareMatchTypesToList().ToArray());
            if (cboErrorMatchType.Items.Count > 0)
            {
                cboErrorMatchType.SelectedIndex = 0;
            }
            #endregion

            if (selectedEntry != null)
            {
                txtName.Text    = selectedEntry.Name;
                optEWG.Checked  = selectedEntry.ReturnCheckSequence == CollectorReturnValueCheckSequenceType.EWG;
                txtScript.Text  = selectedEntry.TestScript;
                txtSuccess.Text = selectedEntry.GoodScriptText;
                cboSuccessMatchType.SelectedIndex = (int)selectedEntry.GoodResultMatchType;
                txtWarning.Text = selectedEntry.WarningScriptText;
                cboWarningMatchType.SelectedIndex = (int)selectedEntry.WarningResultMatchType;
                txtError.Text = selectedEntry.ErrorScriptText;
                cboErrorMatchType.SelectedIndex = (int)selectedEntry.ErrorResultMatchType;
            }
        }