public void TestAddModel() { User user = new User { LoginName = "test", Password = "******", }; DapperFactory factory = new DapperFactory(); Assert.NotEqual(0, factory.ExcuteInsert(user)); }
public void TestAddModels() { var users = Enumerable.Range(0, 10).Select(i => new User { LoginName = $"test{i}", Password = $"test{i}" } ).ToList(); DapperFactory factory = new DapperFactory(); Assert.NotEqual(0, factory.ExcuteInsert(users)); }
public async void Proxy(Spider spider) { await Task.Run(async() => { while (true) { var r = await spider.SpiderAsync <Proxy>(); if (r == null) { return; } var q = new Queue <Proxy>(); r.ForEach(f => { q.Enqueue(f); }); while (q.TryDequeue(out Proxy p)) { try { Console.WriteLine($"dequeue:{p.IP}:{p.Port}"); IWebProxy proxy = new WebProxy(p.IP, Convert.ToInt32(p.Port)); var response = _http.HttpGet("http://www.baidu.com", proxy); if (response.HttpCode == HttpStatusCode.OK) { Console.WriteLine($"insert:{p.IP}:{p.Port}"); _factory.ExcuteInsert(p); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }); Console.WriteLine("task over"); }