Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim Mather 38 posts 142 karma points
    Jun 02, 2020 @ 21:53
    Tim Mather
    0

    Umbraco 8 Events

    Hi, using your latest preview release. I can't get the ImportProvider.RecordImporting event to fire? I know this is a preview release so just checking if that is a known problem or even something you intend to implement.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jun 03, 2020 @ 05:33
    Richard Soeteman
    0

    Hi Tim,

    Will check later this week if this works in the Final version.

    Thanks,

    Richard

  • Tim Mather 38 posts 142 karma points
    Jun 03, 2020 @ 06:21
    Tim Mather
    0

    Don't suppose the source code is available anywhere see if we can fix it, appreciate might not be commercially viable but we are trying to resolve today.

    Thanks

    Tim

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jun 05, 2020 @ 12:49
    Richard Soeteman
    100

    Hi Tim,

    Events were added in a later version. And registering those is a bit differnt than previous version.

    In sample below we log every action through events. The class that handles the events need to derive from IComponent and you need to wire up the events in the initialize method

       public class ContentImportLogEvents :IComponent
    {
        private ILogger _logger;
        public ContentImportLogEvents(ILogger logger)
        {
            _logger = logger;
        }
    
        public void Initialize()
        {
            ContentImportProvider.BulkImporting += ContentImportProvider_BulkImporting;
            ContentImportProvider.BulkImported += ContentImportProvider_BulkImported;
            ContentImportProvider.Importing += ContentImportProvider_Importing;
            ContentImportProvider.Imported += ContentImportProvider_Imported;
            ContentImportProvider.RecordImporting += ContentImportProvider_RecordImporting;
            ContentImportProvider.RecordImported += ContentImportProvider_RecordImported;
        }
    
        private void ContentImportProvider_RecordImported(object sender, Extensions.Providers.ImportProviders.EventArgs.RecordImportedEventArgs e)
        {
            _logger.Info(this.GetType(), "RecordImported {primaryKey}", e.PrimaryKeyValue);
        }
    
        private void ContentImportProvider_RecordImporting(object sender, Extensions.Providers.ImportProviders.EventArgs.RecordImportingEventArgs e)
        {
            _logger.Info(this.GetType(),"RecordImporting {primaryKey}", e.PrimaryKeyValue);
        }
    
        private void ContentImportProvider_Imported(Extensions.Providers.ImportProviders.EventArgs.ImportEventArgs e)
        {
            _logger.Info(this.GetType(), "Imported {stateId}", e.State.StateId);
        }
    
        private void ContentImportProvider_Importing(Extensions.Providers.ImportProviders.EventArgs.ImportEventArgs e)
        {
            _logger.Info(this.GetType(), "Importing {stateId}", e.State.StateId);
        }
    
        private void ContentImportProvider_BulkImported(Extensions.Providers.ImportProviders.EventArgs.BulkImportEventArgs e)
        {
            _logger.Info(this.GetType(), "BulkImported {stateId}", e.State.StateId);
        }
    
        private void ContentImportProvider_BulkImporting(Extensions.Providers.ImportProviders.EventArgs.BulkImportEventArgs e)
        {
            _logger.Info(this.GetType(),"BulkImporting {stateId}",e.State.StateId);
        }
    
        public void Terminate()
        {
    
        }
    }
    

    Then you need to register this class in a composer

     [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
    [ComposeAfter(typeof(CMSImportComposer))]
    public class CMSImportTestProviderComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
    
            composition.Components().Append<ContentImportLogEvents>();
        }
    }
    

    Then it should be picked up in the final version of CMSImport.

    Best,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft