Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed old directory

  • Loading branch information...
commit 7467501864fb6398c748f91e524ce1b8495f1026 1 parent 1935ff0
@Sedward Sedward authored
View
67 MongoDBSessionStore/MongoSessionStore.csproj
@@ -1,67 +0,0 @@
-<?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>MongoDBSessionStore</RootNamespace>
- <AssemblyName>MongoDBSessionStore</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" />
- <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 MongoDBSessionStore/MongoSessionStoreProvider.cs
@@ -1,369 +0,0 @@
-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 MongoDBSessionStore
-{
- 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, DateTime.Now.AddMinutes((Double)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;
- //timeout = reader.GetInt32(5);
-
- 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);
- }
- 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 MongoDBSessionStore/Properties/AssemblyInfo.cs
@@ -1,36 +0,0 @@
-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
114 MongoDBSessionStore/Session.cs
@@ -1,114 +0,0 @@
-using System;
-using System.Configuration;
-using System.Collections.Generic;
-using System.Web.SessionState;
-using System.Text;
-using MongoDB.Driver;
-using MongoDB.Driver.Configuration;
-
-namespace MongoDBSessionStore
-{
- 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);
- }
-
- #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
16 MongoDBSessionStore/SessionStore.cs
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace MongoDBSessionStore
-{
- public class SessionStore
- {
-
- public static void Insert(Session session)
- {
-
- }
- }
-}
View
7 MongoDBSessionStore/obj/Debug/MongoDBSessionStore.csproj.FileListAbsolute.txt
@@ -1,7 +0,0 @@
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\obj\Debug\ResolveAssemblyReference.cache
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\bin\Debug\MongoDBSessionStore.dll
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\bin\Debug\MongoDBSessionStore.pdb
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\bin\Debug\MongoDB.Driver.dll
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\bin\Debug\MongoDB.Driver.pdb
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\obj\Debug\MongoDBSessionStore.dll
-C:\Users\Seth\Documents\Visual Studio 2008\Projects\MytradeExperiment\MongoDBSessionStore\obj\Debug\MongoDBSessionStore.pdb
View
1  MongoDBSessionStore/obj/Debug/MongoSessionStore.csproj.FileListAbsolute.txt
@@ -1 +0,0 @@
-C:\Users\Seth\Projects\MongoSessionStore\MongoDBSessionStore\obj\Debug\ResolveAssemblyReference.cache
Please sign in to comment.
Something went wrong with that request. Please try again.