Пример #1
0
        public List<EntDiscover>GetMachineList()
        {
            List<EntDiscover> discover = new List<EntDiscover>();
            DiscoverDb discDb = new DiscoverDb();
            discover = discDb.GetDiscover(null);
            discDb.CloseConnection();
            discDb = null;

            return discover;
        }
Пример #2
0
        /// <summary>
        /// Private thread function that retrieves the machine list from database and 
        /// then fires discovery start machine found and discovery complete events
        /// </summary>
        public List<EntDiscover>UpdateFromDatabase(string machineName)
        {
            DiscoverDb _tempDb = new DiscoverDb();

            List<EntDiscover> discMachineList = _tempDb.GetDiscover(machineName);

            _tempDb.CloseConnection();
            _tempDb = null;

            return discMachineList;
        }
Пример #3
0
 void netHelper_MachineDiscoveryStart(object sender, DiscoveryDetailsArgs args)
 {
     _logger.Info("Machine discovery started");
     disDB = new DiscoverDb();
     if ( MachineDiscoveryStart!=null)
     {
         MachineDiscoveryStart(this, null);
     }
 }
Пример #4
0
 /// <summary>
 /// Machine discovery complete machine.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 void netHelper_MachineDiscoveryComplete(object sender, EventArgs args)
 {
     disDB.CloseConnection();
     disDB = null;
     if ( MachineDiscoveryComplete!=null)
     {
         MachineDiscoveryComplete(this, null);
     }
 }
Пример #5
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;
        }
Пример #6
0
 public void UpdateDiscoveryMachines(List<EntDiscover> lstDiscover)
 {
     DiscoverDb discoveryDb = new DiscoverDb();
     discoveryDb.UpdateDiscover(lstDiscover);
     discoveryDb.CloseConnection();
     discoveryDb = null;
 }
Пример #7
0
        //TODO_HIGH : return the collection of the objects to the UI
        public int GetWmiDataFromDB(string machineName, DateTime scanDate, ref Hashtable objDataTable)
        {
            //TODO_NORM: Improve the code below so db handling is proper.
            DiscoverDb discDb = new DiscoverDb();
            EntDiscover machineDetails = discDb.GetMachineDetails(machineName);
            discDb.CloseConnection();
            discDb = null;

            //TODO_HIGH: Code only displays the latest, should display scan selected using combobox
            ScanDb _scanDb = new ScanDb();
            EntScan scan = _scanDb.GetLatestScanDetails(machineDetails.MachineID, scanDate);
            _scanDb.CloseConnection();
            _scanDb = null;

            if ( scan != null)
            {
                EntityDb entityDb = new EntityDb();

                ArrayList sysData = new ArrayList();
                ArrayList.Synchronized(sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Computer, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Processor, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.OS, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Bios, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.MotherBoard, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Disk, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Memory, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.LogicalDrive, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.CDRom, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.NetworkAdapter, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Video, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Multimedia, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Monitor, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Share, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Printer, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.Hotfix, ref sysData);
                entityDb.GetEntity(scan.ScanID, EntityType.StartUp, ref sysData);

                objDataTable.Add("System", sysData);

                ArrayList processData = new ArrayList();
                ArrayList.Synchronized(processData);
                entityDb.GetEntity(scan.ScanID, EntityType.Processes, ref processData);
                objDataTable.Add("Processes", processData);

                ArrayList softwareData = new ArrayList();
                ArrayList.Synchronized(softwareData);
                entityDb.GetEntity(scan.ScanID, EntityType.Softwares, ref softwareData);
                objDataTable.Add("Softwares", softwareData);

                ArrayList servicesData = new ArrayList();
                ArrayList.Synchronized(servicesData);
                entityDb.GetEntity(scan.ScanID, EntityType.Services, ref servicesData);
                objDataTable.Add("Services", servicesData);

                ArrayList ipRoutesData = new ArrayList();
                ArrayList.Synchronized(ipRoutesData);
                entityDb.GetEntity(scan.ScanID, EntityType.IPRoutes, ref ipRoutesData);
                objDataTable.Add("IPRoutes", ipRoutesData);

                ArrayList ipEnvVars = new ArrayList();
                ArrayList.Synchronized(ipEnvVars);
                entityDb.GetEntity(scan.ScanID, EntityType.EnvironmentVar, ref ipEnvVars);
                objDataTable.Add("EnvVars", ipEnvVars);

                ArrayList userGrps = new ArrayList();
                ArrayList.Synchronized(userGrps);
                entityDb.GetEntity(scan.ScanID, EntityType.UserGroup, ref userGrps);
                objDataTable.Add("UserGroups", userGrps);

                entityDb.CloseConnection();
                entityDb = null;
            }

            return 1;
        }
Пример #8
0
 public List<EntScan> GetAllScans(string machineName)
 {
     List<EntScan> retList = null;
     DiscoverDb discDb = new DiscoverDb();
     EntDiscover machine = discDb.GetMachineDetails(machineName);
     discDb.CloseConnection();
     discDb = null;
     ScanDb scanDb = new ScanDb();
     retList = scanDb.GetScanDetails(machine.MachineID);
     scanDb.CloseConnection();
     scanDb = null;
     return retList;
 }
Пример #9
0
 public void DeleteMachine(string machineName)
 {
     DiscoverDb discDb = new DiscoverDb();
     discDb.DeleteDiscover(machineName);
     discDb.CloseConnection();
     discDb = null;
 }