Search code examples
episerver

Alternative to unifiedFile in EPIServer 10


Is there anyone expert in EPIServer. I need help to migrate code from Version 6 to 10. I have this code in my file and it gives error after i migrated to Version 10.

  public void Initialize(InitializationEngine context)
    {
        UnifiedFile.UnifiedFileCheckedIn += UnifiedFile_UnifiedFileCheckedIn;
    }

It gives error on UnifiedFile.The name unifiedfile does not exist in current context. Like this many errors related to it. What is alternative for this?


Solution

  • The media system was changed in EPiServer 7.5. You have to migrate your data and rewrite code for it to work in EPiServer 10.

    http://world.episerver.com/documentation/upgrading/Episerver-CMS/75/Migrating-VPP-based-files-to-the-new-media-system/

    http://world.episerver.com/documentation/developer-guides/CMS/Content/assets-and-media2/

    There is no direct equivalent of checking in files but there are a number of events that you could subscribe to to run your code. You can get an instance of IContentEvents in your Initialize method and add an event handler for the SavedContent event like this:

    public void Initialize(InitializationEngine context)
    {
       context.Locate.Advanced.GetInstance<IContentEvents>().SavedContent =+    DoStuffWithSavedContent;
    }
    
        private void DoStuffWithSavedContent(object sender, ContentEventArgs e)
        {
         // Do stuff here...
        } 
    

    A description of all the events available is here:

    http://world.episerver.com/documentation/class-library/?documentId=cms/7/306eae4b-2ba2-dd1e-c114-bccb0d3d2968

    Here are more examples of working with media:

    http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Assets-and-media/Working-with-media/