简体   繁体   English

Ektron CMS-OnAfterAdd的新扩展不起作用

[英]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. 我按照此处的指示添加新扩展名,以便每当将新图像上传到Ektron时都可以触发事件。 I created this new file in the App_Code folder of my project: 我在项目的App_Code文件夹中创建了这个新文件:

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中注册了新扩展名:

<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. 看起来我正确设置了所有内容,但是我依附于流程并打开了Ektron工作区,并将新图像上传到了库中,但是没有遇到任何断点(特别是OnAfterAdd中的断点)。 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. 编辑:我修复了objectfactory.config文件,但仍无法正常工作。 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. 当我在Ektron中添加新的库项目时,UploadExtension.cs中的断点不起作用,并且写入到函数中的测试文件也未写入。

Your objectfactory.config file is incorrect. 您的objectfactory.config文件不正确。 You have created a LibraryStrategy but placed it into the Content Strategy section of the objectfactory.config. 您已经创建了LibraryStrategy,但是将其放置在objectfactory.config的Content Strategy部分中。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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