Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed some directory names

  • Loading branch information...
commit 1935ff0aa8f06a13acc1cd5e91cd62e66c0d9ad4 1 parent 5bc129d
@Sedward Sedward authored
View
69 MongoSessionStore/MongoSessionStore.csproj
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{354D379B-E16C-40DE-B26F-8CCF2EDE94D8}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>MongoSessionStore</RootNamespace>
+ <AssemblyName>MongoSessionStore</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="MongoDB.Driver, Version=1.0.3729.17015, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\mongo\mongodb-csharp\MongoDBDriver\bin\Debug\MongoDB.Driver.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MongoSessionStoreProvider.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Session.cs" />
+ <Compile Include="SessionStore.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
369 MongoSessionStore/MongoSessionStoreProvider.cs
@@ -0,0 +1,369 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using System.Collections.Specialized;
+using System.Web;
+using System.Web.Configuration;
+using System.Configuration;
+using System.Configuration.Provider;
+using System.Web.SessionState;
+using MongoDB.Driver;
+using MongoDB.Driver.Configuration;
+
+
+namespace MongoSessionStore
+{
+ public sealed class MongoSessionStoreProvider : SessionStateStoreProviderBase
+ {
+ private SessionStateSection sessionStateSection = null;
+ private string eventSource = "MongoSessionStore";
+ private string eventLog = "Application";
+
+ private bool _logExceptions = false;
+ public bool WriteExceptionsToEventLog
+ {
+ get { return _logExceptions; }
+ set { _logExceptions = value; }
+ }
+
+ //
+ // The ApplicationName property is used to differentiate sessions
+ // in the data source by application.
+ //
+ public string _applicationName;
+ public string ApplicationName
+ {
+ get { return _applicationName; }
+ }
+
+ public override void Initialize(string name, NameValueCollection config)
+ {
+ if (config == null)
+ throw new ArgumentNullException("config");
+
+ if (name == null || name.Length == 0)
+ name = "MongoSessionStore";
+
+ if (String.IsNullOrEmpty(config["description"]))
+ {
+ config.Remove("description");
+ config.Add("description", "MongoDB Session State Store provider");
+ }
+ // Initialize the abstract base class.
+ base.Initialize(name, config);
+
+ _applicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
+
+ Configuration cfg = WebConfigurationManager.OpenWebConfiguration(ApplicationName);
+ sessionStateSection = (SessionStateSection)cfg.GetSection("system.web/sessionState");
+ if (config["writeExceptionsToEventLog"] != null)
+ {
+ if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE")
+ _logExceptions = true;
+ }
+ }
+
+ public override void Dispose()
+ {
+ }
+
+ public override bool SetItemExpireCallback(SessionStateItemExpireCallback expireCallback)
+ {
+ return false;
+ }
+
+ public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
+ {
+ string sessionItems = Serialize((SessionStateItemCollection)item.Items);
+
+ try
+ {
+ if (newItem)
+ {
+ // Delete an existing expired session if it exists.
+ SessionStore.EvictExpiredSession(id, _applicationName);
+
+ // insert new session item.
+ Session session = new Session(id, this._applicationName, item.Timeout, sessionItems, item.Items.Count,0);
+ SessionStore.Insert(session);
+ }
+ else
+ {
+ SessionStore.UpdateSession(id, item.Timeout, sessionItems, this._applicationName, item.Items.Count, lockId);
+ }
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "SetAndReleaseItemExclusive");
+ throw new ProviderException(e.Message, e.InnerException);
+ }
+ else
+ throw e;
+ }
+ }
+
+
+ public override SessionStateStoreData GetItem(HttpContext context,
+ string id,
+ out bool locked,
+ out TimeSpan lockAge,
+ out object lockId,
+ out SessionStateActions actionFlags)
+ {
+ return GetSessionStoreItem(false, context, id, out locked, out lockAge, out lockId, out actionFlags);
+ }
+
+ public override SessionStateStoreData GetItemExclusive(HttpContext context,
+ string id,
+ out bool locked,
+ out TimeSpan lockAge,
+ out object lockId,
+ out SessionStateActions actionFlags)
+ {
+ return GetSessionStoreItem(true, context, id, out locked, out lockAge, out lockId, out actionFlags);
+ }
+
+
+ //
+ // GetSessionStoreItem is called by both the GetItem and
+ // GetItemExclusive methods. GetSessionStoreItem retrieves the
+ // session data from the data source. If the lockRecord parameter
+ // is true (in the case of GetItemExclusive), then GetSessionStoreItem
+ // locks the record and sets a new LockId and LockDate.
+ //
+ private SessionStateStoreData GetSessionStoreItem(bool lockRecord,
+ HttpContext context,
+ string id,
+ out bool locked,
+ out TimeSpan lockAge,
+ out object lockId,
+ out SessionStateActions actionFlags)
+ {
+ // Initial values for return value and out parameters.
+ SessionStateStoreData item = null;
+ lockAge = TimeSpan.Zero;
+ lockId = null;
+ locked = false;
+ actionFlags = 0;
+
+ // String to hold serialized SessionStateItemCollection.
+ string serializedItems = "";
+ // Timeout value from the data store.
+ int timeout = 0;
+
+ try
+ {
+ Session session = SessionStore.Get(id, this._applicationName);
+ // lockRecord is true when called from GetItemExclusive and
+ // false when called from GetItem.
+ // Obtain a lock if possible. Evict the record if it is expired.
+ if (session == null)
+ {
+ // Not found. The locked value is false.
+ locked = false;
+ }
+ else if(session.Expires < DateTime.Now)
+ {
+ locked = false;
+ SessionStore.EvictSession(session);
+
+ }
+ else if (session.Locked)
+ {
+ locked = true;
+ lockAge = DateTime.Now.Subtract(session.LockDate);
+ lockId = session.LockID;
+ }
+ else
+ {
+ locked = false;
+ lockId = session.LockID;
+ actionFlags = (SessionStateActions)session.Flags;
+
+
+ if (lockRecord)
+ {
+ lockId = (int)lockId + 1;
+ session.LockID = lockId;
+ session.Flags = 0;
+ SessionStore.LockSession(session);
+ }
+
+ if (actionFlags == SessionStateActions.InitializeItem)
+ item = CreateNewStoreData(context, sessionStateSection.Timeout.Minutes);
+ else
+ item = Deserialize(context, serializedItems, timeout);
+ }
+
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "GetSessionStoreItem");
+ throw new ProviderException(e.Message,e.InnerException);
+ }
+ else
+ throw e;
+ }
+ return item;
+ }
+
+ //
+ // Serialize is called by the SetAndReleaseItemExclusive method to
+ // convert the SessionStateItemCollection into a Base64 string to
+ // be stored in an Access Memo field.
+ //
+
+ private string Serialize(SessionStateItemCollection items)
+ {
+ MemoryStream ms = new MemoryStream();
+ BinaryWriter writer = new BinaryWriter(ms);
+
+ if (items != null)
+ items.Serialize(writer);
+
+ writer.Close();
+
+ return Convert.ToBase64String(ms.ToArray());
+ }
+
+ //
+ // DeSerialize is called by the GetSessionStoreItem method to
+ // convert the Base64 string stored in the Access Memo field to a
+ // SessionStateItemCollection.
+ //
+
+ private SessionStateStoreData Deserialize(HttpContext context, string serializedItems, int timeout)
+ {
+ MemoryStream ms =
+ new MemoryStream(Convert.FromBase64String(serializedItems));
+
+ SessionStateItemCollection sessionItems =
+ new SessionStateItemCollection();
+
+ if (ms.Length > 0)
+ {
+ BinaryReader reader = new BinaryReader(ms);
+ sessionItems = SessionStateItemCollection.Deserialize(reader);
+ }
+
+ return new SessionStateStoreData(sessionItems,
+ SessionStateUtility.GetSessionStaticObjects(context),
+ timeout);
+ }
+
+ //
+ // SessionStateProviderBase.ReleaseItemExclusive
+ //
+ public override void ReleaseItemExclusive(HttpContext context, string id, object lockId)
+ {
+ try
+ {
+ SessionStore.ReleaseLock(id, this._applicationName, lockId, sessionStateSection.Timeout.TotalMinutes);
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "ReleaseItemExclusive");
+ throw new ProviderException(e.Message,e.InnerException);
+ }
+ else
+ throw e;
+ }
+
+ }
+
+
+ //
+ // SessionStateProviderBase.RemoveItem
+ //
+
+ public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item)
+ {
+ try
+ {
+ SessionStore.EvictSession(id, this._applicationName, lockId);
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "RemoveItem");
+ throw new ProviderException(e.Message,e.InnerException);
+ }
+ else
+ throw e;
+ }
+ }
+
+ public override void CreateUninitializedItem(HttpContext context,string id,int timeout)
+ {
+ Session session = new Session(id,this._applicationName, timeout, String.Empty, 0, SessionStateActions.InitializeItem);
+
+ try
+ {
+ SessionStore.Insert(session);
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "CreateUninitializedItem");
+ throw new ProviderException(e.Message,e.InnerException);
+ }
+ else
+ throw e;
+ }
+ }
+
+ public override SessionStateStoreData CreateNewStoreData(HttpContext context,int timeout)
+ {
+ return new SessionStateStoreData(new SessionStateItemCollection(),SessionStateUtility.GetSessionStaticObjects(context),timeout);
+ }
+
+ public override void ResetItemTimeout(HttpContext context, string id)
+ {
+ try
+ {
+ SessionStore.UpdateSessionExpiration(id, DateTime.Now.AddMinutes(sessionStateSection.Timeout.TotalMinutes));
+ }
+ catch (Exception e)
+ {
+ if (WriteExceptionsToEventLog)
+ {
+ WriteToEventLog(e, "ResetItemTimeout");
+ throw new ProviderException(e.Message,e.InnerException);
+ }
+ else
+ throw e;
+ }
+ }
+
+ public override void InitializeRequest(HttpContext context)
+ {
+ }
+
+
+ public override void EndRequest(HttpContext context)
+ {
+ }
+
+ private void WriteToEventLog(Exception e, string action)
+ {
+ EventLog log = new EventLog();
+ log.Source = eventSource;
+ log.Log = eventLog;
+
+ string message =
+ "An exception occurred ";
+ message += "Action: " + action + "\n\n";
+ message += "Exception: " + e.ToString();
+ log.WriteEntry(message);
+ }
+ }
+}
View
36 MongoSessionStore/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MongoDBSessionStore")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MongoDBSessionStore")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a73ef248-cdcf-40f0-9f41-f393abfc1825")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
132 MongoSessionStore/Session.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Configuration;
+using System.Collections.Generic;
+using System.Web.SessionState;
+using System.Text;
+using MongoDB.Driver;
+using MongoDB.Driver.Configuration;
+
+namespace MongoSessionStore
+{
+ public class Session
+ {
+ private string _sessionID;
+ private DateTime _created;
+ private DateTime _expires;
+ private string _applicationName;
+ private DateTime _lockDate;
+ private object _lockID;
+ private int _timeout;
+ private bool _locked;
+ private string _sessionItems;
+ private int _sessionItemsCount;
+ private int _flags;
+
+
+ private OidGenerator oGen;
+
+ public Session() { }
+
+ public Session(string id, string applicationName, int timeout, string sessionItems, int sessionItemsCount,SessionStateActions actionFlags )
+ {
+ this._sessionID = id;
+ this._applicationName = applicationName;
+ this._lockDate = DateTime.Now;
+ this._lockID = 0;
+ this._timeout = timeout;
+ this._locked = false;
+ this._sessionItems = sessionItems;
+ this._sessionItemsCount = sessionItemsCount;
+ this._flags = (int)actionFlags;
+ this._created = DateTime.Now;
+ this._expires = DateTime.Now.AddMinutes((Double)this._timeout);
+ }
+
+ public Session(Document document)
+ {
+ this._sessionID = (string)document["SessionId"];
+ this._applicationName = (string)document["ApplicationName"];
+ this._lockDate = (DateTime)document["LockDate"];
+ this._lockDate = this._lockDate.ToLocalTime();
+ this._lockID = (int)document["LockId"];
+ this._timeout = (int)document["Timeout"];
+ this._locked = (bool)document["Locked"];
+ this._sessionItems = (string)document["SessionItems"];
+ this._sessionItemsCount = (int)document["SessionItemsCount"];
+ this._flags = (int)document["Flags"];
+ this._created = (DateTime)document["Created"];
+ this._created = this._created.ToLocalTime();
+ this._expires = (DateTime)document["Expires"];
+ this._expires = this._expires.ToLocalTime();
+ }
+
+ #region Properties
+ public string SessionID
+ {
+ get { return this._sessionID; }
+ set { this._sessionID = value; }
+ }
+
+ public DateTime Created
+ {
+ get { return this._created; }
+ set { this._created = value; }
+ }
+
+ public DateTime Expires
+ {
+ get { return this._expires; }
+ set { this._expires = value; }
+ }
+
+ public string ApplicationName
+ {
+ get { return this._applicationName; }
+ set { this._applicationName = value; }
+ }
+
+ public DateTime LockDate
+ {
+ get { return this._lockDate; }
+ set { this._lockDate = value; }
+ }
+
+ public object LockID
+ {
+ get { return this._lockID; }
+ set { this._lockID = value; }
+ }
+
+ public int Timeout
+ {
+ get { return this._timeout; }
+ set { this._timeout = value; }
+ }
+
+ public bool Locked
+ {
+ get { return this._locked; }
+ set { this._locked = value; }
+ }
+
+ public string SessionItems
+ {
+ get { return this._sessionItems; }
+ set { this._sessionItems = value; }
+ }
+
+ public int SessionItemsCount
+ {
+ get { return this._sessionItemsCount; }
+ set { this._sessionItemsCount = value; }
+ }
+
+ public int Flags
+ {
+ get { return this._flags; }
+ set { this._flags = value; }
+ }
+ #endregion
+
+ }
+}
View
163 MongoSessionStore/SessionStore.cs
@@ -0,0 +1,163 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using MongoDB.Driver;
+using MongoDB.Driver.Configuration;
+using MongoDB.Driver.Connections;
+using System.Text;
+
+namespace MongoSessionStore
+{
+ public sealed class SessionStore
+ {
+
+ static MongoConfiguration config = (MongoConfiguration)System.Configuration.ConfigurationManager.GetSection("Mongo");
+ static Connection conn = ConnectionFactory.GetConnection(config.Connections["mongoserver"].ConnectionString);
+ static Database db = new Database(conn, "SessionTest");
+ static IMongoCollection sessions = db.GetCollection("sessions");
+
+ public SessionStore()
+ {
+ }
+
+ public static void Insert(Session session)
+ {
+ Document newSession = new Document() { { "SessionId",session.SessionID }, {"ApplicationName",session.ApplicationName},{"Created",session.Created},
+ {"Expires",session.Expires},{"LockDate",session.LockDate},{"LockId",session.LockID},{"Timeout",session.Timeout},{"Locked",session.Locked},
+ {"SessionItems",session.SessionItems},{"SessionItemsCount",session.SessionItemsCount},{"Flags",session.Flags}};
+ try
+ {
+ conn.Open();
+ sessions.Insert(newSession);
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("Could not insert a new session", ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+
+ }
+
+ public static Session Get(string id, string applicationName)
+ {
+ Document selector = new Document() { { "SessionId", id }, { "ApplicationName", applicationName } };
+ Session session;
+ try
+ {
+ conn.Open();
+ Document sessionDoc = sessions.FindOne(selector);
+ session = new Session(sessionDoc);
+
+ if (session == null)
+ {
+ throw new Exception("The session was not found. SessionID: + " + id);
+ }
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("Could not insert a new session", ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ return session;
+ }
+
+ public static void UpdateSession(string id, int timeout, string sessionItems, string applicationName, int sessionItemsCount, object lockId)
+ {
+ try
+ {
+
+ Document selector = new Document() { { "SessionId", id }, { "ApplicationName", applicationName } };
+ Document session = new Document() { { "$set", new Document() { { "LockDate", DateTime.Now.AddMinutes((double)timeout) }, { "LockId", lockId }, { "Locked", true } } } };
+ conn.Open();
+ sessions.Update(session);
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("Could not insert a new session", ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+
+ public static void UpdateSessionExpiration(string id, string applicationName, double timeout)
+ {
+ Document selector = new Document() { { "SessionId", id}, { "ApplicationName", applicationName} };
+ Document sessionUpdate = new Document() { { "$set", new Document() { { "Expires", DateTime.Now.AddMinutes(timeout)} }}};
+ }
+
+ public static void EvictSession(Session session)
+ {
+ Document selector = new Document() { { "SessionId", session.SessionID }, { "ApplicationName", session.ApplicationName },{"LockId",session.LockID} };
+ try
+ {
+ sessions.Delete(selector);
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("There was a problem when evicting the session with SessionId:" + session.SessionID, ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+
+ public static void EvictSession(string id, string applicationName, object lockId)
+ {
+ Document selector = new Document() {{"SessionId", id }, { "ApplicationName", applicationName }, { "LockId", lockId}};
+ try
+ {
+ sessions.Delete(selector);
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("There was a problem when evicting the session with SessionId:" + id, ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+
+ public static void EvictExpiredSession(string id, string applicationName)
+ {
+ Document selector = new Document() { { "SessionId", id }, { "ApplicationName", applicationName },
+ {"Expires",new Document(){{"$lt",DateTime.Now}} }};
+ try
+ {
+ sessions.Delete(selector);
+ }
+ catch (MongoException ex)
+ {
+ throw new Exception("There was a problem when evicting the session with SessionId:" + id, ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+
+ public static void LockSession(Session session)
+ {
+ Document selector = new Document() {{"SessionId", session.SessionID }, {"ApplicationName", session.ApplicationName}};
+ Document sessionLock = new Document() { { "$set", new Document() {{"LockDate", session.LockDate },
+ {"LockId", session.LockID }, {"Locked", session.Locked }, {"Flags",session.Flags} } } };
+ sessions.Update(sessionLock, selector, 0, false);
+ }
+
+ public static void ReleaseLock(string id, string applicationName, object lockId, double timeout)
+ {
+ Document selector = new Document() { { "SessionId", id }, { "ApplicationName", applicationName},{"LockId",lockId }};
+ Document sessionLock = new Document() { { "$set", new Document() {{"Expires", DateTime.Now.AddMinutes(timeout)}, {"Locked", false }}}};
+ sessions.Update(sessionLock, selector, 0, false);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.