예제 #1
0
        private TreeNode getModel(WMIC wmic)
        {
            TreeNode model    = new TreeNode();
            string   response = wmicCall(wmic.createQuery((int)Query.model));

            model.Name = "Model";
            model.Text = response.Replace("Name", "").Trim();
            return(model);
        }
예제 #2
0
        private TreeNode getSerial(WMIC wmic)
        {
            TreeNode serial   = new TreeNode();
            string   response = wmicCall(wmic.createQuery((int)Query.serial));

            serial.Name = "SerialNO";
            serial.Text = "Serial Number: " + response.Replace("SerialNumber", "").Trim();
            serial.Tag  = response;
            return(serial);
        }
예제 #3
0
        // Change this so it only gets software and adds it to a node
        /// <summary>
        /// Gets a list of software from the target node.
        /// ToDo: Configure for adaptable WMIC calls rather than hard coded.
        /// ToDo: Edit Node names
        /// </summary>
        /// <param name="nodeName"></param>
        /// <returns></returns>
        private TreeNode getSoftware(WMIC wmic)
        {
            TreeNode softNode = new TreeNode();

            softNode.Name = "Software";
            softNode.Text = "Software";
            TreeNode node;
            string   response = "";
            string   dupResponse;


            response    = wmicCall(wmic.createQuery((int)Query.software));
            dupResponse = response;
            foreach (string l in filterResponse(response, wmic.Version))
            {
                if (!string.IsNullOrEmpty(l.Trim()))
                {
                    TreeNode version = new TreeNode();
                    TreeNode n       = new TreeNode();
                    n.Name = l.Substring(0, l.LastIndexOf(" ")).Replace(' ', '.');
                    n.Text = l.Substring(0, l.LastIndexOf(" "));
                    if (wmic.Version)
                    {
                        version.Name = "Version";
                        version.Text = "Version: " + l.Substring(l.LastIndexOf(" "));
                        n.Nodes.Add(version);
                    }
                    softNode.Nodes.Add(n);

                    AddToSoftware(l);
                }
            }

            node      = new TreeNode();
            node.Text = wmic.Name;
            node.Name = wmic.Name;
            if (softNode.GetNodeCount(true) > 1)
            {
                node.Nodes.Add(softNode);
            }
            return(node);
        }
예제 #4
0
        private void reScanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            while (running > 0)
            {
                ;
            }


            /* Update GUI */
            progressScan.Style = ProgressBarStyle.Marquee;
            progressScan.MarqueeAnimationSpeed = 20;

            /* Save info from GUI */
            string userName = txtUsername.Text;
            string password = txtPassword.Text;
            bool   product  = chkProdName.Checked;
            bool   version  = chkProdVer.Checked;
            bool   serial   = chkSerialNum.Checked;
            bool   model    = chkModelName.Checked;

            /* Set up task lists */
            List <List <string> > ParentList = new List <List <string> >();
            int count;

            for (count = 0; count < 10; ++count)
            {
                ParentList.Add(new List <String>());
            }

            count = 0;
            foreach (TreeNode t in treeFailed.Nodes)
            {
                ParentList[count % 10].Add(t.Text);
                count++;
            }

            foreach (List <string> list in ParentList)
            {
                Interlocked.Increment(ref running);
                Task.Run(() =>
                {
                    foreach (string s in list)
                    {
                        TreeNode node = null;
                        WMIC wmic     = new WMIC(s, userName, password, version, serial, model);
                        if (product)
                        {
                            node = getSoftware(wmic);
                        }

                        if (serial)
                        {
                            node.Nodes.Add(getSerial(wmic));
                        }

                        if (model)
                        {
                            node.Nodes.Add(getModel(wmic));
                        }

                        if (node.GetNodeCount(true) < 4)
                        {
                            AddFailedNode(node);
                        }
                        else
                        {
                            AddNode(node);
                        }
                    }
                    Interlocked.Decrement(ref running);
                    if (running == 0)
                    {
                        ResetProgress();
                    }
                });
            }
        }