2

Вопрос по – Обновление компонентов с использованием основной службы в SDL Tridion 2011

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

string COMPONENT_URI = "tcm:8-674";
string SCHEMA_URI = "tcm:8-426-8";

ComponentData component = client.TryCheckOut(COMPONENT_URI, null) as ComponentData;

try
{
    Response.Write("<BR>" + component.Content);
    XDocument xdoc = XDocument.Parse(component.Content);
    var element = xdoc.Elements("first").Single();
    element.Value = "updated";
    xdoc.Save(component.Content);
    client.Save(component, null);
    Response.Write("<BR"+"SAVED");
}
catch (Exception ex)
{
    Response.Write("Unable to save comp" + ex.Message);
}

client.CheckIn(COMPONENT_URI, null);

Error: User Rate Limit Exceeded

 Unable to save compSequence contains no elements 

Error: User Rate Limit Exceeded

firstError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

3ответа

12

Error: User Rate Limit Exceeded

<Content xmlns="uuid:2607D20D-1B22-4994-98C1-66D9ACF85C20">
  <first>The value of my first field</first>
  <second>The value of my second field</second>
</Content>

Error: User Rate Limit Exceeded

var element = xdoc.Elements("first").Single();

Error: User Rate Limit Exceeded

  1. not providing a namespace to the selection
  2. only selecting direct children of the document root

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

XNamespace ns = xdoc.Root.GetDefaultNamespace();
var element = xdoc.Descendants(ns+"first").Single();

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededXDocument.SaveError: User Rate Limit Exceeded

2

Error: User Rate Limit Exceeded

    public static void updateComponent()
    {
        string componentWdUrl = "/webdav/020%20Content/Building%20Blocks/Content/wstest/testComponent.xml";
        CoreServicesUtil coreServicesUtil = new CoreServicesUtil();
        coreServicesUtil.coreServiceClient.CheckOut(componentWdUrl, true, coreServicesUtil.readOptions);
        ComponentData componentData = coreServicesUtil.getComponentData(componentWdUrl);
        SchemaData schemaData = coreServicesUtil.getSchemaData(componentData.Schema.IdRef);
        componentData.Content = xmlUtil.GetNewXmlNode("Content", schemaData.NamespaceUri);
        componentData.Metadata = xmlUtil.GetNewXmlNode("Metadata", schemaData.NamespaceUri);
        componentData.AddSingleField("singlefield", "singlefield sample", schemaData.NamespaceUri);
        componentData = (ComponentData)coreServicesUtil.coreServiceClient.Save(componentData, coreServicesUtil.readOptions);
        coreServicesUtil.coreServiceClient.CheckIn(componentData.Id, coreServicesUtil.readOptions);
        coreServicesUtil.coreServiceClient.Close();
    }

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

3

Error: User Rate Limit Exceeded

XDocument.Save(string fileName)Error: User Rate Limit ExceededXDocumentError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

using (var client = new SessionAwareCoreServiceClient(netTcpBinding, remoteAddress))
{
    ReadOptions readOptions = new ReadOptions();
    ComponentData component = client.Read(compTcmUri, readOptions) as ComponentData;
    XDocument dom = XDocument.Parse(component.Content);
    // do your modifications to dom
    component.Content = dom.ToString();
    component = client.Update(component, readOptions) as ComponentData;

    Console.WriteLine("Component updated: " + component.LocationInfo.WebDavUrl);
}

RelatedQuestions