示例#1
0
        protected void LoadData()
        {
            string key = string.Format("Prediction-{0}", Guid.NewGuid().ToString());

            hfCache.Value = key;

            // load setting
            BizPredictionGameSettings settings = TNHelper.GetPredictionGameSettings();

            if (settings != null && settings.Timer > 0)
            {
                hfTimer.Value = settings.Timer.ToString();
                pnlQuestion.Attributes["style"] = "display: none";
            }

            // check user already play this game
            User user = Utils.GetCurrentUser();
            PredictionGameUser pgu = TNHelper.GetPredictionGameUserByGameId(settings.PredictionGameID, user.Id);

            prePlayedInfo.Visible = false;

            if (pgu != null)
            {
                PredictionGameUser               = pgu;
                prePlayedInfo.Visible            = true;
                divContainer.Attributes["class"] = "invisible " + divContainer.Attributes["class"];
            }

            // load radom question and save to cache
            PredictionGame pgame = TNHelper.GetCurrentPredictionGame();

            if (pgame != null && pgame.Predictionses.Count > 0)
            {
                Prediction prediction = pgame.Predictionses[0] as Prediction;
                LoadAnswerList(prediction);
                litQuestion.Text = prediction.PredictionName;
                litInfo.Text     = string.Format("Bạn đang trả lời câu hỏi {0}/{1}", 1, pgame.Predictionses.Count);
                CMSCache.Insert(key, pgame);

                hfIndex.Value = "0";
                hfTotal.Value = pgame.Predictionses.Count.ToString();

                hfID.Value = prediction.Id.ToString();
            }
            else
            {
                Utils.ShowMessage(lblMsg, "Mời bạn quay lại sau, bạn vui lòng xem thông báo ở cột bên phải để biết thêm chi tiết.");
                divContainer.Visible  = false;
                prePlayedInfo.Visible = false;
            }
        }