示例#1
0
 public static void CounterState()
 {
     try
     {
         DateTime dt = ReturnPastTime.SetTime(DateTime.Now);
         if (HttpContext.Current.Request.Cookies["StateSite"] != null)
         {
             if (ReturnPastTime.SetTime(HttpContext.Current.Request.Cookies["StateSite"].Value.ToString()) != dt)
             {
                 HttpCookie cookieCode = new HttpCookie("StateSite", dt.ToString());
                 HttpContext.Current.Response.Cookies.Add(cookieCode);
                 CountUpState();
             }
         }
         else
         {
             CountUpState();
             HttpCookie cookie = new HttpCookie("StateSite");
             cookie.Value = dt.ToString();
             HttpContext.Current.Response.Cookies.Add(cookie);
         }
     }
     catch (Exception)
     {
     }
 }
示例#2
0
 public static ShowStateViewModel ShowState()
 {
     try
     {
         using (RealState_DBEntities db = new RealState_DBEntities())
         {
             DateTime dt  = ReturnPastTime.SetTime(DateTime.Now);
             DateTime dt2 = dt.AddDays(-1);
             return(new ShowStateViewModel()
             {
                 OnlineUser = (int)HttpContext.Current.Application["OnlineUser"],
                 SeeSum = db.StateSites.Sum(s => s.StateSiteCount),
                 SeeToday = db.StateSites.First(s => s.StateSiteDate == dt).StateSiteCount,
                 SeeYesterday = db.StateSites.Where(s => s.StateSiteDate == dt2).Select(s => s.StateSiteCount).FirstOrDefault()
             });
         }
     }
     catch (Exception)
     {
         throw;
     }
 }