简体   繁体   中英

Ektron CMS - new extension for OnAfterAdd not working

I followed the direction here for adding a new extension so that I can trigger an event whenever a new image is uploaded to Ektron. I created this new file in the App_Code folder of my project:

using System;
using System.Collections.Generic;
using System.Text;
using Ektron.Cms;
using Ektron.Cms.Common;
using Ektron.Cms.Extensibility;
using Ektron.Cms.Extensibility.Content;

namespace Cms.Extensions.Samples
{
    public class UploadExtension : LibraryStrategy
    {
        public override void OnAfterAdd(LibraryData taxonomyData, CmsEventArgs eventArgs)
        {
            string[] lines = { "Written on Ektron upload event!" };
            System.IO.File.WriteAllLines(@"C:\Users\Public\TestFolder\WORKING.txt", lines);

            var x = taxonomyData;
        }

        public override void OnAfterUpdate(LibraryData taxonomyData, CmsEventArgs eventArgs)
        {
            var x = taxonomyData;
        }

        public override void OnBeforeDelete(long id, CmsEventArgs eventArgs)
        {
            var x = id;
        }
    }
}

I just put in one test line for each method so that I could add a breakpoint to see if it's getting hit. I registered the new extension in objectfactory:

<objectFactory>
    <objectStrategies>
        <add name="Library">
          <strategies>
            <add name="EktronUploadExtension" type="Cms.Extensions.Samples.UploadExtension"/>
            <add name="GoogleGeoCoder" type="Cms.Extensions.GoogleGeoCoder.LibraryStrategy, Cms.Extensions.GoogleGeoCoder"/>
          </strategies>
        </add>
    </objectStrategies>
</objectFactory>

It looks like I set everything up correctly, but I attached to process and opened up my Ektron work area and uploaded a new image to the library, but none of my breakpoints (specifically the breakpoint in OnAfterAdd) got hit. I'm not sure how to debug or figure out what's wrong with my extension.

EDIT: I fixed the objectfactory.config file, but it's still not working. The breakpoints in UploadExtension.cs aren't working, and the test file that I put in the function isn't getting written when I add new library item in Ektron.

Your objectfactory.config file is incorrect. You have created a LibraryStrategy but placed it into the Content Strategy section of the objectfactory.config.

You should add a section called "Library" to the config file like so:

<add name="Library">
  <strategies>
    <add name="MyFirstExample" 
              type="Cms.Extensions.Samples.UploadExtension"/>
  </strategies>
</add>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM