为有问题的自定义表的日志更改事件创建全局处理程序。使用这样的事情:
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事件处理程序时触发的事件少一个。 –