爲有問題的自定義表的日誌更改事件創建全局處理程序。使用這樣的事情:
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;
}
}
}
謝謝正是我需要的。我注意到我們目前有一個StagingEvents.LogTask.Before的全局處理程序 - 你知道這與LogChange有什麼不同嗎? – Jen
LogChange事件在對象任務被記錄時觸發。您可以禁用任務日誌記錄,集成等。當Staging記錄任務時,StagingEvents事件在源服務器上觸發。所以說,LogChange事件在StagingEvents觸發之前觸發,意味着如果執行檢查LogChange事件處理程序時觸發的事件少一個。 –