public override void CreateUninitializedItem(System.Web.HttpContext context, string id, int timeout)
        {
            UserSession userSession = new UserSession();
            userSession.SessionID = id;
            userSession.ApplicationName = ApplicationName;
            userSession.Created = DateTime.Now.ToUniversalTime();
            userSession.Expires = DateTime.Now.AddMinutes((Double)timeout).ToUniversalTime();
            userSession.LockDate = DateTime.Now.ToUniversalTime();
            userSession.LockId = 0;
            userSession.Timeout = timeout;
            userSession.Locked = false;
            userSession.Flags = 1;

            var collection = new StateItemCollection(ApplicationName, ConnectionString);
            userSession.ChildIdentifier = collection.SessionOwner;

            var result = CurrentCollection.Insert<UserSession>(userSession);
            if(result != null)
                if (!result.Ok)
                    throw new Exception("");
        }
        public override void SetAndReleaseItemExclusive(System.Web.HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
        {
            if (lockId == null)
                lockId = 0; //Default

            if (newItem)
            {
                UserSession userSession = new UserSession();
                userSession.SessionID = id;
                userSession.ApplicationName = ApplicationName;
                userSession.Created = DateTime.Now.ToUniversalTime();
                userSession.Expires = DateTime.Now.AddMinutes((Double)item.Timeout).ToUniversalTime();
                userSession.LockDate = DateTime.Now.ToUniversalTime();
                userSession.LockId = 0;
                userSession.Timeout = item.Timeout;
                userSession.Locked = false;
                userSession.Flags = 1;
                if (item == null)
                    item = CreateNewStoreData(context, 20);
                userSession.ChildIdentifier = (item.Items as StateItemCollection).SessionOwner;
                CurrentCollection.Insert<UserSession>(userSession);
            }
            else
            {
                var query = Query.And(Query.EQ("SessionID", id), Query.EQ("ApplicationName", ApplicationName), Query.EQ("LockId", (Int32) lockId));
                UserSession userSession = CurrentCollection.FindOneAs<UserSession>(query);
                if (userSession != null)
                {
                    userSession.Expires = DateTime.Now.AddMinutes((Double)item.Timeout).ToUniversalTime();
                    if (item == null)
                        item = CreateNewStoreData(context, 20);
                    userSession.Locked = false;
                    userSession.ChildIdentifier = (item.Items as StateItemCollection).SessionOwner;
                    CurrentCollection.Save<UserSession>(userSession);
                }
            }
        }