Ejemplo n.º 1
0
        private bool DownSSC(DownParameter param, Biz.SSC.DwNumberBiz biz, DateTime currentDate)
        {
            int    intDate = int.Parse(currentDate.ToString("yyyyMMdd"));
            string url     = string.Format(param.Category.DownUrl, "&", intDate);

            try
            {
                string          htmlText = this._webClient.DownloadString(url);
                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, "<div class=\"numBall_ssc\">(.*?)</div>",
                                              RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim();
                    code = Regex.Replace(code, "<.*?>|[\\s]", "").Trim();

                    if (string.IsNullOrEmpty(code) || code.Length == 0)
                    {
                        continue;
                    }

                    long p = long.Parse(peroid);
                    //把期号统一成{yyyymmddnnn}
                    if (p < 20000000000)
                    {
                        p += 20000000000;
                    }
                    if (p <= lastP)
                    {
                        continue;
                    }

                    code = string.Join(",", code.ToArray());
                    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);
            }
        }
Ejemplo n.º 2
0
        protected override bool DownSSC(DownParameter param)
        {
            Biz.SSC.DwNumberBiz biz      = new Biz.SSC.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        = 20000000000 + 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);
        }
Ejemplo n.º 3
0
        protected override bool DownSSC(DownParameter param)
        {
            Biz.SSC.DwNumberBiz biz      = new Biz.SSC.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        = long.Parse(numberInfo.Peroid);
                if (p < 20000000000)
                {
                    p += 20000000000;
                }
                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);
        }
Ejemplo n.º 4
0
        protected override bool DownSSC(DownParameter param)
        {
            Biz.SSC.DwNumberBiz biz = new Biz.SSC.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 = 20000000000 + 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;
        }
Ejemplo n.º 5
0
        protected override bool DownSSC(DownParameter param)
        {
            Biz.SSC.DwNumberBiz biz = new Biz.SSC.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 = long.Parse(numberInfo.Peroid);
                if (p < 20000000000) p += 20000000000;
                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;
        }