示例#1
0
        /// <summary>
        /// 得到当前期数据
        /// </summary>
        /// <param name="listPeriod"></param>
        /// <param name="AType"></param>
        /// <returns></returns>
        public static bool GetCurrentPeriodDataOfList(ref List <PeriodDetail_101> listPeriod, int GolaPeriod)
        {
            bool flag = true;


            if (listPeriod.Where(p => p.ShortPeriod_005 == GolaPeriod).Count() > 0)
            {
                PeriodDetail_101 pTemp = listPeriod.Where(p => p.ShortPeriod_005 == GolaPeriod).First();
                FileLog.WriteInfo("GetHtmlString163--Get Period's LongPeriod_001", pTemp.LongPeriod_001.ToString());
                listPeriod.Clear();
                listPeriod.Add(pTemp);
            }
            else
            {
                listPeriod.Clear();
            }
            return(flag);
        }
示例#2
0
        /// <summary>
        /// AType:-1取那天全部的数据,为其它时取特定某期数据
        /// </summary>
        /// <param name="ADateTime"></param>
        /// <param name="listPeriod"></param>
        /// <param name="AType"></param>
        /// <returns></returns>
        public static bool GetHtmlString08(string AUrl, DateTime ADateTime, ref List <PeriodDetail_101> listPeriod, int AType = -1)
        {
            listPeriod.Clear();
            string LinkOf08Parse = string.Empty;

            LinkOf08Parse = string.Format(LinkOf08, ADateTime.ToString("yyyy-MM-dd"), '&', ADateTime.ToString("yyyyMMdd"));
            FileLog.WriteInfo("url", LinkOf08Parse);
            string strResult = string.Empty;

            if (IsSetUpCook.Equals("1"))
            {
                if (String.IsNullOrWhiteSpace(strCookier))
                {
                    strResult = GetHtml(LinkOf08Parse, Encoding.UTF8, "", -1);
                    Regex  rgx            = new Regex(@"ddos=([^]]*)\;\s");
                    Match  match11        = rgx.Match(strResult);
                    string classification = match11.Groups[1].Value;
                    Console.WriteLine("classification:" + classification);
                    strCookier = "ddos=" + classification;
                }
                strResult = GetHtml(LinkOf08Parse, Encoding.UTF8, strCookier, 1);
            }
            else
            {
                strResult = GetHtml(LinkOf08Parse, Encoding.UTF8);
            }


            try
            {
                string          regex              = @"<td>\d{11}</td>[\s\S]*?<td>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}</td>[\s\S]*?<td><span>\d{1}</span><span>\d{1}</span><span>\d{1}</span><span>\d{1}</span><span>\d{1}</span></td>";
                Regex           re                 = new Regex(regex);
                MatchCollection matches            = re.Matches(strResult);
                System.Collections.IEnumerator enu = matches.GetEnumerator();
                while (enu.MoveNext() && enu.Current != null)
                {
                    string strPeriod   = string.Empty;
                    string strAllValue = string.Empty;
                    Match  match       = (Match)(enu.Current);
                    if (match.Groups.Count > 0)
                    {
                        String strTemp = match.Groups[0].Value;
                        regex = @"\d{11}";
                        Regex           reTemp                 = new Regex(regex);
                        MatchCollection matchesTemp            = reTemp.Matches(strTemp);
                        System.Collections.IEnumerator enuTemp = matchesTemp.GetEnumerator();
                        while (enuTemp.MoveNext() && enuTemp.Current != null)
                        {
                            match     = (Match)(enuTemp.Current);
                            strPeriod = match.Groups[0].Value;
                        }

                        regex       = @"<span>\d{1}</span>";
                        reTemp      = new Regex(regex);
                        matchesTemp = reTemp.Matches(strTemp);
                        enuTemp     = matchesTemp.GetEnumerator();
                        StringBuilder sb = new StringBuilder();
                        while (enuTemp.MoveNext() && enuTemp.Current != null)
                        {
                            match = (Match)(enuTemp.Current);
                            sb.Append(match.Groups[0].Value.Substring(6, 1));
                        }
                        strAllValue = sb.ToString();
                    }
                    int Xingqi = 0;
                    switch (ADateTime.DayOfWeek)
                    {
                    case DayOfWeek.Friday:
                        Xingqi = 5;
                        break;

                    case DayOfWeek.Monday:
                        Xingqi = 1;
                        break;

                    case DayOfWeek.Saturday:
                        Xingqi = 6;
                        break;

                    case DayOfWeek.Sunday:
                        Xingqi = 7;
                        break;

                    case DayOfWeek.Thursday:
                        Xingqi = 4;
                        break;

                    case DayOfWeek.Tuesday:
                        Xingqi = 2;
                        break;

                    case DayOfWeek.Wednesday:
                        Xingqi = 3;
                        break;

                    default:
                        Xingqi = 0;
                        break;
                    }

                    if (!string.IsNullOrWhiteSpace(strPeriod) && !string.IsNullOrWhiteSpace(strAllValue))
                    {
                        PeriodDetail_101 period   = new PeriodDetail_101();
                        char[]           charTemp = strAllValue.ToCharArray();
                        if (charTemp.Length == 5)
                        {
                            period.Wei5_050 = int.Parse(charTemp[0].ToString());
                            period.Wei4_040 = int.Parse(charTemp[1].ToString());
                            period.Wei3_030 = int.Parse(charTemp[2].ToString());
                            period.Wei2_020 = int.Parse(charTemp[3].ToString());
                            period.Wei1_010 = int.Parse(charTemp[4].ToString());
                            int countBig  = 0;
                            int countEven = 0;
                            if (period.Wei5_050 >= 5)
                            {
                                countBig++;
                            }
                            if (period.Wei4_040 >= 5)
                            {
                                countBig++;
                            }
                            if (period.Wei3_030 >= 5)
                            {
                                countBig++;
                            }
                            if (period.Wei2_020 >= 5)
                            {
                                countBig++;
                            }
                            if (period.Wei1_010 >= 5)
                            {
                                countBig++;
                            }

                            if (period.Wei5_050 % 2 == 1)
                            {
                                countEven++;
                            }
                            if (period.Wei4_040 % 2 == 1)
                            {
                                countEven++;
                            }
                            if (period.Wei3_030 % 2 == 1)
                            {
                                countEven++;
                            }
                            if (period.Wei2_020 % 2 == 1)
                            {
                                countEven++;
                            }
                            if (period.Wei1_010 % 2 == 1)
                            {
                                countEven++;
                            }

                            int total = period.Wei5_050 + period.Wei4_040 + period.Wei3_030 + period.Wei2_020 + period.Wei1_010;
                            period.AllSub_009 = total;
                            if (total >= 23)
                            {
                                period.BigOrSmall_007 = 1;
                            }
                            else
                            {
                                period.BigOrSmall_007 = 2;
                            }

                            if (total % 2 == 1)
                            {
                                period.EvenODD_008 = 1;
                            }
                            else
                            {
                                period.EvenODD_008 = 2;
                            }
                            period.DateTimeInsert_003 = DateTime.Now;
                            period.DateNumber_004     = Int64.Parse(ADateTime.ToString("yyyyMMdd"));
                            period.ShortPeriod_005    = int.Parse(strPeriod.Substring(8));
                            period.LongPeriod_001     = Int64.Parse(strPeriod);
                            period.AwardNumber_002    = strAllValue;
                            period.DayInWeek_006      = Xingqi;
                            period.CountBig_106       = countBig;
                            period.CountSmall_107     = 5 - countBig;
                            period.CountEven_108      = countEven;
                            period.CountOdd_109       = 5 - countEven;
                            listPeriod.Add(period);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                listPeriod = listPeriod.OrderBy(p => p.LongPeriod_001).ToList();
                if (AType != -1)
                {
                    if (listPeriod.Where(p => p.ShortPeriod_005 == AType).Count() > 0)
                    {
                        PeriodDetail_101 pTemp = listPeriod.Where(p => p.ShortPeriod_005 == AType).First();
                        FileLog.WriteInfo("GetHtmlString08--Get Period's PeriodLong001", pTemp.LongPeriod_001.ToString());
                        listPeriod.Clear();
                        listPeriod.Add(pTemp);
                    }
                    else
                    {
                        listPeriod.Clear();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="listPeriod"></param>
        /// <param name="AIntType">0 360,1 163 ,3  08</param>
        public static void GetPriodDataOfHtmlString(ref List <PeriodDetail_101> listPeriod, string AStrHtmlString, int AIntType, DateTime ADateTime, int APeriod = -1)
        {
            string regex163 = "<td class=\"start\" data-win-number=\'(\\d{1}\\s\\d{1}\\s\\d{1}\\s\\d{1}\\s\\d{1})\' data-period=\"\\d{9}\">(\\d{3})</td>";
            string regex360 = "<td class=\'gray\'>(\\d{3})</td><td class=\'red big\'>(\\d{5})</td>";
            string regex08  = string.Empty;

            Regex re = null;

            if (AIntType == 0)
            {
                re = new Regex(regex360);
            }
            else if (AIntType == 1)
            {
                re = new Regex(regex163);
            }
            else
            {
                re = new Regex(regex08);
            }
            MatchCollection matches = re.Matches(AStrHtmlString);

            System.Collections.IEnumerator enu = matches.GetEnumerator();
            string strPeriod   = string.Empty;
            string strAllValue = string.Empty;

            while (enu.MoveNext() && enu.Current != null)
            {
                strPeriod   = string.Empty;
                strAllValue = string.Empty;

                Match match = (Match)(enu.Current);
                if (AIntType == 0)
                {
                    strPeriod   = match.Groups[1].Value;
                    strAllValue = match.Groups[2].Value;
                }
                else if (AIntType == 1)
                {
                    strPeriod   = match.Groups[2].Value;
                    strAllValue = match.Groups[1].Value;
                }
                else
                {
                }
                int Xingqi = 0;

                switch (ADateTime.DayOfWeek)
                {
                case DayOfWeek.Friday:
                    Xingqi = 5;
                    break;

                case DayOfWeek.Monday:
                    Xingqi = 1;
                    break;

                case DayOfWeek.Saturday:
                    Xingqi = 6;
                    break;

                case DayOfWeek.Sunday:
                    Xingqi = 7;
                    break;

                case DayOfWeek.Thursday:
                    Xingqi = 4;
                    break;

                case DayOfWeek.Tuesday:
                    Xingqi = 2;
                    break;

                case DayOfWeek.Wednesday:
                    Xingqi = 3;
                    break;

                default:
                    Xingqi = 0;
                    break;
                }

                if (!string.IsNullOrWhiteSpace(strPeriod) && !string.IsNullOrWhiteSpace(strAllValue))
                {
                    PeriodDetail_101 period       = new PeriodDetail_101();
                    string[]         strArrayTemp = strAllValue.Split(' ');
                    if (strArrayTemp.Length == 5)
                    {
                        period.Wei5_050           = int.Parse(strArrayTemp[0]);
                        period.Wei4_040           = int.Parse(strArrayTemp[1]);
                        period.Wei3_030           = int.Parse(strArrayTemp[2]);
                        period.Wei2_020           = int.Parse(strArrayTemp[3]);
                        period.Wei1_010           = int.Parse(strArrayTemp[4]);
                        period.DateTimeInsert_003 = DateTime.Now;
                        period.DateNumber_004     = Int64.Parse(ADateTime.ToString("yyyyMMdd"));
                        period.ShortPeriod_005    = int.Parse(strPeriod);
                        period.LongPeriod_001     = Int64.Parse(period.DateNumber_004.ToString() + period.ShortPeriod_005.ToString().PadLeft(3, '0'));
                        period.AwardNumber_002    = string.Format("{0}{1}{2}{3}{4}", period.Wei5_050, period.Wei4_040, period.Wei3_030, period.Wei2_020, period.Wei1_010);
                        period.DayInWeek_006      = Xingqi;
                        listPeriod.Add(period);
                    }
                }
            }

            if (APeriod != -1)
            {
                if (listPeriod.Where(p => p.ShortPeriod_005 == APeriod).Count() > 0)
                {
                    PeriodDetail_101 pTemp = listPeriod.Where(p => p.ShortPeriod_005 == APeriod).First();
                    listPeriod.Clear();
                    listPeriod.Add(pTemp);
                }
                else
                {
                    listPeriod.Clear();
                }
            }
        }