LogSessionExported() приватный Метод

private LogSessionExported ( string key ) : void
key string
Результат void
Пример #1
0
        /// <summary>
        /// Ends an external session export
        /// </summary>
        /// <param name="Key">Session key</param>
        /// <param name="RemoveSession">True to remove session from dictionary</param>
        public void EndExport(string Key, bool RemoveSession)
        {
            //This method resets the inuse property if the isExporting property is true

            if (Key == null)
            {
                throw new ArgumentNullException("Key");
            }

            AcquireReadLock();
            ISessionObject entry;

            try
            {
                dict.TryGetValue(Key, out entry);
            }
            finally
            {
                ReleaseReadLock();
            }

            if (entry == null)
            {
                //Session not found -- it's okay, don't freak out, session may have expired.
                return;
            }
            else
            {
                //Session Found
                if (entry.IsInUse)
                {
                    //The InUse flag, now check the isExporting flag
                    if (!entry.IsExporting)
                    {
                        Exception ex = new InvalidOperationException("EndExport must be called after a call to BeginExport");
                        Diags.LogApplicationError("EndExport must be called after a call to BeginExport -- Entry is InUse but IsExporting is false", ex);
                        throw ex;
                    }

                    try
                    {
                        //Delete session
                        if (RemoveSession)
                        {
                            AcquireWriteLock();
                            try
                            {
                                if (dict.Remove(Key))
                                {
                                    expiryList.Remove(Key);
                                    Diags.LogSessionDeleted(Key);
                                }
                            }
                            finally
                            {
                                ReleaseWriteLock();
                            }
                        }
                    }
                    finally
                    {
                        entry.IsExporting = false;
                        Diags.LogSessionExported(Key);
                        entry.CompareExchangeIsInUse(false, true);
                    }
                }
                else
                {
                    Exception ex = new InvalidOperationException("EndExport must be called after a call to BeginExport");
                    Diags.LogApplicationError("EndExport must be called after a call to BeginExport -- Entry is not in use", ex);
                    throw ex;
                }
            }
        }