Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Start event of the Session control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Session_Start(object sender, EventArgs e)
        {
            Session.Timeout = 200;
            this.Application.Lock();
            this.Application["visitors_online"] = Convert.ToInt32(this.Application["visitors_online"]) + 1;
            this.Application.UnLock();
            try
            {
                StatisticModels statisticModels = new StatisticModels();
                DataTable       dtb             = statisticModels.StatisticTable();
                if (dtb.Rows.Count > 0)
                {
                    this.Application["HomNay"]     = long.Parse("0" + dtb.Rows[0]["HomNay"]).ToString("#,###");
                    this.Application["HomQua"]     = long.Parse("0" + dtb.Rows[0]["HomQua"]).ToString("#,###");
                    this.Application["TuanNay"]    = long.Parse("0" + dtb.Rows[0]["TuanNay"]).ToString("#,###");
                    this.Application["TuanTruoc"]  = long.Parse("0" + dtb.Rows[0]["TuanTruoc"]).ToString("#,###");
                    this.Application["ThangNay"]   = long.Parse("0" + dtb.Rows[0]["ThangNay"]).ToString("#,###");
                    this.Application["ThangTruoc"] = long.Parse("0" + dtb.Rows[0]["ThangTruoc"]).ToString("#,###");
                    this.Application["TatCa"]      = long.Parse("0" + dtb.Rows[0]["TatCa"]).ToString("#,###");
                }

                dtb.Dispose();
                statisticModels = null;
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        public ActionResult Statistic()
        {
            RatingModels  ratingModels   = new RatingModels();
            ContactModels contactModels  = new ContactModels();
            var           statistic_view = new Statistic_view();
            ////Thống kê truy cập theo tháng trong năm (lấy 12 tháng gần nhất)
            List <C_Statistic> arrAll = new List <C_Statistic>();

            arrAll = StatisticModels.ListAll();

            StringBuilder sb = new StringBuilder();

            for (int j = 0; j < arrAll.Count; j++)
            {
                if (j < arrAll.Count - 1)
                {
                    sb.Append("[gd(" + arrAll[j].year + ", " + arrAll[j].month + ",1), " + arrAll[j].SoTruyCap + "],");
                }
                else
                {
                    sb.Append("[gd(" + arrAll[j].year + ", " + arrAll[j].month + ",1), " + arrAll[j].SoTruyCap + "]");
                }
            }

            statistic_view.Chart_text = HttpUtility.HtmlEncode(sb.ToString());

            ////Danh sách review và bình luận mới sản phẩm mới nhất
            statistic_view.List_rating_last  = ratingModels.GetListRatingLast();
            statistic_view.List_contact_last = contactModels.GetListContactLast();

            return(this.PartialView("../control/statistic", statistic_view));
        }
Ejemplo n.º 3
0
        public void ChangeAndSaveUserStatistic(GameViewModel model, int winGames, int lossGames, int wholeWordGuessed)
        {
            StatisticModels userStatistic = ReadStatisticsFromFile(model.UserName, true).FirstOrDefault();

            userStatistic.WinGames                 += winGames;
            userStatistic.LossGames                += lossGames;
            userStatistic.PlayedGames              += 1;
            userStatistic.NumberOfTryGuessLetter   += model.NumberOfTryGuessLetter;
            userStatistic.NumberOfWholeWordGuessed += wholeWordGuessed;
            SaveStatisticToFile(userStatistic);
        }
Ejemplo n.º 4
0
        public void SaveStatisticToFile(StatisticModels userStats)
        {
            List <StatisticModels> repository = ReadStatisticsFromFile(userStats.UserName, false);

            if (repository != null)
            {
                repository.Add(userStats);
            }
            else
            {
                repository = new List <StatisticModels>()
                {
                    userStats
                };
            }
            string fileContent = JsonConvert.SerializeObject(repository);

            System.IO.File.WriteAllText(pathToStatisticsRepository, fileContent);
        }