示例#1
0
        /// <summary>
        /// Thread function to collect wmi data
        /// </summary>
        /// <param name="param">receives the machine name or ip for data collecton</param>
        private void CollectWMIData(object param)
        {
            string hostname = (string)param;
            _logger.Info("wmi data collection started for machine " +hostname);
            DiscoverDb _disDb = new DiscoverDb();
            EntDiscover machinedetails = _disDb.GetMachineDetails(hostname);

            CredentialDB _credDb = new CredentialDB();
            EntCredential _cred = _credDb.GetCredential(machinedetails.CredentialID);
            _credDb.CloseConnection();
            _credDb = null;

            string _UserName = null;
            string _Password = null;

            if ( _cred != null)
            {
                _UserName = _cred.Username;
                _Password = _cred.Password;
            }

            FireStatusMessage(NAMString.ResourceFormatter.CONTROLLER_STATUS_MESSAGE_WMICOLLECT()+" "+hostname);
            WMIHandler objHandler = new WMIHandler(machinedetails.MachineName, _UserName, _Password);
            EntScan scan = new EntScan();

            if ( objHandler.IsWmiInitialized == true )
            {

                scan.MachineID = machinedetails.MachineID;

                ScanDb _scandb = new ScanDb();
                int scanID = _scandb.InsertScan(scan);
                _scandb.CloseConnection();
                _scandb = null;

                EntityDb entityDb = new EntityDb();

                FireStatusMessage(hostname+" : "+ NAMString.ResourceFormatter.CONTROLLER_STATUS_MESSAGE_PROCESSOR());

                foreach (EntProcessor pro in objHandler.GetProcessorDetails())
                {
                    pro.ScanID = scanID;
                    //procDb.InsertProcessor(pro);
                    entityDb.Insert(pro);
                }

               foreach (EntSoftwares lSoftware in objHandler.GetInstalledSoftwareDetails())
               {
                   lSoftware.ScanID = scanID;
                   entityDb.Insert(lSoftware);
               }

                entityDb.CloseConnection();
                entityDb = null;

                _disDb.UpdateLastScan(scan.MachineID, scan.Date);

                machinedetails.Discovered = true;
                machinedetails.StatusMessage = NAMString.ResourceFormatter.CONTROLLER_STATUS_MESSAGE_SCANCOMPLETE();

            }
            else
            {
                _logger.Error("WMI not initialized for machine <" + hostname+">");
                machinedetails.StatusMessage = "wmi initialization failure";
                machinedetails.Discovered = false;
            }

            machinedetails.LastChecked = DateTime.Now;
            _disDb.UpdateDiscover(machinedetails);

            if ( ScanComplete!=null)
            {
                ScanComplete(this, machinedetails.MachineName);
            }
            FireStatusMessage("Scan complete");
            _disDb.CloseConnection();
            _disDb = null;
        }
示例#2
0
 public void SetCredentials(List<EntCredential> lstCredentials)
 {
     CredentialDB _credDb = new CredentialDB();
     _credDb.UpdateCredentials(lstCredentials);
     _credDb.CloseConnection();
     _credDb = null;
 }
示例#3
0
 /// <summary>
 /// Gets the machines from the specified domain
 /// </summary>
 /// <param name="domainName">Domain from which machines needs to be discovered</param>
 public void GetMachinesByHostName(string machineName)
 {
     _logger.Info("Getting machines by hostname");
     CredentialDB _credDb = new CredentialDB();
     _netHelper.Credentials = _credDb.GetAllCredentials();
     _credDb.CloseConnection();
     _credDb = null;
     _netHelper.GetMachinesByName(machineName);
 }
示例#4
0
        public void GetMachinesByFromFile(string fileName)
        {
            _logger.Info("Getting the list of machines from filename "+fileName);
            CredentialDB _credDb = new CredentialDB();
            _netHelper.Credentials = _credDb.GetAllCredentials();
            _credDb.CloseConnection();
            _credDb = null;

            _netHelper.DiscoverMachinesByFileName(fileName);
        }
示例#5
0
 /// <summary>
 /// Gets the machines from the specified domain
 /// </summary>
 /// <param name="domainName">Domain from which machines needs to be discovered</param>
 public void GetMachines(string domainName)
 {
     _logger.Info("Getting the list of machines from domain "+ domainName);
     CredentialDB _credDb = new CredentialDB();
     _netHelper.Credentials = _credDb.GetAllCredentials();
     _credDb.CloseConnection();
     _credDb = null;
     _netHelper.DiscoverMachines(SearchType.Machines, domainName);
 }
示例#6
0
        public List<EntCredential> GetCredentials()
        {
            List<EntCredential> lstCred = null;
            CredentialDB _credDb = new CredentialDB();
            lstCred = _credDb.GetAllCredentials();
            _credDb.CloseConnection();
            _credDb = null;

            return lstCred;
        }