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); }