internal static void Action() { OnlineStatic os = OnlineStaticHelper.Select(Session.SessionID); os.LastTime = DateTime.Now; OnlineStaticHelper.Update(Session.SessionID, os); }
internal static OnlineStatic Select() { //return OnlineStaticHelper.Select(Session.SessionID); return(OnlineStaticHelper.Select(Session.SessionID)); }
/// <summary> /// 檢查Session是否還在,依據cookie取出使用者資訊,並取出該使用者的資料 /// </summary> private bool CheckLoginInfo(HttpContextBase httpContext) { bool result = false; //if (string.IsNullOrEmpty(httpContext.Session.GetValue<int>(SessionKey.UserId).ToString())) //{ //沒有使用者資訊 //session不在,所以check cookie是否在 //string cookieName = FormsAuthentication.FormsCookieName; //HttpCookie authCookie = httpContext.Request.Cookies[cookieName]; //FormsAuthenticationTicket authTicket = null; //authTicket = FormsAuthentication.Decrypt(authCookie.Value); //string usrid = authTicket.Name; string SessionID = ((FormsIdentity)httpContext.User.Identity).Ticket.UserData; if (string.IsNullOrEmpty(SessionID) == false) { // //自動登入系統 // //FormsService.SignIn(usrid, true); // var ou = OnlineUserHelper.GetUserOnline(SessionID); // if (object.Equals(null, ou)) // { // AuthRules.SignOut(); // return result; // } // try // { // if (ou.IsLeave) // { // Rules.Exit(SessionID); // return result; // } // } // catch (System.Exception ex) // { // AuthRules.SignOut(); // return result; // } // OnlineUserHelper.removeUserOnline(SessionID); // Rules.Reset(ou); var ou = OnlineStaticHelper.Select(SessionID); if (ou.Id == 0) { Rule.Dispose(); return(result); } if (ou.IsLeave) { Rule.Dispose(); return(result); } Rule.Action(); httpContext.Session.SetValue <int>(SessionKey.UserId, Convert.ToInt32(httpContext.User.Identity.Name)); result = true; } //} //else { // result = true; //} return(result); }