예제 #1
0
        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
        {
            try
            {
                if (r == CacheItemRemovedReason.Expired)
                {
                    // Process the transaction queue on another thread
                    Task.Run(() => DrainTransactionQueue());

                    // add cache item again
                    AddCallBack();

                    // call a page on the site to keep IIS alive
                    if (!string.IsNullOrWhiteSpace(Global.BaseUrl))
                    {
                        string      url      = Global.BaseUrl + "KeepAlive.aspx";
                        WebRequest  request  = WebRequest.Create(url);
                        WebResponse response = request.GetResponse();
                    }
                }
                else
                {
                    if (r != CacheItemRemovedReason.Removed)
                    {
                        throw new Exception(
                                  string.Format("The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                                r.ConvertToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex, null);
            }
        }
예제 #2
0
        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
        {
            try
            {
                if (r == CacheItemRemovedReason.Expired)
                {
                    // Process the transaction queue on another thread
                    Task.Run(() => DrainTransactionQueue());

                    // add cache item again
                    AddCallBack();

                    var keepAliveUrl = GlobalAttributesCache.Value("KeepAliveUrl");
                    if (string.IsNullOrWhiteSpace(keepAliveUrl))
                    {
                        keepAliveUrl = GlobalAttributesCache.Value("InternalApplicationRoot") ?? string.Empty;
                        keepAliveUrl = keepAliveUrl.EnsureTrailingForwardslash() + "KeepAlive.aspx";
                    }

                    // call a page on the site to keep IIS alive
                    if (!string.IsNullOrWhiteSpace(keepAliveUrl))
                    {
                        try
                        {
                            WebRequest  request  = WebRequest.Create(keepAliveUrl);
                            WebResponse response = request.GetResponse();
                        }
                        catch (Exception ex)
                        {
                            LogError(new Exception("Error doing KeepAlive request.", ex), null);
                        }
                    }
                }
                else
                {
                    if (r != CacheItemRemovedReason.Removed)
                    {
                        throw new Exception(
                                  string.Format("The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                                r.ConvertToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(ex, null);
            }
        }
예제 #3
0
파일: Global.asax.cs 프로젝트: Ganon11/Rock
        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved( string k, object v, CacheItemRemovedReason r )
        {
            try
            {
                if ( r == CacheItemRemovedReason.Expired )
                {
                    // Process the transaction queue on another thread
                    Task.Run( () => DrainTransactionQueue() );

                    // add cache item again
                    AddCallBack();

                    // call a page on the site to keep IIS alive
                    if ( !string.IsNullOrWhiteSpace( Global.BaseUrl ) )
                    {
                        string url = Global.BaseUrl + "KeepAlive.aspx";
                        WebRequest request = WebRequest.Create( url );
                        WebResponse response = request.GetResponse();
                    }
                }
                else
                {
                    if ( r != CacheItemRemovedReason.Removed )
                    {
                        throw new Exception(
                            string.Format( "The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                r.ConvertToString() ) );
                    }
                }
            }
            catch ( Exception ex )
            {
                LogError( ex, null );
            }
        }
예제 #4
0
        /// <summary>
        /// Caches the item removed.
        /// </summary>
        /// <param name="k">The k.</param>
        /// <param name="v">The v.</param>
        /// <param name="r">The r.</param>
        public static void CacheItemRemoved( string k, object v, CacheItemRemovedReason r )
        {
            try
            {
                if ( r == CacheItemRemovedReason.Expired )
                {
                    // Process the transaction queue on another thread
                    Task.Run( () => DrainTransactionQueue() );

                    // add cache item again
                    AddCallBack();

                    var keepAliveUrl = GlobalAttributesCache.Value( "KeepAliveUrl" );
                    if ( string.IsNullOrWhiteSpace( keepAliveUrl ) )
                    {
                        keepAliveUrl = GlobalAttributesCache.Value( "InternalApplicationRoot" ) ?? string.Empty;
                        keepAliveUrl = keepAliveUrl.EnsureTrailingForwardslash() + "KeepAlive.aspx";
                    }

                    // call a page on the site to keep IIS alive
                    if ( !string.IsNullOrWhiteSpace( keepAliveUrl ) )
                    {
                        try
                        {
                            WebRequest request = WebRequest.Create( keepAliveUrl );
                            WebResponse response = request.GetResponse();
                        }
                        catch ( Exception ex )
                        {
                            LogError( new Exception( "Error doing KeepAlive request.", ex ), null );
                        }
                    }
                }
                else
                {
                    if ( r != CacheItemRemovedReason.Removed )
                    {
                        throw new Exception(
                            string.Format( "The IISCallBack cache object was removed without expiring.  Removed Reason: {0}",
                                r.ConvertToString() ) );
                    }
                }
            }
            catch ( Exception ex )
            {
                LogError( ex, null );
            }
        }