public Task gwsAsync() { cts = new CancellationTokenSource(); task = Task.Factory.StartNew(() => { while (!cts.IsCancellationRequested) { try { using (IPv4DataContext db = new IPv4DataContext()) { var q = db.gws_Old.Select(f => f.Address).Except(db.gws.Select(f => f.Address)).ToList(); for (int i = 0; i < q.Count - 1; i++) { if (cts.IsCancellationRequested) { break; } var gws = q[i]; //CodeSite.Send("gws.IP", gws.IP); if (ProgressString != null) { ProgressString.Report(string.Format("{0}/{1}", i + 1, q.Count)); } var ip = db.IPv4SSL.SingleOrDefault(f => f.Address == gws); if (ip == null) { ip = new IPv4SSL((UInt32)gws); } else if (ip.Isgws) { //CodeSite.SendNote("跳过"); continue; } WebCheck(ip); if (ip.RoundtripTime != -1 && db.IPv4SSL.SingleOrDefault(f => f.Address == gws) == null) { db.IPv4SSL.InsertOnSubmit(ip); } if (ip.Isgws) { if (ProgressIP != null) { ProgressIP.Report(ip); } db.SubmitChanges(); } } } } catch (Exception ex) { ex.SendCodeSite("gwsAsync"); Thread.Sleep(1000); } } }, cts.Token); return(task); }
private void buttonServernull_Click(object sender, EventArgs e) { using (IPv4DataContext db = new IPv4DataContext()) { //var q = from g in db.Google // join i in db.IPv4SSL on g.Address equals i.Address // where i.Server == null // select i.Address; foreach (var ip in db.IPv4SSL.Join(db.Google, i => i.Address, g => g.Address, (i, g) => i).Where(f => f.Server == null).OrderBy(f => f.Address)) { CodeSite.Send("IP", ip.IP); Search.WebCheck(ip); Search.TcpCheck(ip); db.SubmitChanges(); } } }
static bool SaveDB(IEnumerable <IPv4SSL> ipa) { using (IPv4DataContext db = new IPv4DataContext()) { try { db.IPv4SSL.InsertAllOnSubmit(ipa); db.SubmitChanges(); return(true); } catch (Exception ex) { ex.SendCodeSite("SaveDB"); CodeSite.Send("ipa.First().IP", ipa.First().IP); } } return(false); }
protected override bool SaveDB(IEnumerable <IPv4SSL> ipa) { using (IPv4DataContext db = new IPv4DataContext()) { try { db.IPv4SSL.InsertAllOnSubmit(ipa); db.SubmitChanges(); return(true); } catch (Exception ex) { ex.SendCodeSite("SaveDB"); CodeSite.Send("Count = {0}, FirstIP = {1}", ipa.Count(), ipa.First().IP); } } return(false); }
private void buttonGoogleIPHunter_Click(object sender, EventArgs e) { var files = Directory.GetFiles(@"G:\DxgWork\GitHub\GoogleIPHunter\trunk", "*.txt", SearchOption.AllDirectories); using (IPv4DataContext db = new IPv4DataContext()) { foreach (var file in files) { foreach (var s in File.ReadAllLines(file)) { try { IPNetwork network = IPNetwork.Parse(s); if (network.ToString() == s) { uint address = network.Network.ToUInt32(); if (!db.GoogleIPHunter.Any(f => f.Address == (long)address)) { db.GoogleIPHunter.InsertOnSubmit(new GoogleIPHunter() { Address = address, IPBlock = s }); db.SubmitChanges(); CodeSite.SendNote("新增 = {0}", s); } } else { CodeSite.SendError(s); } } catch { //CodeSite.SendException(s, ex); } } } } }
private void buttonGoogleIP_Click(object sender, EventArgs e) { var sa = File.ReadAllLines("google ip duan.txt"); using (IPv4DataContext db = new IPv4DataContext()) { var list = db.GoogleIPDuan.ToList().Select(f => (uint)f.Address); foreach (var s in sa) { try { IPNetwork network = IPNetwork.Parse(s); if (network.ToString() == s) { uint address = network.Network.ToUInt32(); if (!list.Contains(address)) { db.GoogleIPDuan.InsertOnSubmit(new GoogleIPDuan() { Address = address, IPBlock = s }); CodeSite.SendNote("新增 = {0}", s); } } else { CodeSite.SendError(s); } } catch (Exception ex) { CodeSite.SendException(s, ex); } } db.SubmitChanges(); } }
protected override bool SaveDB(IEnumerable <IPv4SSL> ipa) { //CodeSite.Send("ipa.Count()", ipa.Count()); using (IPv4DataContext db = new IPv4DataContext()) { try { foreach (var ip in ipa) { if (ip.Isgws && ProgressIPv4SSL != null) { ProgressIPv4SSL.Report(ip); } int i = listIPv4SSL.BinarySearch(ip); if (i > -1) { //CodeSite.Send(listIPv4SSL[i].IP, listIPv4SSL[i]); //CodeSite.Send(ip.IP, ip); db.IPv4SSL.Attach(ip, listIPv4SSL[i]); } else { CodeSite.SendError(string.Format("{0}-{1}", i, ip.IP)); } } db.SubmitChanges(); return(true); } catch (Exception ex) { ex.SendCodeSite("SaveDB"); CodeSite.Send("ipa.First().IP", ipa.First().IP); } } return(false); }