Amnesia.Module.PersistSessionState C# (CSharp) Метод

PersistSessionState() статический приватный Метод

Tracks information about the session so rollbacks can be handled cleanly across app domain restarts
static private PersistSessionState ( ) : void
Результат void
        internal static void PersistSessionState()
        {
            if (Session.ID == Guid.Empty)
            {
                if (File.Exists(stateFile))
                    File.Delete(stateFile);
            }
            else
            {
                // Make sure the parent directory is there before saving the file.
                if (!Directory.Exists(Path.GetDirectoryName(stateFile)))
                    Directory.CreateDirectory(Path.GetDirectoryName(stateFile));

                File.WriteAllText(stateFile, Session.ID.ToString());
            }
        }

Usage Example

Пример #1
0
            protected override void OnExecute(HttpContext ctx)
            {
                using (Session.Tracker.Exclusive(WebServerLockTimeoutMS, Response.Log))
                {
                    Session.AsyncLog.CopyInto(Response.AsyncLog);
                    Session.AsyncLog = new SerializableLog();

                    if (Session.IsActive)
                    {
                        Response.Log.Write("Ending the active session ({0})", Session.ID);
                        EndSession(Response.Log);
                        Response.Log.Write("Session has been ended");
                    }
                    else if (Session.IsRollbackPending)
                    {
                        // handle unexpected app domain restarts where there's no active session but a rollback is still expected
                        Session.IsRollbackPending = false;
                        Response.Log.Write("Cleaned up session after unexpected app domain restart");
                    }
                    else
                    {
                        Response.Log.Write("There is no active session to end");
                    }

                    Module.PersistSessionState();
                }
            }
All Usage Examples Of Amnesia.Module::PersistSessionState