我正在尝试使用以下代码使用 coreservice 创建组件,当我执行 exe 时,出现错误“无法找到 uuid:”“64c7e56a-161d-4698-a76b-7fd96227948d:Content”。
我已经打开了链接到这个组件的架构,我也在那里看到了这个 UUID。
截至目前,我只是试图通过提供硬线的文件夹、架构、标题来创建一个组件。
如果您能指导我如何在组件中添加字段值,那就太好了。(例如,假设我的架构中有一个“文本”字段链接到该组件,并且我想使用相同的程序在我的组件的该字段中添加“这是文本”。
你能帮我解决这个问题吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DctmToSDLMigration.SDLCoreServiceReference;
namespace DctmToSDLMigration
{
class Program
{
static DctmToSDLMigration.SDLCoreServiceReference.SessionAwareCoreService2010Client client = new SessionAwareCoreService2010Client();
static ReadOptions readoptions = new ReadOptions();
static void CreateComponent()
{
try
{
string TargetFolderTcmId = "tcm:148-1263-2";
string LinkSchemaTcmId = "tcm:148-11460-8";
ComponentData CurrentMigrationComponent = client.GetDefaultData(ItemType.Component, TargetFolderTcmId) as ComponentData;
LinkToSchemaData SchemaToUse = new LinkToSchemaData();
SchemaToUse.IdRef = LinkSchemaTcmId.ToString();
CurrentMigrationComponent.Schema = SchemaToUse ;
CurrentMigrationComponent.Title = "Test component";
client.Create(CurrentMigrationComponent, readoptions);
Console.WriteLine(CurrentMigrationComponent.Id);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
static void Main(string[] args)
{
CreateComponent();
}
}
}