private void bwDomains_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { cmbDomains.Invoke(new MethodInvoker(delegate() { cmbDomains.Items.Clear(); })); foreach (CompEnum.NetworkComputers nc in NSearcher.GetDomainNames()) { cmbDomains.Invoke(new MethodInvoker(delegate() { cmbDomains.Items.Add(nc.Name); })); } }
private void bwDomains_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { CompEnum ce = NSearcher.GetDomainNames(); cmbDomains.Invoke(new MethodInvoker(delegate() { cmbDomains.Items.Clear(); })); foreach (CompEnum.NetworkComputers nc in ce) { cmbDomains.Invoke(new MethodInvoker(delegate() { cmbDomains.Items.Add(nc.Name); })); } lnkConfiguration.Invoke(new MethodInvoker(delegate() { lnkConfiguration.Enabled = true; })); }
private void bwComputers_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { string hostName; _totalFileFound = 0; try { //Computers on Domain CompEnum computers = NSearcher.GetComputersOnDomain(_selectedNetwork); _totalTime = DateTime.Now; int currentComputer = 1; DateTime hostScanTime; int totalComputerCount = computers.Length; if (_configurationInfo.SelectedHostList != null && _configurationInfo.SelectedHostList.Count > 0) { totalComputerCount = _configurationInfo.SelectedHostList.Count; } foreach (CompEnum.NetworkComputers nc in computers) { hostName = nc.Name; hostScanTime = DateTime.Now; if (_configurationInfo.SelectedHostList == null || _configurationInfo.SelectedHostList.Count == 0 || _configurationInfo.SelectedHostList.Contains(hostName)) { if (!_configurationInfo.ScanOnlyNewHosts || (_configurationInfo.ScanOnlyNewHosts && !DBLayer.HostExists(hostName))) { lblHostProgress.Invoke(new MethodInvoker(delegate() { lblHostProgress.Text = string.Format("{0} of {1}", currentComputer++, totalComputerCount); })); lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(string.Format("{0} - {1} scan started", hostScanTime.ToShortTimeString(), hostName)); })); txtCurrentHost.Invoke(new MethodInvoker(delegate(){ txtCurrentHost.Text = hostName; })); DBLayer.CreateHost(hostName); string sharePath; //Shares for computer foreach (Share s in NSearcher.GetSharesForComputer(hostName)) { if (s.ShareType == ShareType.Device || s.ShareType == ShareType.Disk) { sharePath = s.Root.FullName; ScanFolder(sharePath, " ", hostName, sharePath, 1); } } TimeSpan hostScanSpan = DateTime.Now.Subtract(hostScanTime); lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(string.Format("{0} - {1} scan finished, took {2} minutes {3} seconds {4} milliseconds", DateTime.Now.ToShortTimeString(), hostName, hostScanSpan.Minutes, hostScanSpan.Seconds, hostScanSpan.Milliseconds)); })); } } } TimeSpan totalTimeSpan = DateTime.Now.Subtract(_totalTime); lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(string.Format("Total: {0} files, took {1} minutes, {2} seconds, {3} milliseconds", _totalFileFound, totalTimeSpan.Minutes, totalTimeSpan.Seconds, totalTimeSpan.Milliseconds)); })); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.InnerException + ex.StackTrace); } gbSearch.Invoke(new MethodInvoker(delegate() { gbSearch.Enabled = true; })); lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(string.Format("Scan finished")); })); }
private void bwComputers_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { gbSearch.Enabled = false; lbConsole.Items.Clear(); string hostName; _totalFileFound = 0; //CompEnum ce = NSearcher.GetComputersOnDomain(cmbDomains.SelectedItem.ToString()); try { CompEnum computers = NSearcher.GetComputersOnDomain(cmbDomains.SelectedItem.ToString()); int currentComputer = 1; foreach (CompEnum.NetworkComputers nc in computers) { lblHostProgress.Text = string.Format("{0} of {1}", currentComputer++, computers.Length); hostName = nc.Name; lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(hostName); })); txtCurrentHost.Text = hostName; DBLayer.CreateOrUpdateHost(hostName); string sharePath; foreach (Share s in NSearcher.GetSharesForComputer(hostName)) { if (s.ShareType == ShareType.Device || s.ShareType == ShareType.Disk) { sharePath = s.Root.FullName; DBLayer.CreateOrUpdateHostShare(hostName, sharePath); ScanFolder(sharePath, " ", hostName, sharePath); } } } lbConsole.Invoke(new MethodInvoker(delegate() { lbConsole.Items.Add(string.Format("Total:{0}", _totalFileFound)); })); } catch (Exception ex) { MessageBox.Show(ex.Message); } gbSearch.Enabled = true; }