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 回答