Beispiel #1
0
        /// <summary>
        /// 將資料依日期做分類解析
        /// </summary>
        /// <param name="download">資料下載物件</param>
        /// <param name="teamData">聯盟/隊伍資料集合 ( Key: 聯盟, Value: 隊伍集合 )</param>
        private Dictionary<string, BasicInfo> Follow(BkOSDownload download, Dictionary<string, List<string>> teamData)
        {
            try
            {
                // 沒有資料就離開
                if (string.IsNullOrEmpty(download.Data))
                    return null;

                string data = String.Copy(download.Data);

                bool hasGameStart = false;
                Dictionary<string, BasicInfo> gameData = this.GetDataByBet007Basketball(data, isAcH: AcH, url: download.Uri.OriginalString);
                if (gameData == null || gameData.Count == 0) { return null; }

                // 聯盟/隊伍資料集合
                foreach (BasicInfo info in gameData.Values)
                {
                    // 有開賽時, 設定旗標
                    if ("S".Equals(info.GameStates)) { hasGameStart = true; }

                    // 聯盟/隊伍資料
                    string alliance = info.AllianceName;
                    string teamA = info.Away;
                    string teamB = info.Home;

                    List<string> teamList = (teamData.ContainsKey(alliance)) ? teamData[alliance] : new List<string>();
                    if (!teamList.Contains(teamA)) { teamList.Add(teamA); }
                    if (!teamList.Contains(teamB)) { teamList.Add(teamB); }

                    teamData[alliance] = teamList;
                }

                // 有開賽時 即時比分改每秒抓取
                this.DownChange.UpdateSecond = (hasGameStart) ? 1 : 5;

                return gameData;
            }
            catch { throw; }
        }
Beispiel #2
0
        public BkOS(DateTime today)
            : base(ESport.Basketball_OS)
        {
            // 讀取聯盟/隊伍翻譯表
            this.LoadAllianceAndTeamTable();

            this.Logs = new LogFile(ESport.Basketball_OS);//設定log type

            // 設定
            this.AllianceID = 0;
            this.GameType = "BKOS";
            this.GameDate = GetUtcTw(today).Date; // 只取日期
            this.DownReal = new List<BkOSDownload>();

            if (string.IsNullOrWhiteSpace(this.sWebUrl))
            {
                this.sWebUrl = @"http://interface.win007.com/lq/today.aspx";
            }
            if (string.IsNullOrWhiteSpace(this.sWebUrl1))
            {
                this.sWebUrl1 = @"http://interface.win007.com/lq/change.xml";
            }
            if (string.IsNullOrWhiteSpace(this.sWebUrl2))
            {
                this.sWebUrl2 = @"http://interface.win007.com/lq/LqSchedule.aspx?time={0:yyyy-MM-dd}";
            }
            // 今日
            var todayUrl = this.sWebUrl;
            this.DownToday = new BkOSDownload(this.Sport, GameDate, todayUrl, Encoding.UTF8, "today");

            // 即時資料
            var changeUrl = this.sWebUrl1;
            this.DownChange = new BkOSDownload(this.Sport, GameDate, changeUrl, Encoding.GetEncoding("gb2312"), "change", 5);

            // 昨天/未來一周
            for (int i = startIndex; i <= endIndex; i++)
            {
                DateTime gameDate = this.GameDate.AddDays(i);
                var url = String.Format(this.sWebUrl2, gameDate);
                this.DownReal.Add(new BkOSDownload(this.Sport, gameDate, url, Encoding.UTF8, String.Format("LqSchedule_{0:yyyy-MM-dd}", gameDate)));
            }

            #region 從資料庫中取得舊資料

            GetOldGames();

            #endregion 從資料庫中取得舊資料
        }
Beispiel #3
0
 /// <summary>
 /// 下載資料
 /// </summary>
 /// <param name="download"></param>
 private void Download(BkOSDownload download)
 {
     // 沒有資料或下載時間超過更新秒數時才讀取資料。
     if (!download.LastTime.HasValue ||
             DateTime.Now > download.LastTime.Value.AddSeconds(download.UpdateSecond))
     {
         download.DownloadString();
     }
 }