Пример #1
0
        public override void DoWork()
        {
            try
            {
                Controller c = new Controller();
                ArrayList arr = c.GetBroadcasts( Globals.ServerName );
                int i;
                for( i = 0; i <= arr.Count - 1; i++ )
                {
                    BroadcastInfo objBroadcastInfo;
                    objBroadcastInfo = (BroadcastInfo)arr[i];
                    switch( objBroadcastInfo.BroadcastType )
                    {
                        case "RemoveCachedItem":

                            CachingProvider.Instance().Remove( objBroadcastInfo.BroadcastMessage );
                            break;
                    }
                    this.ScheduleHistoryItem.AddLogNote( "Broadcast Type: " + objBroadcastInfo.BroadcastType + ", Broadcast Message: " + objBroadcastInfo.BroadcastMessage + '\r' );
                }
                this.ScheduleHistoryItem.Succeeded = true; //REQUIRED
            }
            catch( Exception exc ) //REQUIRED
            {
                this.ScheduleHistoryItem.Succeeded = false; //REQUIRED

                this.ScheduleHistoryItem.AddLogNote( string.Format( "An error ocurred polling for server broadcasts.", exc.ToString() ) ); //OPTIONAL

                //notification that we have errored
                this.Errored( ref exc ); //REQUIRED

                //log the exception
                Exceptions.Exceptions.LogException( exc ); //OPTIONAL
            }
        }
        public override object GetPersistentCacheItem( string CacheKey, Type objType )
        {
            object obj = objCache[CacheKey];
            if( obj != null )
            {
                return obj;
            }
            else if( DataCache.CachePersistenceEnabled )
            {
                Controller c = new Controller();

                obj = c.GetCachedObject( CacheKey, objType );
                if( obj != null )
                {
                    Insert( CacheKey, obj, true );
                }
            }
            return obj;
        }
        public override void Insert( string CacheKey, object objObject, bool PersistAppRestart )
        {
            if( PersistAppRestart )
            {
                //remove the cache key which
                //will remove the serialized
                //file before creating a new one
                Remove( CacheKey );
            }
            Controller c = new Controller();
            if( PersistAppRestart && DataCache.CachePersistenceEnabled )
            {
                c.AddCachedObject( CacheKey, objObject, Globals.ServerName );
                c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
            }
            else if( Globals.WebFarmEnabled )
            {
                c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
            }

            objCache.Insert( CacheKey, objObject );
        }
 public override void RemovePersistentCacheItem( string CacheKey )
 {
     if( objCache[CacheKey] != null )
     {
         objCache.Remove( CacheKey );
         if( DataCache.CachePersistenceEnabled == true )
         {
             Controller c = new Controller();
             c.DeleteCachedObject( CacheKey );
             c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
         }
     }
 }
 public override void Remove( string CacheKey )
 {
     if( objCache[CacheKey] != null )
     {
         Controller c = new Controller();
         objCache.Remove( CacheKey );
         if( Globals.WebFarmEnabled )
         {
             c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
         }
     }
 }
        public override void Insert( string CacheKey, object objObject, CacheDependency objDependency, DateTime AbsoluteExpiration, TimeSpan SlidingExpiration, CacheItemPriority Priority, CacheItemRemovedCallback OnRemoveCallback, bool PersistAppRestart )
        {
            if( PersistAppRestart )
            {
                //remove the cache key which
                //will remove the serialized
                //file before creating a new one
                Remove( CacheKey );
            }

            Controller c = new Controller();
            if( PersistAppRestart && DataCache.CachePersistenceEnabled )
            {
                c.AddCachedObject( CacheKey, objObject, Globals.ServerName );
                c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
            }
            else if( Globals.WebFarmEnabled )
            {
                c.AddBroadcast( "RemoveCachedItem", CacheKey, Globals.ServerName );
            }

            objCache.Insert( CacheKey, objObject, objDependency, AbsoluteExpiration, SlidingExpiration, Priority, OnRemoveCallback );
        }