/// <summary>
 /// 创建未初始化的项
 /// </summary>
 /// <param name="context"></param>
 /// <param name="id"></param>
 /// <param name="timeout"></param>
 public void CreateUninitializedItem(System.Web.HttpContext context, string id, int timeout)
 {
     var session = new MongoDBSessionDo()
     {
         ApplicationName = "",
         SessionId = id,
         Created = DateTime.Now,
         Expired = DateTime.Now.AddMinutes(sessionStateSection.Timeout.TotalMinutes),
         LockDate = DateTime.Now,
         LockId = 0,
         Locked = false,
         Flags = (Int32)SessionStateActions.InitializeItem,
         TimeOut = timeout
     };
     collection.Save(session);
 }
        /// <summary>
        /// 设置并释放项
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        /// <param name="item"></param>
        /// <param name="lockId"></param>
        /// <param name="newItem"></param>
        public void SetAndReleaseItem(System.Web.HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
        {
            MongoDBSessionDo session;
            if (newItem)
            {
                //删除过期的会话信息
                collection.Remove(Query.And(Query.EQ("_id", id), Query.LT("Expired", DateTime.Now)));

                //插入新的会话信息
                session = new MongoDBSessionDo()
                {
                    SessionId = id,
                    Created = DateTime.Now,
                    Expired = DateTime.Now.AddMinutes(sessionStateSection.Timeout.TotalMinutes),
                    LockDate = DateTime.Now,
                    LockId = 0,
                    Locked = false,
                    TimeOut = item.Timeout,
                    SessionItem = Serialize((SessionStateItemCollection)item.Items),
                    Flags = (Int32)SessionStateActions.None
                };
                collection.Save(session);
            }
            else { 
                //更新会话信息
                var query = Query.And(Query.EQ("_id", id), Query.EQ("LockId", (Int32)lockId));
                session = collection.FindOne(query);
                session.Expired = DateTime.Now.AddMinutes(item.Timeout);
                session.SessionItem = Serialize((SessionStateItemCollection)item.Items);
                session.Locked = false;
                var update = Update.Set("Expired", DateTime.Now.AddMinutes(item.Timeout))
                                   .Set("SessionItem", Serialize((SessionStateItemCollection)item.Items))
                                   .Set("Locked", false);
                
                collection.Update(query, update);
            }
        }