Amazon.SessionProvider.DynamoDBSessionStateStore.SetAndReleaseItemExclusive C# (CSharp) Méthode

SetAndReleaseItemExclusive() public méthode

Updates the session-item information in the session-state data store with values from the current request, and clears the lock on the data.
public SetAndReleaseItemExclusive ( HttpContext context, string sessionId, System.Web.SessionState.SessionStateStoreData item, object lockId, bool newItem ) : void
context System.Web.HttpContext The HttpContext for the current request.
sessionId string The session identifier for the current request.
item System.Web.SessionState.SessionStateStoreData The SessionStateStoreData object that contains the current session values to be stored.
lockId object The lock identifier for the current request.
newItem bool true to identify the session item as a new item; false to identify the session item as an existing item.
Résultat void
        public override void SetAndReleaseItemExclusive(HttpContext context,
                                                         string sessionId,
                                                         SessionStateStoreData item,
                                                         object lockId,
                                                         bool newItem)
        {
            string serialized = serialize(item.Items as SessionStateItemCollection);

            Document newValues = new Document();
            newValues[ATTRIBUTE_SESSION_ID] = GetHashKey(sessionId);
            newValues[ATTRIBUTE_LOCKED] = false;
            newValues[ATTRIBUTE_LOCK_ID] = null;
            newValues[ATTRIBUTE_LOCK_DATE] = DateTime.Now;
            newValues[ATTRIBUTE_EXPIRES] = DateTime.Now.Add(this._timeout);
            newValues[ATTRIBUTE_FLAGS] = 0;
            newValues[ATTRIBUTE_SESSION_ITEMS] = serialized;
            newValues[ATTRIBUTE_RECORD_FORMAT_VERSION] = CURRENT_RECORD_FORMAT_VERSION;

            if (newItem)
            {
                newValues[ATTRIBUTE_CREATE_DATE] = DateTime.Now;
                this._table.PutItem(newValues);
            }
            else
            {
                Document expected = new Document();
                expected[ATTRIBUTE_LOCK_ID] = lockId.ToString();

                // Not really any reason the condition should fail unless we get in some sort of weird
                // app pool reset mode.
                try
                {
                    this._table.UpdateItem(newValues, new UpdateItemOperationConfig() { Expected = expected });
                }
                catch (ConditionalCheckFailedException) { }
            }
        }