/// <summary> /// 根据session 获取缓存中的session /// app /// </summary> /// <param name="sessionid"></param> /// <returns></returns> public UserSession GetUserSession(string sessionid) { if (string.IsNullOrEmpty(sessionid)) { return(null); } UserSession userSession = BLL.Cache.DataCache.Get(sessionid) as UserSession; if (userSession == null) // attempt access db session { var dbsession = new Model.dt_session().Get(sessionid); if (dbsession == null) { return(null); } else { // session timeout if (dbsession.LastLoginTime < DateTime.Now.AddMinutes(-1 * new BLL.siteconfig().loadConfig().websessioncache)) { return(null); } string msg = string.Empty; userSession = Login(dbsession.UserName, out msg); userSession.SESSIONID = sessionid; userSession.LASTLOGINTIME = dbsession.LastLoginTime; userSession.Plateform = dbsession.Plateform; userSession.Version = dbsession.Version; } } //if (userSession != null) //{ // userSession.LASTLOGINTIME = DateTime.Now; // new Model.dt_session() // { // LastLoginTime = userSession.LASTLOGINTIME, // SessionID = userSession.SESSIONID, // LOGFLAG = userSession.LOGFLAG, // UserName = userSession.USERNAME // }.Merge(); // BLL.Cache.MemoryCacheManager.Add(userSession.SESSIONID, userSession, new DateTimeOffset(DateTime.Now.AddMinutes(new BLL.siteconfig().loadConfig().websessioncache))); // SetUserSession(userSession); //} return(userSession); }
public bool Insert(Model.dt_session item) { return(MSSQLAccess.InsertData("DT_SESSION", item)); }