protected override bool Down11X5(DownParameter param) { Biz.D11X5.DwNumberBiz biz = new Biz.D11X5.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) return false; var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) return false; long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number.Replace(" ", ","); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); int p = 2000000000 + int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 2)); if (p <= lastP) continue; if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) continue; return false; } return true; }
private bool Down11X5(DownParameter param, Biz.D11X5.DwNumberBiz biz, DateTime currentDate) { int intDate = int.Parse(currentDate.ToString("yyyyMMdd")); string url = string.Format(param.Category.DownUrl, intDate, "&"); try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<tbody id=\"row_show\">.*</tbody>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value; MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return(false); } long lastP = biz.GetLatestPeroid(); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, @"[<spans >|<span >](\d{2},\d{2},\d{2},\d{2},\d{2})[</spans>|<spans>]", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) { continue; } long p = int.Parse(peroid); //把期号统一成{yyyymmddnn} if (p < 2000000000) { p += 2000000000; } if (p <= lastP) { continue; } int n = int.Parse(peroid.Substring(peroid.Length - 2)); if (!biz.Add(p, n, code, intDate, datetime)) { return(false); } } return(true); } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return(false); } }
protected override bool Down11X5(DownParameter param) { Biz.D11X5.DwNumberBiz biz = new Biz.D11X5.DwNumberBiz(param.Category.DbName); DateTime startDate = biz.GetLatestDate(); for (DateTime date = startDate; date <= DateTime.Now; date = date.AddDays(1)) { if (!this.Down11X5(param, biz, date)) return false; } return true; }
protected override bool Down11X5(DownParameter param) { Biz.D11X5.DwNumberBiz biz = new Biz.D11X5.DwNumberBiz(param.Category.DbName); DateTime startDate = biz.GetLatestDate(); for (DateTime date = startDate; date <= DateTime.Now; date = date.AddDays(1)) { if (!this.Down11X5(param, biz, date)) { return(false); } } return(true); }
protected override bool Down11X5(DownParameter param) { Biz.D11X5.DwNumberBiz biz = new Biz.D11X5.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) { return(false); } var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) { return(false); } long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number.Replace(" ", ","); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); int p = 2000000000 + int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 2)); if (p <= lastP) { continue; } if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) { continue; } return(false); } return(true); }