Example #1
0
 public void SetUp()
 {
     _sysInfoResult = new SysInfoResult("OS");
     _child         = new SysInfoResult("OS_Child");
     _sysInfoResult.ChildResults.Add(_child);
     _child.Nodes.AddRange(new[] { "CountryCode = 1", "CodeSet = 7", "OSLanguage = Portugese" });
 }
        private static IEnumerable <SysInfoResult> CreateSysInfoResult()
        {
            IList <SysInfoResult> results = new List <SysInfoResult>();
            var result = new SysInfoResult("Memory");

            result.Nodes.Add("Physical Memory");
            var resultChild = new SysInfoResult("Bla");

            result.ChildResults.Add(resultChild);
            resultChild.Nodes.Add("Version:2.66");
            results.Add(result);
            return(results);
        }
Example #3
0
        protected string AboutBind(string id)
        {
            SysInfoResult result = EispSysInfoBLL.GetSysInfoByID(id);

            if (!result.HasError)
            {
                return(VerifyTool.DeleteScript(result.Result.Content));
            }
            else
            {
                return("");
            }
        }
Example #4
0
        protected string AboutBind(string id)
        {
            SysInfoResult result = EispSysInfoBLL.GetSysInfoByID(id);

            if (!result.HasError)
            {
                return(VerifyTool.CheckStringLength(VerifyTool.RemoveHtml(result.Result.Content), 360, false));
            }
            else
            {
                return("");
            }
        }
        /// <summary>
        /// Add a tree node to an existing parentNode, by passing the SysInfoResult
        /// </summary>
        public static void AddTreeViewNode(TreeNode parentNode, SysInfoResult result)
        {
            var nodeRoot = new TreeNode(result.Name);

            foreach (var nodeLeaf in result.Nodes.Select(nodeValueParent => new TreeNode(nodeValueParent)))
            {
                nodeRoot.Nodes.Add(nodeLeaf);

                foreach (var nodeValue in result.ChildResults.SelectMany(childResult => childResult.Nodes))
                {
                    nodeLeaf.Nodes.Add(new TreeNode(nodeValue));
                }
            }
            parentNode.Nodes.Add(nodeRoot);
        }
        /// <summary>
        /// Retrieve system information, using the given SysInfoQuery to determine what information to retrieve
        /// </summary>
        /// <param name="sysInfoQuery">
        /// the query to determine what information to retrieve
        /// </param>
        /// <returns>
        /// a SysInfoResult ie containing the results of the query
        /// </returns>
        public SysInfoResult Retrieve(SysInfoQuery sysInfoQuery)
        {
            this._sysInfoQuery = sysInfoQuery;
            this._sysInfoSearcher =
                new ManagementObjectSearcher(string.Format("SELECT * FROM {0}", this._sysInfoQuery.QueryText));
            this._sysInfoResult = new SysInfoResult(this._sysInfoQuery.Name);

            foreach (ManagementObject managementObject in this._sysInfoSearcher.Get())
            {
                this._sysInfoResult.AddNode(
                    managementObject.GetPropertyValue(this._sysInfoQuery.DisplayField).ToString().Trim());
                this._sysInfoResult.AddChildren(this.GetChildren(managementObject));
            }

            return this._sysInfoResult;
        }
        /// <summary>
        /// The get children.
        /// </summary>
        /// <param name="managementObject">
        /// The management object.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        private IEnumerable<SysInfoResult> GetChildren(ManagementBaseObject managementObject)
        {
            SysInfoResult childResult = null;
            ICollection<SysInfoResult> childList = new List<SysInfoResult>();

            foreach (PropertyData propertyData in managementObject.Properties)
            {
                if (childResult == null)
                {
                    childResult = new SysInfoResult(this._sysInfoQuery.Name + "_Child");
                    childList.Add(childResult);
                }

                string nodeValue = string.Format("{0} = {1}", propertyData.Name, Convert.ToString(propertyData.Value));
                childResult.Nodes.Add(nodeValue);
            }

            return childList;
        }