public void FromCsv(Csv csv) { UserList.Clear(); foreach (CsvEntry e in csv.Items) { if (e.Count >= 4) { try { MailUser u = new MailUser(e); this.UserList.Add(u); } catch { } } else if (e.Count == 1) { try { string mail = e[0]; if (Str.CheckMailAddress(mail)) { MailUser u = new MailUser(mail, mail, "", "ja", new List <KeyValuePair <string, string> >()); this.UserList.Add(u); } } catch { } } } }
public static FullRouteIPInfoCache CreateFromDownload(string url) { FullRouteIPInfoCache ret = new FullRouteIPInfoCache(); ret.TimeStamp = DateTime.Now; // Download CSV WebRequest req = HttpWebRequest.Create(url); WebResponse res = req.GetResponse(); try { Stream stream = res.GetResponseStream(); try { byte[] rawData = Util.ReadAllFromStream(stream); byte[] data = GZipUtil.Decompress(rawData); Csv csv = new Csv(new Buf(data)); foreach (CsvEntry ce in csv.Items) { if (ce.Count >= 7) { FullRouteIPInfoEntry e = new FullRouteIPInfoEntry(); e.From = Str.StrToUInt(ce[2]); e.To = Str.StrToUInt(ce[3]); //e.Registry = ce[2]; //e.Assigned = Str.StrToUInt(ce[3]); e.Country2 = ce[5]; //e.Country3 = ce[5]; e.CountryFull = DeleteSemi(ce[6]); if (e.From != 0 && e.To != 0) { ret.EntryList.Add(e); } } } ret.EntryList.Sort(); if (ret.EntryList.Count <= 70000) { throw new ApplicationException("ret.EntryList.Count <= 70000"); } } finally { stream.Close(); } } finally { res.Close(); } ret.build_country_code_to_name_db(); return(ret); }