0

コアサービスを使用してワークフローアクティビティを公開および終了するメソッドを作成しようとしています。コンパイルエラーが発生しています。以下は私のコードです。誰かが私を訂正できますか?その緊急。

public void PublishComponent(string WorkItemId)
    {
        var client = new SessionAwareCoreServiceClient();
        var readoptions = new ReadOptions();            
        ComponentData component = (ComponentData)client.Read(new TcmUri(WorkItemId), readoptions) as ComponentData;
        List<IdentifiableObjectData> ItemToPublish = new List<IdentifiableObjectData>();            
        ItemToPublish.Add(component);
        PublishInstructionData instruction = new PublishInstructionData();
        PublicationTargetData pubtarget = (PublicationTargetData)client.Read(new TcmUri("tcm: 0 - 21 - 65537"), readoptions) as PublicationTargetData;
        List<PublicationTargetData> target = new List<PublicationTargetData>();
        target.Add(pubtarget);            
        client.Publish(ItemToPublish, instruction, target, PublishPriority.Normal, readoptions);


        WorkItemData workitem = new WorkItemData();
        workitem.Id = new TcmUri(WorkItemId);            
        ActivityInstanceData currentactivity = new ActivityInstanceData();
        ActivityFinishData finish = new ActivityFinishData();
        finish.Message="Published";
        client.FinishActivity(currentactivity, finish, readoptions);
}
4

1 に答える 1

5

いくつか問題がありましたが、主TcmUriに TOM.NET のようにクラスがなく、CoreService では文字列です。メソッドについてPublishも同様に、TOM.NET のようにアイテム配列ではなく、文字列配列を入力として受け取ります。

        var client = new SessionAwareCoreServiceClient();
        var readoptions = new ReadOptions();
        ComponentData component = (ComponentData)client.Read(WorkItemId, readoptions);
        List<string> ItemToPublish = new List<string>();
        ItemToPublish.Add(component.Id);
        PublishInstructionData instruction = new PublishInstructionData();
        PublicationTargetData pubtarget = (PublicationTargetData)client.Read("tcm:0-21-65537", readoptions);
        List<string> target = new List<string>();
        target.Add(pubtarget.Id);
        client.Publish(ItemToPublish.ToArray(), instruction, target.ToArray(), PublishPriority.Normal, readoptions);


        WorkItemData workitem = new WorkItemData();
        workitem.Id = WorkItemId;
        ActivityInstanceData currentactivity = new ActivityInstanceData();
        ActivityFinishData finish = new ActivityFinishData();
        finish.Message = "Published";
        client.FinishActivity(currentactivity.Id, finish, readoptions);
于 2012-07-09T08:47:00.067 に答える