private void CreateFixtureListView()
        {
            if (_searchTeamIDs == null ||
                _searchTeamNames == null ||
                _searchTeamIDs.Length != _searchTeamNames.Length)
            {
                return;
            }

            // 텝 셋팅
            for (int i = 0; i < _searchTeamIDs.Length; i++)
            {
                tabContainer.Items.Add(new MenuItem($"&nbsp{_searchTeamNames[i].ToString()}&nbsp", i.ToString()));
            }

            // set standing
            _leagueStanding = Singleton.Get <RedisCacheManager>()
                              .Get <IList <WebFormModel.FootballStandings> >
                              (
                () => RequestLoader.FootballStandingsByLeagueId(_searchLeagueID),
                RequestLoader.Locker_FootballStandingsByLeagueId,
                DateTime.Now.AddHours(1),
                RedisKeyMaker.FootballStandingsByLeagueId(_searchLeagueID)
                              );

            // 그리드 아이템 셋팅
            BindData(_searchTeamIDs);
        }
        protected void GV_FootballFixtures_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var dataItem = e.Row.DataItem as WebFormModel.FootballFixture;

                var chk_interestedFixture = e.Row.FindControl("chk_interestedFixture") as CheckBox;

                var homeHyperLink = e.Row.FindControl("hl_homeTeamLink") as HyperLink;
                var awayHyperLink = e.Row.FindControl("hl_awayTeamLink") as HyperLink;

                homeHyperLink.NavigateUrl = GetRouteUrl("FootballTeamById", new { TeamId = dataItem.AwayTeam.TeamId });
                awayHyperLink.NavigateUrl = GetRouteUrl("FootballTeamById", new { TeamId = dataItem.AwayTeam.TeamId });

                if (dataItem != null)
                {
                    chk_interestedFixture.Checked = true;

                    // 리그 5위 이상 팀 Bold체
                    var leaugeStandings = Singleton.Get <RedisCacheManager>()
                                          .Get <IList <WebFormModel.FootballStandings> >
                                          (
                        () => RequestLoader.FootballStandingsByLeagueId(dataItem.LeagueId),
                        RequestLoader.Locker_FootballStandingsByLeagueId,
                        DateTime.Now.AddHours(4),
                        RedisKeyMaker.FootballStandingsByLeagueId(dataItem.LeagueId)
                                          );

                    var homeStandingInfo = leaugeStandings.Where(elem => elem.TeamId == dataItem.HomeTeam.TeamId).FirstOrDefault();
                    var awayStandingInfo = leaugeStandings.Where(elem => elem.TeamId == dataItem.AwayTeam.TeamId).FirstOrDefault();

                    if (homeStandingInfo?.Rank <= 5)
                    {
                        homeHyperLink.Font.Bold = true;
                    }

                    if (awayStandingInfo?.Rank <= 5)
                    {
                        awayHyperLink.Font.Bold = true;
                    }
                }

                // 단폴픽 체크
                var prediction = Singleton.Get <RedisCacheManager>()
                                 .Get <IList <WebFormModel.FootballPrediction> >
                                 (
                    () => RequestLoader.FootballPredictionByFixtureId(dataItem.FixtureId),
                    RequestLoader.Locker_FootballPredictionByFixtureId,
                    DateTime.Now.AddDays(1),
                    RedisKeyMaker.FootballPredictionByFixtureId(dataItem.FixtureId)
                                 ).FirstOrDefault();

                if (prediction?.MatchWinner?.Trim(' ').Length == 1)
                {
                    e.Row.BackColor = Color.LightGreen;
                }
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Login()
        {
            var result = await RequestLoader
                         .LoadPing <GetLoggedInUserHandler, UserIdentity>()
                         .WithResponseMappedTo <UserIdentityViewModel>()
                         .InvokeAsync();

            return(Ok(result));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> CreateUserAsync()
        {
            var createdBacklog = await RequestLoader
                                 .LoadPing <CreateBacklogRequestHandler, Core.Models.Backlog>()
                                 .WithResponseMappedTo <BacklogViewModel>()
                                 .InvokeAsync();

            return(CreatedAtAction(nameof(GetBacklogByIdAsync), new { id = createdBacklog.Id }, createdBacklog));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> CreateUserAsync([FromBody] CreateUserProfileViewModel userProfileViewModel)
        {
            var createdUser = await RequestLoader
                              .LoadRequest <CreateUserProfileViewModel, CreateUserRequestHandler, UserProfile, UserProfile>(userProfileViewModel)
                              .WithDataMappedTo <UserProfile>()
                              .WithResponseMappedTo <UserProfileViewModel>()
                              .InvokeAsync();

            return(CreatedAtAction(nameof(GetUserByIdAsync), new { userId = createdUser.Id }, createdUser));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> ConfigureUserAsync([FromBody] ConfigureUserProfileViewModel userProfile)
        {
            var user = await RequestLoader
                       .LoadRequest <ConfigureUserProfileViewModel, ConfigureUserProfileRequestHandler, UserProfile, UserProfile>(userProfile)
                       .WithDataMappedTo <UserProfile>()
                       .WithResponseMappedTo <UserProfileViewModel>()
                       .InvokeAsync();

            return(Ok(user));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            int fixtureId = int.Parse(this.Page.RouteData.Values["FixtureId"].ToString());

            var fixture = Singleton.Get <RedisCacheManager>()
                          .Get <WebFormModel.FootballFixture>
                          (
                () => RequestLoader.FootballFixtureById(fixtureId),
                RequestLoader.Locker_FootballFixtureById,
                DateTime.Now.AddHours(1),
                RedisKeyMaker.FootballFixtureById(fixtureId)
                          );

            var curLeague = Singleton.Get <RedisCacheManager>()
                            .Get <WebFormModel.FootballLeague>
                            (
                () => RequestLoader.FootballSeasonsByLeagueId(fixture.LeagueId),
                RequestLoader.Locker_FootballSeasonsByLeagueId,
                DateTime.Now.AddDays(1),
                RedisKeyMaker.FootballSeasonsByLeagueId(fixture.LeagueId)
                            );

            // Standing
            ctrl_footballStanding.SetSearchTeamID(fixture.HomeTeam.TeamId, fixture.AwayTeam.TeamId);
            ctrl_footballStanding.SetSearchLeagueID(fixture.LeagueId);

            // H2H
            ctrl_FootballH2HFixtureList.SetSearchTeamID(fixture.HomeTeam.TeamId, fixture.AwayTeam.TeamId);

            // FixturesResult
            ctrl_footballTeamFixtureResults.SetSearchTeamID(fixture.HomeTeam.TeamId, fixture.AwayTeam.TeamId);
            ctrl_footballTeamFixtureResults.SetSearchTeamName(fixture.HomeTeam.TeamName, fixture.AwayTeam.TeamName);
            ctrl_footballTeamFixtureResults.SetSearchLeagueID(fixture.LeagueId);

            // Player
            //ctrl_footballPlayerList.SetSearchTeamID(fixture.HomeTeam.TeamID, fixture.AwayTeam.TeamID);
            //ctrl_footballPlayerList.SetSearchTeamName(fixture.HomeTeam.TeamName, fixture.AwayTeam.TeamName);
            //ctrl_footballPlayerList.SetSearchLeagueID(curLeague.LeagueID);

            //int startYear = curLeague.SeasonStart.Year;
            //int endYear = curLeague.SeasonEnd.Year;
            //if (startYear != endYear)
            //	ctrl_footballPlayerList.SetSearchSeason($"{startYear}-{endYear}");
            //else
            //	ctrl_footballPlayerList.SetSearchSeason($"{startYear}");
        }
        public WebFormModel.FootballPrediction GetFootballPrediction([RouteData] int fixtureID)
        {
            //TODO FixtureDetail 버전으로 바꾸기..
            var predictions = Singleton.Get <RedisCacheManager>()
                              .Get <IList <WebFormModel.FootballPrediction> >
                              (
                () => RequestLoader.FootballPredictionByFixtureId(fixtureID),
                RequestLoader.Locker_FootballPredictionByFixtureId,
                DateTime.Now.AddDays(1),
                RedisKeyMaker.FootballPredictionByFixtureId(fixtureID)
                              );

            return(predictions.FirstOrDefault());
        }
Exemplo n.º 9
0
        public async Task <IActionResult> GetUsernameByUsernameAsync([FromRoute] string username)
        {
            try
            {
                var foundUsername = await RequestLoader
                                    .LoadRequest <string, GetUsernameByUsernameRequestHandler, string, string>(username)
                                    .WithResponseMappedTo <GetUsernameByUsernameViewModel>()
                                    .InvokeAsync();

                return(Ok(foundUsername));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
        }
Exemplo n.º 10
0
        public IQueryable <dynamic> GetPredictionByOdds([RouteData] int fixtureID)
        {
            var oddsInfo = RequestLoader.FootballOddsByFixtureId(fixtureID);

            List <PredictionByOdds> list_predictionByOdds = new List <PredictionByOdds>();

            if (oddsInfo != null && oddsInfo.Bookmakers.Length > 0)
            {
                foreach (var bookMaker in oddsInfo.Bookmakers)
                {
                    var MatchWinnerInfo = bookMaker.BetInfos.Where(elem => elem.LabelType == OddsLabelType.Match_Winner).FirstOrDefault();
                    if (MatchWinnerInfo == null)
                    {
                        continue;
                    }

                    try
                    {
                        double refundRate        = 100.0 / ((100.0 / MatchWinnerInfo.BetValues[0].Odds) + (100.0 / MatchWinnerInfo.BetValues[1].Odds) + (100.0 / MatchWinnerInfo.BetValues[2].Odds)) * 100;
                        double predictionPG_Home = refundRate / MatchWinnerInfo.BetValues[0].Odds;
                        double predictionPG_Draw = refundRate / MatchWinnerInfo.BetValues[1].Odds;
                        double predictionPG_Away = refundRate / MatchWinnerInfo.BetValues[2].Odds;

                        var predictionByOdds = new PredictionByOdds
                        {
                            BookMakerName     = bookMaker.BookmakerName,
                            HomeOdds          = MatchWinnerInfo.BetValues[0].Odds,
                            DrawOdds          = MatchWinnerInfo.BetValues[1].Odds,
                            AwayOdds          = MatchWinnerInfo.BetValues[2].Odds,
                            RefundRate        = refundRate,
                            PredictionPG_Home = predictionPG_Home,
                            PredictionPG_Draw = predictionPG_Draw,
                            PredictionPG_Away = predictionPG_Away
                        };

                        list_predictionByOdds.Add(predictionByOdds);
                    }
                    catch
                    {
                        break;
                    }
                }
            }

            return(list_predictionByOdds.AsQueryable());
        }
Exemplo n.º 11
0
        public IEnumerable <WebFormModel.FootballStandings> GetStandings()
        {
            if (_searchLeagueID == 0 || _searchTeamIDs == null || _searchTeamIDs.Length < 2)
            {
                return(null);
            }

            var standings = Singleton.Get <RedisCacheManager>()
                            .Get <IList <WebFormModel.FootballStandings> >
                            (
                () => RequestLoader.FootballStandingsByLeagueId(_searchLeagueID),
                RequestLoader.Locker_FootballStandingsByLeagueId,
                DateTime.Now.AddHours(1),
                RedisKeyMaker.FootballStandingsByLeagueId(_searchLeagueID)
                            );

            return(standings);
        }
        public IEnumerable <Pose_sports_statistics.Models.FootballFixture> GetH2HFixtures()
        {
            if (_searchTeamIDs == null || _searchTeamIDs.Length < 2)
            {
                return(null);
            }

            var fixtures = Singleton.Get <RedisCacheManager>()
                           .Get <IList <WebFormModel.FootballFixture> >
                           (
                () => RequestLoader.FootballH2HFixtureByTeamId(_searchTeamIDs[0], _searchTeamIDs[1]),
                RequestLoader.Locker_FootballH2HFixtureByTeamId,
                DateTime.Now.AddHours(12),
                RedisKeyMaker.FootballH2HFixtureByTeamId(_searchTeamIDs[0], _searchTeamIDs[1])
                           );

            return(fixtures?.Where(elem => elem.MatchTime > DateTime.Now.AddYears(-3) && elem.MatchTime < DateTime.Now)
                   .OrderByDescending(elem => elem.MatchTime));
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            CreatePlayerListView();

            // databind top scorer
            gv_topScorer.DataSource = Singleton.Get <RedisCacheManager>()
                                      .Get <IList <WebFormModel.FootballPlayer> >
                                      (
                () => RequestLoader.FootballTopScorerByLeagueId(_searchLeagID),
                RequestLoader.Locker_FootballTopScorerByLeagueId,
                DateTime.Now.AddDays(1),
                RedisKeyMaker.FootballTopScorerByLeagueId(_searchLeagID)
                                      );
            gv_topScorer.DataBind();
        }
Exemplo n.º 14
0
        private void CreatePlayerListByLeague(params int[] searchTeamIDs)
        {
            // view1
            if (searchTeamIDs.Length > 0)
            {
                var homePlayers = Singleton.Get <RedisCacheManager>()
                                  .Get <IList <WebFormModel.FootballPlayer> >
                                  (
                    () => RequestLoader.FootballPlayersByTeamIdAndSeason(searchTeamIDs[0], _searchSeason),
                    RequestLoader.Locker_FootballPlayersByTeamIdAndSeason,
                    DateTime.Now.AddDays(1),
                    RedisKeyMaker.FootballPlayersByTeamIdAndSeason(searchTeamIDs[0], _searchSeason)
                                  ).GroupBy(elem => elem.League);

                if (homePlayers?.Count() > 0)
                {
                    BindPlayerByLeague(ref menu_homeLeagues, ref mview_homePlayers, ref homePlayers);
                }
            }

            //view2
            if (searchTeamIDs.Length > 1)
            {
                var awayPlayers = Singleton.Get <RedisCacheManager>()
                                  .Get <IList <WebFormModel.FootballPlayer> >
                                  (
                    () => RequestLoader.FootballPlayersByTeamIdAndSeason(searchTeamIDs[1], _searchSeason),
                    RequestLoader.Locker_FootballPlayersByTeamIdAndSeason,
                    DateTime.Now.AddDays(1),
                    RedisKeyMaker.FootballPlayersByTeamIdAndSeason(searchTeamIDs[1], _searchSeason)
                                  ).GroupBy(elem => elem.League);

                if (awayPlayers?.Count() > 0)
                {
                    BindPlayerByLeague(ref menu_awayLeagues, ref mview_awayPlayers, ref awayPlayers);
                }
            }
        }
        public IQueryable <dynamic> GetFixtures([RouteData] string countryName)
        {
            var fixtures = Singleton.Get <RedisCacheManager>()
                           .Get <IList <WebFormModel.FootballFixture> >
                           (
                () => RequestLoader.FootballFixturesByDate(DateTime.Now),
                RequestLoader.Locker_FootballFixturesByDate,
                DateTime.Now.AddHours(4),
                RedisKeyMaker.FootballFixturesByDate(DateTime.Now)
                           );

            // step1. 종료된 경기는 필터링
            IEnumerable <WebFormModel.FootballFixture> filteredByData;

            if (string.IsNullOrEmpty(countryName))
            {
                filteredByData = fixtures.Where(elem => elem.MatchTime > DateTime.Now.AddHours(-2));
            }
            else
            {
                filteredByData = fixtures.Where(elem => elem.MatchTime > DateTime.Now.AddHours(-2) && elem.League.Country.Equals(countryName));
            }

            // step2. 데이터를 리그, 시작시간으로 그룹화
            var group_query = filteredByData.GroupBy(elem => new { League = elem.LeagueId, StartTime = elem.MatchTime });

            var result_query = from queryData in group_query
                               select new
            {
                League = queryData.FirstOrDefault().League.Name,
                queryData.Key.StartTime,
                queryData.FirstOrDefault()?.League.Flag,
                Fixtures = queryData.ToArray()
            };

            return(result_query.AsQueryable());
        }
        public void DDLBindData()
        {
            List <DDL_NameValue> ddlDataList = new List <DDL_NameValue>();

            ddlDataList.Add(new DDL_NameValue {
                Name = "Filtered by country"
            });

            var fixtures = Singleton.Get <RedisCacheManager>()
                           .Get <IList <WebFormModel.FootballFixture> >
                           (
                () => RequestLoader.FootballFixturesByDate(DateTime.Now),
                RequestLoader.Locker_FootballFixturesByDate,
                DateTime.Now.AddHours(4),
                RedisKeyMaker.FootballFixturesByDate(DateTime.Now)
                           );

            // 종료된 경기 필터링
            var exclusive_finished = fixtures.Where(elem => elem.MatchTime > DateTime.Now.AddHours(-2));

            var group_query = exclusive_finished.GroupBy(elem => new { CountryName = elem.League.Country });

            var bindData = from queryData in group_query
                           select new DDL_NameValue
            {
                Name  = queryData.Key.CountryName,
                Value = queryData.Key.CountryName,
            };

            ddlDataList.AddRange(bindData);

            ddl_kindCountry.DataTextField  = "Name";
            ddl_kindCountry.DataValueField = "Value";
            ddl_kindCountry.DataSource     = ddlDataList;
            ddl_kindCountry.DataBind();
        }
Exemplo n.º 17
0
 protected virtual void OnRequestLoader(bool isShow)
 {
     RequestLoader?.Invoke(isShow);
 }
    protected void btnStart_Click(object sender, EventArgs e)
    {
        mLastError = "";
        mCancel = false;
        mSuccessRequests = 0;
        mErrors = 0;
        mRun = true;

        mDuration = txtDuration.Text.Trim();
        mInterval = txtInterval.Text.Trim();
        mIterations = txtIterations.Text.Trim();
        mThreads = txtThreads.Text.Trim();
        mURLs = txtURLs.Text.Trim();
        mUserAgent = txtUserAgent.Text.Trim();
        mUserName = ValidationHelper.GetString(userElem.Value, "");
        mSplitURLs = chkSplitUrls.Checked;

        if (!String.IsNullOrEmpty(txtURLs.Text))
        {
            // Prepare the parameters
            string[] urls = txtURLs.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < urls.Length; i++)
            {
                urls[i] = URLHelper.GetAbsoluteUrl(urls[i]);
            }

            int newThreads = ValidationHelper.GetInteger(txtThreads.Text, 0);
            if (newThreads > 0)
            {
                int duration = ValidationHelper.GetInteger(txtDuration.Text, 0);
                int interval = ValidationHelper.GetInteger(txtInterval.Text, 0);
                int iterations = ValidationHelper.GetInteger(txtIterations.Text, 0);
                bool splitUrls = ValidationHelper.GetBoolean(chkSplitUrls.Checked, false);

                DateTime runUntil = DateTime.Now.AddSeconds(duration);

                // Divide URLs between threads
                string[][] partUrls = null;
                if (splitUrls)
                {
                    // Do not run more threads than URLs
                    newThreads = Math.Min(urls.Length, newThreads);

                    partUrls = new string[newThreads][];

                    int size = (int)Math.Ceiling((double)urls.Length / newThreads);
                    for (int i = 0; i < newThreads; i++)
                    {
                        size = Math.Min(size, urls.Length - i * size);
                        partUrls[i] = new string[size];
                        for (int j = 0; j < size; j++)
                        {
                            partUrls[i][j] = urls[i * size + j];
                        }
                    }
                }

                // Run specified number of threads
                for (int i = 0; i < newThreads; i++)
                {
                    // Prepare the loader object
                    RequestLoader loader = new RequestLoader();
                    loader.URLs = (splitUrls ? partUrls[i] : urls);
                    loader.WaitInterval = interval;
                    loader.UserAgent = txtUserAgent.Text.Trim();
                    loader.UserName = ValidationHelper.GetString(userElem.Value, "").Trim();
                    if (duration > 0)
                    {
                        loader.RunUntil = runUntil;
                    }
                    if (iterations > 0)
                    {
                        loader.NumberOfIterations = iterations;
                    }

                    // Start new thread
                    CMSThread newThread = new CMSThread(loader.Run);
                    newThread.Start();
                }

                DisableAll();
                btnStop.Enabled = true;
                btnReset.Enabled = true;
            }
        }
    }
Exemplo n.º 19
0
 internal virtual void OnRequestLoader(bool isShow)
 {
     RequestLoader?.Invoke(isShow);
 }
Exemplo n.º 20
0
    protected void btnStart_Click(object sender, EventArgs e)
    {
        mLastError       = "";
        mCancel          = false;
        mSuccessRequests = 0;
        mErrors          = 0;
        mRun             = true;

        mDuration   = txtDuration.Text.Trim();
        mInterval   = txtInterval.Text.Trim();
        mIterations = txtIterations.Text.Trim();
        mThreads    = txtThreads.Text.Trim();
        mURLs       = txtURLs.Text.Trim();
        mUserAgent  = txtUserAgent.Text.Trim();
        mUserName   = ValidationHelper.GetString(userElem.Value, "");
        mSplitURLs  = chkSplitUrls.Checked;

        if (!String.IsNullOrEmpty(txtURLs.Text))
        {
            // Prepare the parameters
            string[] urls = txtURLs.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < urls.Length; i++)
            {
                urls[i] = URLHelper.GetAbsoluteUrl(urls[i]);
            }

            int newThreads = ValidationHelper.GetInteger(txtThreads.Text, 0);
            if (newThreads > 0)
            {
                int  duration   = ValidationHelper.GetInteger(txtDuration.Text, 0);
                int  interval   = ValidationHelper.GetInteger(txtInterval.Text, 0);
                int  iterations = ValidationHelper.GetInteger(txtIterations.Text, 0);
                bool splitUrls  = ValidationHelper.GetBoolean(chkSplitUrls.Checked, false);

                DateTime runUntil = DateTime.Now.AddSeconds(duration);

                // Divide URLs between threads
                string[][] partUrls = null;
                if (splitUrls)
                {
                    // Do not run more threads than URLs
                    newThreads = Math.Min(urls.Length, newThreads);

                    partUrls = new string[newThreads][];

                    int size = (int)Math.Ceiling((double)urls.Length / newThreads);
                    for (int i = 0; i < newThreads; i++)
                    {
                        size        = Math.Min(size, urls.Length - i * size);
                        partUrls[i] = new string[size];
                        for (int j = 0; j < size; j++)
                        {
                            partUrls[i][j] = urls[i * size + j];
                        }
                    }
                }

                // Run specified number of threads
                for (int i = 0; i < newThreads; i++)
                {
                    // Prepare the loader object
                    RequestLoader loader = new RequestLoader();
                    loader.URLs         = (splitUrls ? partUrls[i] : urls);
                    loader.WaitInterval = interval;
                    loader.UserAgent    = txtUserAgent.Text.Trim();
                    loader.UserName     = ValidationHelper.GetString(userElem.Value, "").Trim();
                    if (duration > 0)
                    {
                        loader.RunUntil = runUntil;
                    }
                    if (iterations > 0)
                    {
                        loader.NumberOfIterations = iterations;
                    }

                    // Start new thread
                    CMSThread newThread = new CMSThread(loader.Run);
                    newThread.Start();
                }

                DisableAll();
                btnStop.Enabled  = true;
                btnReset.Enabled = true;
            }
        }
    }
Exemplo n.º 21
0
    private bool RunThreads()
    {
        var s = Settings;

        if (!String.IsNullOrEmpty(s.URLs))
        {
            int newThreads = ValidationHelper.GetInteger(s.Threads, 0);
            if (newThreads > 0)
            {
                // Prepare the parameters
                string[] urls = s.URLs.Split(new[]
                {
                    '\r',
                    '\n'
                }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < urls.Length; i++)
                {
                    urls[i] = URLHelper.GetAbsoluteUrl(urls[i]);
                }

                int  duration   = ValidationHelper.GetInteger(s.Duration, 0);
                int  interval   = ValidationHelper.GetInteger(s.Interval, 0);
                int  iterations = ValidationHelper.GetInteger(s.Iterations, 0);
                bool splitUrls  = ValidationHelper.GetBoolean(s.SplitURLs, false);

                DateTime runUntil = DateTime.Now.AddSeconds(duration);

                // Divide URLs between threads
                string[][] partUrls = null;

                if (splitUrls)
                {
                    // Do not run more threads than URLs
                    newThreads = Math.Min(urls.Length, newThreads);

                    partUrls = new string[newThreads][];

                    int size = (int)Math.Ceiling((double)urls.Length / newThreads);

                    for (int i = 0; i < newThreads; i++)
                    {
                        size        = Math.Min(size, urls.Length - i * size);
                        partUrls[i] = new string[size];

                        for (int j = 0; j < size; j++)
                        {
                            partUrls[i][j] = urls[i * size + j];
                        }
                    }
                }

                // Run specified number of threads
                for (int i = 0; i < newThreads; i++)
                {
                    // Prepare the loader object
                    RequestLoader loader = new RequestLoader();

                    loader.URLs         = (splitUrls ? partUrls[i] : urls);
                    loader.WaitInterval = interval;
                    loader.UserAgent    = s.UserAgent;
                    loader.UserName     = ValidationHelper.GetString(userElem.Value, "").Trim();

                    if (duration > 0)
                    {
                        loader.RunUntil = runUntil;
                    }

                    if (iterations > 0)
                    {
                        loader.NumberOfIterations = iterations;
                    }

                    // Start new thread
                    CMSThread newThread = new CMSThread(loader.Run);
                    newThread.Start();
                }

                return(true);
            }
        }

        return(false);
    }
        private void BindData(params int[] searchTeamIDs)
        {
            // view1
            if (searchTeamIDs.Length > 0)
            {
                var homefixtures = Singleton.Get <RedisCacheManager>()
                                   .Get <IList <WebFormModel.FootballFixture> >
                                   (
                    () => RequestLoader.FootballFixtureByTeamId(_searchTeamIDs[0]),
                    RequestLoader.Locker_FootballFixtureByTeamId,
                    DateTime.Now.AddHours(12),
                    RedisKeyMaker.FootballFixtureByTeamId(_searchTeamIDs[0])
                                   );

                // 지난 경기
                var homeLateFixtures = homefixtures.Where(elem => elem.MatchTime < DateTime.Now)
                                       .OrderByDescending(elem => elem.MatchTime)
                                       .Take(20);

                if (homeLateFixtures?.Count() > 0)
                {
                    gv_homeLateFixtures.DataSource = homeLateFixtures;
                    gv_homeLateFixtures.DataBind();
                }

                // 예정된 경기
                var homeReserveFixtures = homefixtures.Where(elem => elem.MatchTime > DateTime.Now)
                                          .Take(10);
                if (homeReserveFixtures?.Count() > 0)
                {
                    gv_homeReserveFixtures.DataSource = homeReserveFixtures;
                    gv_homeReserveFixtures.DataBind();
                }
            }

            //view2
            if (searchTeamIDs.Length > 1)
            {
                var awayfixtures = Singleton.Get <RedisCacheManager>()
                                   .Get <IList <WebFormModel.FootballFixture> >
                                   (
                    () => RequestLoader.FootballFixtureByTeamId(_searchTeamIDs[1]),
                    RequestLoader.Locker_FootballFixtureByTeamId,
                    DateTime.Now.AddHours(12),
                    RedisKeyMaker.FootballFixtureByTeamId(_searchTeamIDs[1])
                                   );

                // 지난 경기
                var awayLateFixtures = awayfixtures.Where(elem => elem.MatchTime < DateTime.Now)
                                       .OrderByDescending(elem => elem.MatchTime)
                                       .Take(20);

                if (awayLateFixtures?.Count() > 0)
                {
                    gv_awayLateFixtures.DataSource = awayLateFixtures;
                    gv_awayLateFixtures.DataBind();
                }

                // 예정된 경기
                var awayReserveFixtures = awayfixtures.Where(elem => elem.MatchTime > DateTime.Now)
                                          .Take(10);
                if (awayReserveFixtures?.Count() > 0)
                {
                    gv_awayReserveFixtures.DataSource = awayReserveFixtures;
                    gv_awayReserveFixtures.DataBind();
                }
            }
        }
        protected void Form_fixture_DataBound(object sender, EventArgs e)
        {
            if (form_fixture.Row != null)
            {
                var dataItem = this.form_fixture.DataItem as WebFormModel.FootballFixture;

                // Load data
                var standings = Singleton.Get <RedisCacheManager>()
                                .Get <IList <WebFormModel.FootballStandings> >
                                (
                    () => RequestLoader.FootballStandingsByLeagueId(dataItem.LeagueId),
                    RequestLoader.Locker_FootballStandingsByLeagueId,
                    DateTime.Now.AddHours(1),
                    RedisKeyMaker.FootballStandingsByLeagueId(dataItem.LeagueId)
                                );

                var homeTeamStatistics = Singleton.Get <RedisCacheManager>()
                                         .Get <WebFormModel.FootballTeamStatistics>
                                         (
                    () => RequestLoader.FootballTeamStatisticsByLeagueIDAndTeamId(dataItem.LeagueId, dataItem.HomeTeam.TeamId),
                    RequestLoader.Locker_FootballTeamStatisticsByLeagueIDAndTeamId,
                    DateTime.Now.AddHours(12),
                    RedisKeyMaker.FootballTeamStatisticsByLeagueIdAndTeamId(dataItem.LeagueId, dataItem.HomeTeam.TeamId)
                                         );

                var awayTeamStatistics = Singleton.Get <RedisCacheManager>()
                                         .Get <WebFormModel.FootballTeamStatistics>
                                         (
                    () => RequestLoader.FootballTeamStatisticsByLeagueIDAndTeamId(dataItem.LeagueId, dataItem.AwayTeam.TeamId),
                    RequestLoader.Locker_FootballTeamStatisticsByLeagueIDAndTeamId,
                    DateTime.Now.AddHours(12),
                    RedisKeyMaker.FootballTeamStatisticsByLeagueIdAndTeamId(dataItem.LeagueId, dataItem.AwayTeam.TeamId)
                                         );

                // page process
                var homeStandingInfo = standings.Where(elem => elem.TeamId == dataItem.HomeTeam.TeamId).FirstOrDefault();
                var awayStandingInfo = standings.Where(elem => elem.TeamId == dataItem.AwayTeam.TeamId).FirstOrDefault();

                // 홈 순위, 최근 결과
                if (homeStandingInfo != null)
                {
                    var lbl_homeRank = this.form_fixture.Row.FindControl("lbl_homeRank") as Label;
                    lbl_homeRank.Text = homeStandingInfo.Rank.ToString();

                    if (homeStandingInfo.Forme != null)
                    {
                        for (int i = 0; i < homeStandingInfo.Forme.Length; i++)
                        {
                            var label = this.form_fixture.Row.FindControl($"home_form_{i}") as Label;
                            label.Text = homeStandingInfo.Forme[homeStandingInfo.Forme.Length - 1 - i].ToString();

                            if (label.Text.Equals("W"))
                            {
                                label.ForeColor = Color.Green;
                            }
                            else if (label.Text.Equals("L"))
                            {
                                label.ForeColor = Color.Red;
                            }
                            else
                            {
                                label.ForeColor = Color.Orange;
                            }
                        }
                    }

                    var lbl_homePoint = this.form_fixture.Row.FindControl("lbl_homePoint") as Label;
                    lbl_homePoint.Text = homeStandingInfo.Points.ToString();
                }

                // 원정 순위, 최근 결과
                if (awayStandingInfo != null)
                {
                    var lbl_awayRank = this.form_fixture.Row.FindControl("lbl_awyaRank") as Label;
                    lbl_awayRank.Text = awayStandingInfo.Rank.ToString();

                    if (awayStandingInfo.Forme != null)
                    {
                        for (int i = 0; i < awayStandingInfo.Forme.Length; i++)
                        {
                            var label = this.form_fixture.Row.FindControl($"away_form_{i}") as Label;
                            label.Text = awayStandingInfo.Forme[awayStandingInfo.Forme.Length - 1 - i].ToString();

                            if (label.Text.Equals("W"))
                            {
                                label.ForeColor = Color.Green;
                            }
                            else if (label.Text.Equals("L"))
                            {
                                label.ForeColor = Color.Red;
                            }
                            else
                            {
                                label.ForeColor = Color.Orange;
                            }
                        }
                    }

                    var lbl_awayPoint = this.form_fixture.Row.FindControl("lbl_awayPoint") as Label;
                    lbl_awayPoint.Text = awayStandingInfo.Points.ToString();
                }

                // 전적
                var lbl_homeTotalRecord = this.form_fixture.Row.FindControl("lbl_homeTotalRecord") as Label;
                lbl_homeTotalRecord.Text = $"{homeTeamStatistics.Matchs.Wins.Total}/{homeTeamStatistics.Matchs.Draws.Total}/{homeTeamStatistics.Matchs.Loses.Total} " +
                                           $"({homeTeamStatistics.Matchs.Wins.Home}/{homeTeamStatistics.Matchs.Draws.Home}/{homeTeamStatistics.Matchs.Loses.Home})";

                var lbl_awayTotalRecord = this.form_fixture.Row.FindControl("lbl_awayTotalRecord") as Label;
                lbl_awayTotalRecord.Text = $"({awayTeamStatistics.Matchs.Wins.Away}/{awayTeamStatistics.Matchs.Draws.Away}/{awayTeamStatistics.Matchs.Loses.Away}) " +
                                           $"{awayTeamStatistics.Matchs.Wins.Total}/{awayTeamStatistics.Matchs.Draws.Total}/{awayTeamStatistics.Matchs.Loses.Total}";

                // 평균 득점
                var lbl_homeGoalsAvg = this.form_fixture.Row.FindControl("lbl_homeGoalsAvg") as Label;
                lbl_homeGoalsAvg.Text = $"{homeTeamStatistics.GoalsAvg.GoalsFor.Total} ({homeTeamStatistics.GoalsAvg.GoalsFor.Home})";

                var lbl_awayGoalsAvg = this.form_fixture.Row.FindControl("lbl_awayGoalsAvg") as Label;
                lbl_awayGoalsAvg.Text = $"({awayTeamStatistics.GoalsAvg.GoalsFor.Away}) {awayTeamStatistics.GoalsAvg.GoalsFor.Total}";

                // 평균 실점
                var lbl_homeGoalAgainst = this.form_fixture.Row.FindControl("lbl_homeGoalAgainst") as Label;
                lbl_homeGoalAgainst.Text = $"{homeTeamStatistics.GoalsAvg.GoalsAgainst.Total} ({homeTeamStatistics.GoalsAvg.GoalsAgainst.Home})";

                var lbl_awayGoalAgainst = this.form_fixture.Row.FindControl("lbl_awayGoalAgainst") as Label;
                lbl_awayGoalAgainst.Text = $"({awayTeamStatistics.GoalsAvg.GoalsAgainst.Away}) {awayTeamStatistics.GoalsAvg.GoalsAgainst.Total}";

                // 최근 6경기 득실점
                var lbl_homeLastSixPoints = this.form_fixture.Row.FindControl("lbl_homeLastSixPoints") as Label;
                lbl_homeLastSixPoints.Text = dataItem.HomeLateSixGoalPoints;

                var lbl_awayLastSixPoints = this.form_fixture.Row.FindControl("lbl_awayLastSixPoints") as Label;
                lbl_awayLastSixPoints.Text = dataItem.AwayLateSixGoalPoints;

                // 홈/원정 각 3경기 득실점
                var lbl_homeLastThreePoints = this.form_fixture.Row.FindControl("lbl_homeLastThreePoints") as Label;
                lbl_homeLastThreePoints.Text = dataItem.HomeLateThreeGoalPoints;

                var lbl_awayLastThreePoints = this.form_fixture.Row.FindControl("lbl_awayLastThreePoints") as Label;
                lbl_awayLastThreePoints.Text = dataItem.AwayLateThreeGoalPoints;

                // 회복기간
                var lbl_homeRecoveryDays = this.form_fixture.Row.FindControl("lbl_homeRecoveryDays") as Label;
                lbl_homeRecoveryDays.Text = dataItem.HomeRecoveryDays;

                var lbl_awayRecoveryDays = this.form_fixture.Row.FindControl("lbl_awayRecoveryDays") as Label;
                lbl_awayRecoveryDays.Text = dataItem.AwayRecoveryDays;
            }
        }
        protected void GV_FootballFixtures_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var dataItem = e.Row.DataItem as WebFormModel.FootballFixture;

                var chk_interestedFixture = e.Row.FindControl("chk_interestedFixture") as CheckBox;

                var homeHyperLink = e.Row.FindControl("hl_homeTeamLink") as HyperLink;
                var awayHyperLink = e.Row.FindControl("hl_awayTeamLink") as HyperLink;

                homeHyperLink.NavigateUrl = GetRouteUrl("FootballTeamById", new { TeamId = dataItem.AwayTeam.TeamId });
                awayHyperLink.NavigateUrl = GetRouteUrl("FootballTeamById", new { TeamId = dataItem.AwayTeam.TeamId });

                if (dataItem != null)
                {
                    // 관심경기 선택 여부

                    // 관심 경기 데이터 가져오기
                    var interestedFixtures = Singleton.Get <RedisCacheManager>()
                                             .GetNullable <IList <WebFormModel.FootballFixture> >
                                             (
                        RedisKeyMaker.FootballInterestedFixture()
                                             );
                    bool isInterestedFixture = interestedFixtures?.Where(elem => elem.FixtureId == dataItem.FixtureId).FirstOrDefault() != null;
                    chk_interestedFixture.Checked = isInterestedFixture;

                    // 리그 5위 이상 팀 Bold체
                    var leaugeStandings = Singleton.Get <RedisCacheManager>()
                                          .Get <IList <WebFormModel.FootballStandings> >
                                          (
                        () => RequestLoader.FootballStandingsByLeagueId(dataItem.LeagueId),
                        RequestLoader.Locker_FootballStandingsByLeagueId,
                        DateTime.Now.AddHours(4),
                        RedisKeyMaker.FootballStandingsByLeagueId(dataItem.LeagueId)
                                          );

                    var homeStandingInfo = leaugeStandings.Where(elem => elem.TeamId == dataItem.HomeTeam.TeamId).FirstOrDefault();
                    var awayStandingInfo = leaugeStandings.Where(elem => elem.TeamId == dataItem.AwayTeam.TeamId).FirstOrDefault();

                    if (homeStandingInfo?.Rank <= 5)
                    {
                        homeHyperLink.Font.Bold = true;
                    }

                    if (awayStandingInfo?.Rank <= 5)
                    {
                        awayHyperLink.Font.Bold = true;
                    }

                    // 팀 통계에 따른 폰트 색상
                    //var homeTeamStatistics = Singleton.Get<RedisCacheManager>()
                    //.Get<WebFormModel.FootballTeamStatistics>
                    //(
                    //	() => RequestLoader.FootballTeamStatisticsByLeagueIDAndTeamID(dataItem.LeagueID, dataItem.HomeTeam.TeamID),
                    //	RequestLoader.Locker_FootballTeamStatisticsByLeagueIDAndTeamID,
                    //	DateTime.Now.AddHours(12),
                    //	RedisKeyMaker.FootballTeamStatisticsByLeagueIDAndTeamID(dataItem.LeagueID, dataItem.HomeTeam.TeamID)
                    //);

                    //var awayTeamStatistics = Singleton.Get<RedisCacheManager>()
                    //.Get<WebFormModel.FootballTeamStatistics>
                    //(
                    //	() => RequestLoader.FootballTeamStatisticsByLeagueIDAndTeamID(dataItem.LeagueID, dataItem.AwayTeam.TeamID),
                    //	RequestLoader.Locker_FootballTeamStatisticsByLeagueIDAndTeamID,
                    //	DateTime.Now.AddHours(12),
                    //	RedisKeyMaker.FootballTeamStatisticsByLeagueIDAndTeamID(dataItem.LeagueID, dataItem.AwayTeam.TeamID)
                    //);

                    //CheckTeamStaticAndApplyColor(homeTeamStatistics, homeHyperLink);
                    //CheckTeamStaticAndApplyColor(awayTeamStatistics, awayHyperLink);

                    // 팀 최근 6경기 득실점에 따른 폰트 색상
                    //var homefixtures = Singleton.Get<RedisCacheManager>()
                    //	.Get<IList<WebFormModel.FootballFixture>>
                    //	(
                    //		() => RequestLoader.FootballFixtureByTeamID(dataItem.HomeTeam.TeamID),
                    //		RequestLoader.Locker_FootballFixtureByTeamID,
                    //		DateTime.Now.AddHours(12),
                    //		RedisKeyMaker.FootballFixtureByTeamID(dataItem.HomeTeam.TeamID)
                    //	).Where(elem => elem.EventDate < DateTime.Now)
                    //	.OrderByDescending(elem => elem.EventDate);

                    //// 홈팀 최근 6경기 득실점
                    //int fixtureCnt = 0;
                    //int goalCnt = 0;
                    //int goalAgainst = 0;
                    //foreach (var selectedfixture in homefixtures)
                    //{
                    //	if (string.IsNullOrEmpty(selectedfixture.Score.FullTime)
                    //		|| selectedfixture.LeagueID != dataItem.LeagueID)
                    //		continue;

                    //	// 최근 5경기만..
                    //	if (fixtureCnt >= 6)
                    //		break;

                    //	bool isHomeTeam = selectedfixture.HomeTeam.TeamID == dataItem.HomeTeam.TeamID;
                    //	string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                    //	goalCnt += int.Parse(scoreSplit[isHomeTeam ? 0 : 1]);
                    //	goalAgainst += int.Parse(scoreSplit[isHomeTeam ? 1 : 0]);

                    //	fixtureCnt++;
                    //}

                    //CheckTeamGoalAgainstAndApplyColor(goalCnt, goalAgainst, homeHyperLink);

                    //var awayfixtures = Singleton.Get<RedisCacheManager>()
                    //	.Get<IList<WebFormModel.FootballFixture>>
                    //	(
                    //		() => RequestLoader.FootballFixtureByTeamID(dataItem.AwayTeam.TeamID),
                    //		RequestLoader.Locker_FootballFixtureByTeamID,
                    //		DateTime.Now.AddHours(12),
                    //		RedisKeyMaker.FootballFixtureByTeamID(dataItem.AwayTeam.TeamID)
                    //	).Where(elem => elem.EventDate < DateTime.Now)
                    //	.OrderByDescending(elem => elem.EventDate);

                    //// 어웨이팀 최근 6경기 득실점
                    //fixtureCnt = 0;
                    //goalCnt = 0;
                    //goalAgainst = 0;
                    //foreach (var selectedfixture in awayfixtures)
                    //{
                    //	if (string.IsNullOrEmpty(selectedfixture.Score.FullTime)
                    //		|| selectedfixture.LeagueID != dataItem.LeagueID)
                    //		continue;

                    //	// 최근 6경기만..
                    //	if (fixtureCnt >= 6)
                    //		break;

                    //	bool isHomeTeam = selectedfixture.HomeTeam.TeamID == dataItem.AwayTeam.TeamID;
                    //	string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                    //	goalCnt += int.Parse(scoreSplit[isHomeTeam ? 0 : 1]);
                    //	goalAgainst += int.Parse(scoreSplit[isHomeTeam ? 1 : 0]);

                    //	fixtureCnt++;
                    //}

                    //CheckTeamGoalAgainstAndApplyColor(goalCnt, goalAgainst, awayHyperLink);

                    //경기 예측(단폴픽 체크)
                    var prediction = Singleton.Get <RedisCacheManager>()
                                     .Get <IList <WebFormModel.FootballPrediction> >
                                     (
                        () => RequestLoader.FootballPredictionByFixtureId(dataItem.FixtureId),
                        RequestLoader.Locker_FootballPredictionByFixtureId,
                        DateTime.Now.AddDays(1),
                        RedisKeyMaker.FootballPredictionByFixtureId(dataItem.FixtureId)
                                     ).FirstOrDefault();

                    if (prediction?.MatchWinner?.Trim(' ').Length == 1)
                    {
                        e.Row.BackColor = Color.LightGreen;
                    }
                }
            }
        }
        public WebFormModel.FootballFixture GetFootballFixture([RouteData] int fixtureId)
        {
            var fixture = Singleton.Get <RedisCacheManager>()
                          .Get <WebFormModel.FootballFixture>
                          (
                () => RequestLoader.FootballFixtureById(fixtureId),
                RequestLoader.Locker_FootballFixtureById,
                DateTime.Now.AddHours(1),
                RedisKeyMaker.FootballFixtureById(fixtureId)
                          );

            var homefixtures = Singleton.Get <RedisCacheManager>()
                               .Get <IList <WebFormModel.FootballFixture> >
                               (
                () => RequestLoader.FootballFixtureByTeamId(fixture.HomeTeam.TeamId),
                RequestLoader.Locker_FootballFixtureByTeamId,
                DateTime.Now.AddHours(12),
                RedisKeyMaker.FootballFixtureByTeamId(fixture.HomeTeam.TeamId)
                               ).Where(elem => elem.MatchTime < DateTime.Now)
                               .OrderByDescending(elem => elem.MatchTime);

            var awayfixtures = Singleton.Get <RedisCacheManager>()
                               .Get <IList <WebFormModel.FootballFixture> >
                               (
                () => RequestLoader.FootballFixtureByTeamId(fixture.AwayTeam.TeamId),
                RequestLoader.Locker_FootballFixtureByTeamId,
                DateTime.Now.AddHours(12),
                RedisKeyMaker.FootballFixtureByTeamId(fixture.AwayTeam.TeamId)
                               ).Where(elem => elem.MatchTime < DateTime.Now)
                               .OrderByDescending(elem => elem.MatchTime);

            // 홈팀 최근 6경기 득실점
            int fixtureCnt  = 0;
            int goalCnt     = 0;
            int goalAgainst = 0;

            foreach (var selectedfixture in homefixtures)
            {
                if (string.IsNullOrEmpty(selectedfixture.Score.FullTime) ||
                    selectedfixture.LeagueId != fixture.LeagueId)
                {
                    continue;
                }

                // 최근 5경기만..
                if (fixtureCnt >= 6)
                {
                    break;
                }

                bool     isHomeTeam = selectedfixture.HomeTeam.TeamId == fixture.HomeTeam.TeamId;
                string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                goalCnt     += int.Parse(scoreSplit[isHomeTeam ? 0 : 1]);
                goalAgainst += int.Parse(scoreSplit[isHomeTeam ? 1 : 0]);

                fixtureCnt++;
            }
            fixture.HomeLateSixGoalPoints = $"{goalCnt} : {goalAgainst}";

            // 홈팀 최근 홈3경기 득실점
            fixtureCnt  = 0;
            goalCnt     = 0;
            goalAgainst = 0;
            foreach (var selectedfixture in homefixtures)
            {
                bool isHomeTeam = selectedfixture.HomeTeam.TeamId == fixture.HomeTeam.TeamId;
                if (string.IsNullOrEmpty(selectedfixture.Score.FullTime) ||
                    selectedfixture.LeagueId != fixture.LeagueId ||
                    !isHomeTeam)
                {
                    continue;
                }

                // 최근 3경기만..
                if (fixtureCnt >= 3)
                {
                    break;
                }

                string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                goalCnt     += int.Parse(scoreSplit[0]);
                goalAgainst += int.Parse(scoreSplit[1]);

                fixtureCnt++;
            }
            fixture.HomeLateThreeGoalPoints = $"{goalCnt} : {goalAgainst}";

            // 어웨이팀 최근 6경기 득실점
            fixtureCnt  = 0;
            goalCnt     = 0;
            goalAgainst = 0;
            foreach (var selectedfixture in awayfixtures)
            {
                if (string.IsNullOrEmpty(selectedfixture.Score.FullTime) ||
                    selectedfixture.LeagueId != fixture.LeagueId)
                {
                    continue;
                }

                // 최근 6경기만..
                if (fixtureCnt >= 6)
                {
                    break;
                }

                bool     isHomeTeam = selectedfixture.HomeTeam.TeamId == fixture.AwayTeam.TeamId;
                string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                goalCnt     += int.Parse(scoreSplit[isHomeTeam ? 0 : 1]);
                goalAgainst += int.Parse(scoreSplit[isHomeTeam ? 1 : 0]);

                fixtureCnt++;
            }
            fixture.AwayLateSixGoalPoints = $"{goalCnt} : {goalAgainst}";

            // 어웨이팀 최근 어웨이3경기 득실점
            fixtureCnt  = 0;
            goalCnt     = 0;
            goalAgainst = 0;
            foreach (var selectedfixture in awayfixtures)
            {
                bool isAwayTeam = selectedfixture.AwayTeam.TeamId == fixture.AwayTeam.TeamId;
                if (string.IsNullOrEmpty(selectedfixture.Score.FullTime) ||
                    selectedfixture.LeagueId != fixture.LeagueId ||
                    !isAwayTeam)
                {
                    continue;
                }

                // 최근 3경기만..
                if (fixtureCnt >= 3)
                {
                    break;
                }

                string[] scoreSplit = selectedfixture.Score.FullTime.Split('-');

                goalCnt     += int.Parse(scoreSplit[1]);
                goalAgainst += int.Parse(scoreSplit[0]);

                fixtureCnt++;
            }
            fixture.AwayLateThreeGoalPoints = $"{goalCnt} : {goalAgainst}";

            // 홈팀 회복기간
            var homeLastFixtures = homefixtures.FirstOrDefault();

            if (homeLastFixtures != null)
            {
                fixture.HomeRecoveryDays = $"{(fixture.MatchTime - homeLastFixtures.MatchTime).Days}일";
            }

            // 원정팀 회복기간
            var awayLastFixtures = awayfixtures.FirstOrDefault();

            if (awayLastFixtures != null)
            {
                fixture.AwayRecoveryDays = $"{(fixture.MatchTime - awayLastFixtures.MatchTime).Days}일";
            }

            return(fixture);
        }
    private bool RunThreads()
    {
        var s = Settings;

        if (!String.IsNullOrEmpty(s.URLs))
        {
            int newThreads = ValidationHelper.GetInteger(s.Threads, 0);
            if (newThreads > 0)
            {
                // Prepare the parameters
                string[] urls = s.URLs.Split(new[]
                {
                    '\r',
                    '\n'
                }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < urls.Length; i++)
                {
                    urls[i] = URLHelper.GetAbsoluteUrl(urls[i]);
                }

                int duration = ValidationHelper.GetInteger(s.Duration, 0);
                int interval = ValidationHelper.GetInteger(s.Interval, 0);
                int iterations = ValidationHelper.GetInteger(s.Iterations, 0);
                bool splitUrls = ValidationHelper.GetBoolean(s.SplitURLs, false);

                DateTime runUntil = DateTime.Now.AddSeconds(duration);

                // Divide URLs between threads
                string[][] partUrls = null;

                if (splitUrls)
                {
                    // Do not run more threads than URLs
                    newThreads = Math.Min(urls.Length, newThreads);

                    partUrls = new string[newThreads][];

                    int size = (int)Math.Ceiling((double)urls.Length / newThreads);

                    for (int i = 0; i < newThreads; i++)
                    {
                        size = Math.Min(size, urls.Length - i * size);
                        partUrls[i] = new string[size];

                        for (int j = 0; j < size; j++)
                        {
                            partUrls[i][j] = urls[i * size + j];
                        }
                    }
                }

                // Run specified number of threads
                for (int i = 0; i < newThreads; i++)
                {
                    // Prepare the loader object
                    RequestLoader loader = new RequestLoader();

                    loader.URLs = (splitUrls ? partUrls[i] : urls);
                    loader.WaitInterval = interval;
                    loader.UserAgent = s.UserAgent;
                    loader.UserName = ValidationHelper.GetString(userElem.Value, "").Trim();

                    if (duration > 0)
                    {
                        loader.RunUntil = runUntil;
                    }

                    if (iterations > 0)
                    {
                        loader.NumberOfIterations = iterations;
                    }

                    // Start new thread
                    CMSThread newThread = new CMSThread(loader.Run);
                    newThread.Start();
                }

                return true;
            }
        }

        return false;
    }
        /// <summary>
        /// 관심 경기 체크
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void chk_fixture_InterestedIndexChanged(Object sender, EventArgs e)
        {
            CheckBox chkbox = sender as CheckBox;

            if (chkbox == null)
            {
                return;
            }

            // 관심경기에 추가하는 경우
            if (chkbox.Checked)
            {
                // 모든 경기 가져오기
                var fixtures = Singleton.Get <RedisCacheManager>()
                               .Get <IList <WebFormModel.FootballFixture> >
                               (
                    () => RequestLoader.FootballFixturesByDate(DateTime.Now),
                    RequestLoader.Locker_FootballFixturesByDate,
                    DateTime.Now.AddHours(4),
                    RedisKeyMaker.FootballFixturesByDate(DateTime.Now)
                               );

                // 관심 경기 검색
                int interestedFixtureID = int.Parse(chkbox.ToolTip);
                var interestedFixture   = fixtures.Where(elem => elem.FixtureId == interestedFixtureID).FirstOrDefault();

                if (interestedFixture == null)
                {
                    return;
                }

                // 관심 경기 데이터 가져오기
                var interestedFixtures = Singleton.Get <RedisCacheManager>()
                                         .GetNullable <IList <WebFormModel.FootballFixture> >
                                         (
                    RedisKeyMaker.FootballInterestedFixture()
                                         );

                if (interestedFixtures == null)
                {
                    interestedFixtures = new List <WebFormModel.FootballFixture>();
                }

                // 관심 경기에 추가
                interestedFixtures.Add(interestedFixture);

                // 레디스에 저장
                Singleton.Get <RedisCacheManager>().Set
                (
                    JsonConvert.SerializeObject(interestedFixtures),
                    RequestLoader.Locker_FootballInterestedFixture,
                    new DateTime(9999, 12, 31),
                    RedisKeyMaker.FootballInterestedFixture()
                );
            }
            else // 관심경기에서 제거하는 경우
            {
                // 관심 경기 데이터 가져오기
                var interestedFixtures = Singleton.Get <RedisCacheManager>()
                                         .GetNullable <IList <WebFormModel.FootballFixture> >
                                         (
                    RedisKeyMaker.FootballInterestedFixture()
                                         );

                // 제거할 경기
                int interestedFixtureID = int.Parse(chkbox.ToolTip);
                var interestedFixture   = interestedFixtures.Where(elem => elem.FixtureId == interestedFixtureID).FirstOrDefault();

                if (interestedFixture == null)
                {
                    return; // 이미 제거된 경기
                }
                // 관심 경기에서 제거
                interestedFixtures.Remove(interestedFixture);

                // 레디스에 저장
                Singleton.Get <RedisCacheManager>().Set
                (
                    JsonConvert.SerializeObject(interestedFixtures),
                    RequestLoader.Locker_FootballInterestedFixture,
                    new DateTime(9999, 12, 31),
                    RedisKeyMaker.FootballInterestedFixture()
                );
            }
        }