如何从 PublishEndRemoteEventArgs 获取发布选项? C#,网站核心
How to get the publishing options from PublishEndRemoteEventArgs? C#, Sitecore
我正在添加一个 publish:end 方法,以便在发布特定类型的项目时发布特定的相关项目。我有 OnPublishEnd 和 OnPublishEndRemote 方法,但我需要确保发布到与刚刚发布的项目相同的发布目标。我已经在 OnPublishEnd 事件中拥有发布者,但我不确定如何在远程事件中获取它:
public void OnPublishEnd(object sender, EventArgs args)
{
var sitecoreArgs = args as Sitecore.Events.SitecoreEventArgs;
if (sitecoreArgs == null)
{
return;
}
var publisher = sitecoreArgs.Parameters[0] as Publisher;
if (publisher == null)
{
return;
}
var rootItem = publisher.Options.RootItem;
if (rootItem.TemplateID == IEventConstants.TemplateId)
{
PublishEventParent(rootItem, publisher);
}
}
public void OnPublishEndRemote(object sender, EventArgs args)
{
var args2 = args as PublishEndRemoteEventArgs;
if (args2 == null)
{
return;
}
Item rootItem = Factory.GetDatabase("web").GetItem(new ID(args2.RootItemId));
if (rootItem.TemplateID == IEventConstants.TemplateId)
{
PublishEventParent(rootItem, ???publisher???);
}
}
public void PublishEventParent(Item item, Publisher publisher)
{
var adHocPage =
item.Axes.GetAncestors().FirstOrDefault(x => x.TemplateID == IAd_Hoc_PageConstants.TemplateId);
if (adHocPage != null)
{
publisher.Publish();
}
}
如何在远程事件中获取 publisher/publishing options/publishing 目标?
下面是您在 PublishEndRemoteEventArgs
class.
中拥有的完整属性列表
发布结束远程事件通常在 CD 服务器上触发。而且它们不应该与 master
数据库有任何连接,因此应该不可能在那里进行任何其他发布。
public bool CompareRevisions { get; protected set; }
public bool Deep { get; protected set; }
public DateTime FromDate { get; protected set; }
public string LanguageName { get; protected set; }
public PublishMode Mode { get; protected set; }
public DateTime PublishDate { get; protected set; }
public List<string> PublishingTargets { get; protected set; }
public bool RepublishAll { get; protected set; }
public Guid RootItemId { get; protected set; }
public string SourceDatabaseName { get; protected set; }
public string TargetDatabaseName { get; protected set; }
我正在添加一个 publish:end 方法,以便在发布特定类型的项目时发布特定的相关项目。我有 OnPublishEnd 和 OnPublishEndRemote 方法,但我需要确保发布到与刚刚发布的项目相同的发布目标。我已经在 OnPublishEnd 事件中拥有发布者,但我不确定如何在远程事件中获取它:
public void OnPublishEnd(object sender, EventArgs args)
{
var sitecoreArgs = args as Sitecore.Events.SitecoreEventArgs;
if (sitecoreArgs == null)
{
return;
}
var publisher = sitecoreArgs.Parameters[0] as Publisher;
if (publisher == null)
{
return;
}
var rootItem = publisher.Options.RootItem;
if (rootItem.TemplateID == IEventConstants.TemplateId)
{
PublishEventParent(rootItem, publisher);
}
}
public void OnPublishEndRemote(object sender, EventArgs args)
{
var args2 = args as PublishEndRemoteEventArgs;
if (args2 == null)
{
return;
}
Item rootItem = Factory.GetDatabase("web").GetItem(new ID(args2.RootItemId));
if (rootItem.TemplateID == IEventConstants.TemplateId)
{
PublishEventParent(rootItem, ???publisher???);
}
}
public void PublishEventParent(Item item, Publisher publisher)
{
var adHocPage =
item.Axes.GetAncestors().FirstOrDefault(x => x.TemplateID == IAd_Hoc_PageConstants.TemplateId);
if (adHocPage != null)
{
publisher.Publish();
}
}
如何在远程事件中获取 publisher/publishing options/publishing 目标?
下面是您在 PublishEndRemoteEventArgs
class.
发布结束远程事件通常在 CD 服务器上触发。而且它们不应该与 master
数据库有任何连接,因此应该不可能在那里进行任何其他发布。
public bool CompareRevisions { get; protected set; }
public bool Deep { get; protected set; }
public DateTime FromDate { get; protected set; }
public string LanguageName { get; protected set; }
public PublishMode Mode { get; protected set; }
public DateTime PublishDate { get; protected set; }
public List<string> PublishingTargets { get; protected set; }
public bool RepublishAll { get; protected set; }
public Guid RootItemId { get; protected set; }
public string SourceDatabaseName { get; protected set; }
public string TargetDatabaseName { get; protected set; }