Пример #1
0
        void UpdateSession(string id, int timeout, SessionDictionary dict)
        {
            ((IDataParameter)updateCommand.Parameters["SessionID"]).Value   = id;
            ((IDataParameter)updateCommand.Parameters["Expires"]).Value     = DateTime.Now.AddMinutes(timeout);
            ((IDataParameter)updateCommand.Parameters["Timeout"]).Value     = timeout;
            ((IDataParameter)updateCommand.Parameters["SessionData"]).Value = dict.ToByteArray();

            updateCommand.ExecuteNonQuery();
        }
		public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,
							bool required, bool read_only, ref bool isNew)
		{
			if (!required)
				return null;

			StateServerItem item = null;
			HttpSessionState session = null;
			SessionDictionary dict = null;
			HttpStaticObjectsCollection sobjs = null;
			string id = GetId (context);

			if (id != null) {
				item = state_server.Get (id);
				if (item != null) {
					dict = SessionDictionary.FromByteArray (item.DictionaryData);
					sobjs = HttpStaticObjectsCollection.FromByteArray (item.StaticObjectsData);
					session = new HttpSessionState (id, dict,
							HttpApplicationFactory.ApplicationState.SessionObjects,
							config.Timeout, false, config.CookieLess,
							SessionStateMode.StateServer, read_only);

					return session;
				}
			}
			
			id = SessionId.Create (module.Rng);
			dict = new SessionDictionary ();
			sobjs = HttpApplicationFactory.ApplicationState.SessionObjects;
			item = new StateServerItem (dict.ToByteArray (), sobjs.ToByteArray (), config.Timeout);
			
			state_server.Insert (id, item);

			session = new HttpSessionState (id, dict, sobjs, config.Timeout, true,
							config.CookieLess, SessionStateMode.StateServer,
							read_only);
			
			isNew = true;
			return session;
		}
		void UpdateSession (string id, int timeout, SessionDictionary dict)
		{
			((IDataParameter)updateCommand.Parameters["SessionID"]).Value = id;
			((IDataParameter)updateCommand.Parameters["Expires"]).Value = DateTime.Now.AddMinutes (timeout);
			((IDataParameter)updateCommand.Parameters["Timeout"]).Value = timeout;
			((IDataParameter)updateCommand.Parameters["SessionData"]).Value = dict.ToByteArray ();
			
			updateCommand.ExecuteNonQuery ();
		}
		private void UpdateSession (string id, SessionDictionary dict)
		{
			IDbCommand command = cnc.CreateCommand ();
			IDataParameterCollection param;

			string update = "UPDATE ASPStateTempSessions SET " +
			"SessionData = :SessionData WHERE SessionId = :SessionID";

			command.CommandText = update;

			param = command.Parameters;
			param.Add (CreateParam (command, DbType.String, ":SessionID", id));
			param.Add (CreateParam (command, DbType.Binary, ":SessionData",
								dict.ToByteArray ()));

			command.ExecuteNonQuery ();
		}