use*_*019 2 tridion tridion-2011
我正在尝试使用以下代码使用coreservice创建组件,当我执行exe时,我收到错误"无法找到uuid:""64c7e56a-161d-4698-a76b-7fd96227948d:Content".
我已经打开了链接到这个组件的模式,我也在那里看到了这个UUID.
截至目前我只是试图通过提供文件夹,架构,标题作为硬路径来创建组件.
如果你可以指导我如何在组件中添加字段值,那将是很好的.(例如,假设我的架构中有一个字段"Text",它链接到此组件,我想使用相同的程序在我的组件的这个字段中添加"This is the Text".
你可以帮我解决这个问题吗?
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
您需要设置组件的内容属性.
XmlDocument doc = new XmlDocument();
doc.LoadXml(string.Format(@"<Content xmlns='{0}'><Test>Hello</Test></Content>", SchemaToUse.NamespaceUri));
CurrentMigrationComponent.Content = doc.DocumentElement;
Run Code Online (Sandbox Code Playgroud)
XmlDocument doc = new XmlDocument();
doc.LoadXml(string.Format(@"<Content xmlns='{0}'><Test>Hello</Test></Content>", SchemaToUse.NamespaceUri));
CurrentMigrationComponent.Content = doc.DocumentElement;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |