protected override bool DownPL35(DownParameter param) { Biz.PL35.DwNumberBiz biz = new Biz.PL35.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); var numbers = this.GetNumbers(param, lastDate); if (numbers.Count == 0) { return(false); } long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number; DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) { continue; } if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) { continue; } return(false); } return(true); }
private bool DownPL35(DownParameter param, Biz.PL35.DwNumberBiz biz, DateTime currentDate) { string url = param.Category.DownUrl; try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<div id=\"conKjlist\" class=\"kjlist\">.*?</table>", 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>(\\d{7})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td>(\\d{4}-\\d{2}-\\d{2})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, "<div class=\"aball\">.*?</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Value; code = Regex.Replace(code, "<.*?>", ""); code = string.Join(",", code.ToArray()); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) { continue; } int intDate = int.Parse(datetime.Replace("-", "")); int p = int.Parse(peroid); //把期号统一成{yyyynnn} if (p < 2000000) { p += 2000000; } if (p <= lastP) { continue; } int n = int.Parse(peroid.Substring(peroid.Length - 3)); 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 DownPL35(DownParameter param) { Biz.PL35.DwNumberBiz biz = new Biz.PL35.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) { char[] digits = numberInfo.Number.ToArray(); string code = string.Join(",", digits); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) continue; if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) continue; return false; } return true; }