Example #1
0
 private static void IDynamicContentCreatedEvent(IDynamicContentCreatedEvent eventInfo)
 {
     if (eventInfo.Item.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
     {
         if (eventInfo.Item.GetType() == HogwartsConstants.activityType)
         {
             // A new activity was created. Purge the cache for whichever house it belongs to
             CacheDependency.Notify(new List <CacheDependencyKey>()
             {
                 new CacheDependencyKey()
                 {
                     Key = eventInfo.Item.SystemParentId.ToString(), Type = HogwartsConstants.houseType
                 }
             });
         }
         else if (eventInfo.Item.GetType() == HogwartsConstants.houseType)
         {
             // House has been created. Purge the HouseKeys cache so the new house appears in the list
             // ... Yes. I know that Hogwarts will only ever have 4 houses...
             CacheDependency.Notify(new List <CacheDependencyKey>()
             {
                 new CacheDependencyKey()
                 {
                     Key = HogwartsConstants.cacheKeysInstanceName, Type = HogwartsConstants.houseType
                 }
             });
         }
     }
 }
Example #2
0
 private static void IDynamicContentUpdatedEvent(IDynamicContentUpdatedEvent eventInfo)
 {
     if (eventInfo.Item.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
     {
         if (eventInfo.Item.GetType() == HogwartsConstants.activityType)
         {
             // An activity was modified. Purge the cache for whichever house it belongs to
             CacheDependency.Notify(new List <CacheDependencyKey>()
             {
                 new CacheDependencyKey()
                 {
                     Key = eventInfo.Item.SystemParentId.ToString(), Type = HogwartsConstants.houseType
                 }
             });
         }
         else if (eventInfo.Item.GetType() == HogwartsConstants.houseType)
         {
             // House has been edited. Purge it's cache (so new title or logo loads in)
             CacheDependency.Notify(new List <CacheDependencyKey>()
             {
                 new CacheDependencyKey()
                 {
                     Key = eventInfo.Item.Id.ToString(), Type = HogwartsConstants.houseType
                 }
             });
         }
     }
 }
Example #3
0
        private static void IDynamicContentDeletingEvent(IDynamicContentDeletingEvent eventInfo)
        {
            // Notice we are using IDynamicContentDeletingEvent instead of IDynamicContentDeletedEvent
            // The only difference is that Deleting occurs before the transation is submitted to the database. But, it does occur after permission checks. The only reason this would fail
            // would be due to do a bug or database connection. We have to do this because IDynamicContentDeletedEvent occurs AFTER it has been deleted from the database. And Sitefinity
            // doesn't have access to the SystemParentId at that point.

            if (eventInfo.Item.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
            {
                if (eventInfo.Item.GetType() == HogwartsConstants.activityType)
                {
                    // An activity was deleted. Purge the cache for whichever house it belongs to
                    CacheDependency.Notify(new List <CacheDependencyKey>()
                    {
                        new CacheDependencyKey()
                        {
                            Key = eventInfo.Item.SystemParentId.ToString(), Type = HogwartsConstants.houseType
                        }
                    });
                }
                else if (eventInfo.Item.GetType() == HogwartsConstants.houseType)
                {
                    // House has been deleted. Purge the HouseKeys cache so the house disappears from the list
                    // ... Yes. I know that Hogwarts will only ever have 4 houses...
                    CacheDependency.Notify(new List <CacheDependencyKey>()
                    {
                        new CacheDependencyKey()
                        {
                            Key = HogwartsConstants.cacheKeysInstanceName, Type = HogwartsConstants.houseType
                        }
                    });
                }
            }
        }