Kentico - 从登台数据任务中排除特定的自定义表

时间:2017-10-19 04:18:12

标签: kentico

我正在为我的Kentico 10网站添加一个新的自定义表格。我希望任何自定义表结构更改同步,但我不希望数据在我的不同环境之间同步。

我确实有其他自定义表,但我想继续记录暂存任务。

如何排除特定的自定义表格?我可以看到样品: https://docs.kentico.com/k10/custom-development/handling-global-events/excluding-content-from-staging-and-integration

但我不知道我可以在synchronizedObject上使用哪些属性来验证它是否与自定义表相关。

我到目前为止找到的所有样本都是针对用户/角色的,这些用户/角色是开箱即用的对象类型。

2 个答案:

答案 0 :(得分:2)

为相关自定义表的日志更改事件创建全局处理程序。使用这样的东西:

using CMS;
using CMS.DataEngine;

// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomHandlerModule))]

public class CustomHandlerModule : Module
{
    // Module class constructor, the system registers the module under the name "LogChangeHandlers"
    public CustomHandlerModule()
        : base("CustomHandlerModule") { }

    // Contains initialization code that is executed when the application starts
    protected override void OnInit()
    {
        base.OnInit();
        ObjectEvents.LogChange.Before += LogChange_Before;
    }

    private void LogChange_Before(object sender, LogObjectChangeEventArgs e)
    {
        // check the type info for your specific custom table type/item.  
        // Could use a switch statement here too if you have multiple
        // make sure to update "namespace" and "classname" with your custom data.  
        // Do not modify the "customtableitem" string, that is needed.
        if (e.Settings.InfoObj.TypeInfo.ObjectType.ToLower() == "customtableitem.namespace.classname")
        {
            e.Settings.LogStaging = false;
        }
    }
}

答案 1 :(得分:1)

相关问题