2017-10-19 64 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事件處理程序時觸發的事件少一個。 –