イベントにサブスクライブされたイベントハンドラーを持つTcmExtension
名前を作成しました。このイベントの目的は、関連するワークフローサブジェクトのすべての依存関係(つまりページ)を公開するようにスケジュールすることです。WorkflowEventSystem
FinishProcess
私が抱えている問題は、イベントが適切なタイミングでトリガーされ(ワークフロープロセスが完了した)、公開がスケジュールされているはずのすべてのアイテムがトリガーされても、PublishScheduler
イベントによって作成されたオブジェクトが消えないように見えることです。スコープであるため、WorkflowEventSystemオブジェクトもそうではありません。
これらのオブジェクトが永遠に存続する原因となるイベントシステムの動作について、私が見逃しているものはありますか?私が関連するコードと考えるものを以下に含めました(いくつかの部分を要約しました)。助けてくれてありがとう。
実際のTcmExtensionのほとんどは次のとおりです。
public class WorkflowEventSystem : TcmExtension
{
public WorkflowEventSystem()
{
this.Subscribe();
}
public void Subscribe()
{
EventSystem.Subscribe<ProcessInstance, FinishProcessEventArgs>(ScheduleForPublish, EventPhases.All);
}
}
ScheduleForPublish
PublishScheduler
オブジェクト(私が作成したクラス)を作成します:
private void ScheduleForPublish(ProcessInstance process, FinishProcessEventArgs e, EventPhases phase)
{
if(phase == EventPhases.TransactionCommitted)
{
PublishScheduler publishScheduler = new PublishScheduler(process);
publishScheduler.ScheduleForPublish(process);
publishScheduler = null; // worth a try
}
}
メソッドは次のScheduleForPublish
ようになります。
public void ScheduleForPublish(ProcessInstance process)
{
using(Session session = new Session("ImpersonationUser"))
{
var publishInstruction = new PublishInstruction(session);
// Set up some publish Instructions
var publicationTargets = new List<PublicationTarget>();
// Add a PublicationTarget here by tcm id
IList<VersionedItem> itemsToPublish = new List<VersionedItem>();
// Add the items we want to publish by calling GetUsingItems(filter)
// on the workflow process' subject
//Publish the items
PublishEngine.Publish(itemsToPublish.Cast<IdentifiableObject>(), publishInstruction, publishTargets);
}
}