/// <summary> /// /// </summary> /// <param name="folderID"></param> /// <param name="recursive"></param> /// <param name="srcSchemaID"></param> /// <param name="destSchemaID"></param> public static string UpdateSchemaForComponent(string folderID, bool recursive, string srcSchemaID, string destSchemaID, bool isMultiMediaComp) { cs_client = CoreServiceProvider.CreateCoreService(); StringBuilder sb = new StringBuilder(); FolderData folder = cs_client.Read(folderID, null) as FolderData; SchemaData schema = cs_client.Read(destSchemaID, null) as SchemaData; XNamespace ns = schema.NamespaceUri; XElement items = cs_client.GetListXml(folder.Id, SetComponenetFilterCriterias(isMultiMediaComp)); List <ComponentData> failedItems = new List <ComponentData>(); foreach (XElement item in items.Elements()) { ComponentData component = cs_client.Read(item.Attribute("ID").Value, null) as ComponentData; if (!component.Schema.IdRef.Equals(srcSchemaID)) { // If the component is not of the schmea that we want to change from, do nothing... return(""); } if (component.Schema.IdRef.Equals(schema.Id)) { // If the component already has this schema, don't do anything. return(""); } component = cs_client.TryCheckOut(component.Id, new ReadOptions()) as ComponentData; if (component.IsEditable.Value) { component.Schema.IdRef = destSchemaID; component.Metadata = new XElement(ns + "Metadata").ToString(); cs_client.Save(component, null); cs_client.CheckIn(component.Id, null); } else { sb.AppendLine("Schema Can not be updated for: " + component.Id); sb.AppendLine(""); } } return(sb.ToString()); }