2017-10-19 63 views
0

我正在向我的Kentico 10网站添加新的自定义表格。我想要任何自定义表格结构变化同步,但我不希望数据在我的不同环境之间同步。Kentico - 从暂存数据任务中排除特定的自定义表格

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

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

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

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

回答

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; 
     } 
    } 
} 
+0

谢谢正是我需要的。我注意到我们目前有一个StagingEvents.LogTask.Before的全局处理程序 - 你知道这与LogChange有什么不同吗? – Jen

+1

LogChange事件在对象任务被记录时触发。您可以禁用任务日志记录,集成等。当Staging记录任务时,StagingEvents事件在源服务器上触发。所以说,LogChange事件在StagingEvents触发之前触发,意味着如果执行检查LogChange事件处理程序时触发的事件少一个。 –