示例#1
0
        private void _btnSave_Click(object sender, EventArgs e)
        {
            _btnSave.Enabled = false;

            Subdomain subdomain = new Subdomain();

            subdomain.SubdomainName = _txtSubName.Text;
            subdomain.DateFound     = _dateFound.Value;
            subdomain.DomainId      = int.Parse(_cmbDomain.SelectedItem.ToString().Split('~')[1].ToString());
            subdomain.FoundType     = _txtFoundType.Text;

            SubdomainController subController = new SubdomainController();
            var res = subController.Insert(subdomain);

            if (res.Error)
            {
                MessageBox.Show(res.Message);
            }
            else
            {
                _txtSubName.Text        = "";
                _dateFound.Value        = DateTime.Now;
                _cmbDomain.SelectedItem = "Select";
                _txtFoundType.Text      = "";
            }


            _btnSave.Enabled = true;
        }
示例#2
0
        private void _btnInitSubdomain_Click(object sender, EventArgs e)
        {
            DomainController    domainController    = new DomainController();
            SubdomainController subdomainController = new SubdomainController();
            DomainFindResult    findResult          = domainController.FindAll();

            List <string> knownSubdomains   = new List <string>();
            List <string> knowndbSubdomains = new List <string>();

            foreach (Domain domainItem in findResult.Items)
            {
                string domain       = domainItem.DomainName;
                string existingFile = Path.Combine(@"C:\Alternative\Existing", domain.Replace(".", "") + ".txt");
                if (File.Exists(existingFile))
                {
                    knownSubdomains = File.ReadAllLines(existingFile).ToList();
                }

                knownSubdomains = knownSubdomains.Select(x => x.Replace("." + domainItem.DomainName, "")).ToList();

                SubdomainFindResult subDomainFindResult = subdomainController.FindByDomain(domainItem.DomainId);
                if (subDomainFindResult.Error)
                {
                    MessageBox.Show(subDomainFindResult.Message);
                }

                knowndbSubdomains = subDomainFindResult.Items.Select(x => x.SubdomainName).ToList();

                List <string> inList1ButNotList2 = (from o in knownSubdomains
                                                    join p in knowndbSubdomains on o equals p into t
                                                    from od in t.DefaultIfEmpty()
                                                    where od == null
                                                    select o).ToList <string>();

                foreach (string newItem in inList1ButNotList2)
                {
                    Subdomain sub = new Subdomain();

                    sub.DomainId      = domainItem.DomainId;
                    sub.DateFound     = DateTime.Now;
                    sub.FoundType     = "scanner";
                    sub.SubdomainName = newItem;

                    subdomainController.Insert(sub);
                }
            }
        }