private static string GetAllPublications() { List <string> pubs = new List <string>(); using (CoreServiceClient client = new CoreServiceClient(endpointName)) { var credentials = CredentialCache.DefaultNetworkCredentials; if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password)) { credentials = new NetworkCredential(userName, password); } client.ChannelFactory.Credentials.Windows.ClientCredential = credentials; PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = client.GetSystemWideListXml(filter); XNamespace ns = publications.GetNamespaceOfPrefix("tcm"); foreach (XElement item in publications.DescendantNodes()) { pubs.Add(item.Attribute("ID").Value); } } string allPubs = string.Join(", ", Array.ConvertAll(pubs.ToArray(), i => i.ToString())); return(allPubs); }
public static bool bluePrintInfo(CoreServiceClient client) { client.ClientCredentials.Windows.ClientCredential.Domain = ConfigurationSettings.AppSettings["Domain"]; client.ClientCredentials.Windows.ClientCredential.UserName = ConfigurationSettings.AppSettings["User"]; client.ClientCredentials.Windows.ClientCredential.Password = ConfigurationSettings.AppSettings["PWD"]; UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData { ItemTypes = new[] { ItemType.PublicationTarget, ItemType.Publication, ItemType.Component, ItemType.Page, ItemType.Keyword } , IncludeLocalCopies = true, BaseColumns = ListBaseColumns.Extended, }; PublicationsFilterData filter = new PublicationsFilterData { BaseColumns = ListBaseColumns.IdAndTitle }; XElement publications = client.GetSystemWideListXml(filter); XElement elist = client.GetListXml("tcm:3-1973", usingItemsFilterData); List <Result> lstRS = new List <Result>(); IEnumerable <XElement> usingXML1 = (from el in elist.Elements() //where (string)el.Attribute("IsPublished").Value == "true" select el); return(true); }
public IEnumerable <Publication> LoadPublications(string topoEnvId) { var topo = _topologyManagerService.Get(topoEnvId); var uri = new Uri(topo.CoreServiceEndpoint.Url); var client = Wrapper.GetCoreServiceWsHttpInstance(uri.Host, _userName, _password, _domain, CoreServiceInstance.SdlWeb8); //var client = this.GetCoreServiceWsHttpInstance(topo.CoreServiceEndpoint.Url, CoreServiceInstance.SdlWeb8); PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = client.GetSystemWideListXml(filter); var list = new List <Publication>(); foreach (XElement item in publications.DescendantNodes()) { var id = item.Attribute("ID").Value; var publication = client.Read(id, new ReadOptions()) as PublicationData; //var publication = id.ToTcmUri().GetItem<PublicationData>(); var pub = new Publication() { Id = publication.Id.ToString(), Title = publication.Title, RelativeUrl = publication.PublicationUrl }; list.Add(pub); } return(list); }
public static IList <PublicationData> LoadAllPublications() { Logger.Debug("Loading PublicationData"); string filename = "PublicationData.txt"; var publications = FileCache.LoadFromFile <IList <PublicationData> >(filename); if (publications == null) { var filter = new PublicationsFilterData { BaseColumns = ListBaseColumns.Extended }; publications = TridionCoreServiceFactory.GetSystemWideList <PublicationData>(filter); FileCache.SaveToFile(filename, publications); } else { Logger.Debug("Loading publications from cache"); } Logger.Debug("Found {0} PublicationData", publications.Count); return(publications); }
public string GetPublicationList() { string xmlOrJson = "xml"; try { coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["UserName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString())); string output = string.Empty; XmlDocument publicationList = new XmlDocument(); PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = coreService.Client.GetSystemWideListXml(filter); publicationList.Load(publications.CreateReader()); if (xmlOrJson.ToString().ToLower() == "json") { output = JsonConvert.SerializeObject(publicationList); } else { output = publicationList.InnerXml.ToString(); } return(output); } catch (Exception ex) { return(ex.Message.ToString()); } }
internal string GetPublication(string publicationTitle, params string[] parentIds) { // Console.WriteLine("Getting Publication " + publicationTitle); Stopwatch watch = new Stopwatch(); watch.Start(); string publicationId = TcmUri.UriNull; PublicationsFilterData publicationsFilter = new PublicationsFilterData(); foreach (XElement pub in _client.GetSystemWideListXml(publicationsFilter).Nodes()) { if (!pub.Attribute("Title").Value.Equals(publicationTitle)) { continue; } publicationId = pub.Attribute("ID").Value; Console.WriteLine("Found publication with ID " + publicationId); break; } if (publicationId.Equals(TcmUri.UriNull) && CreateIfNewItem) { // New Publication PublicationData newPublication = //(PublicationData)_client.GetDefaultData(ItemType.Publication, null, _readOptions); (PublicationData)_client.GetDefaultData(ItemType.Publication, null); newPublication.Title = publicationTitle; newPublication.Key = publicationTitle; if (parentIds.Length > 0) { List <LinkToRepositoryData> parents = new List <LinkToRepositoryData>(); foreach (string parentId in parentIds) { LinkToRepositoryData linkToParent = new LinkToRepositoryData { IdRef = parentId }; parents.Add(linkToParent); } newPublication.Parents = parents.ToArray(); } newPublication = (PublicationData)_client.Save(newPublication, _readOptions); publicationId = newPublication.Id; Console.WriteLine("Created publication with ID " + publicationId); } watch.Stop(); Console.WriteLine("GetPublication finished in " + watch.ElapsedMilliseconds + " milliseconds."); return(publicationId); }
public List <Publications> GetPublicationList() { GetPublishedInfo getPublishedInfo = new GetPublishedInfo(); XmlDocument publicationList = new XmlDocument(); PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = Client.GetSystemWideListXml(filter); if (publications == null) { throw new ArgumentNullException(nameof(publications)); } List <Publications> publicationsList = getPublishedInfo.Publications(publicationList, publications); return(publicationsList); }
private static string GetAllPublications() { List<string> pubs = new List<string>(); using (CoreServiceClient client = new CoreServiceClient(endpointName)) { var credentials = CredentialCache.DefaultNetworkCredentials; if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password)) { credentials = new NetworkCredential(userName, password); } client.ChannelFactory.Credentials.Windows.ClientCredential = credentials; PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = client.GetSystemWideListXml(filter); XNamespace ns = publications.GetNamespaceOfPrefix("tcm"); foreach(XElement item in publications.DescendantNodes()) { pubs.Add(item.Attribute("ID").Value); } } string allPubs = string.Join(", ", Array.ConvertAll(pubs.ToArray(), i => i.ToString())); return allPubs; }
/// <summary> /// Get a list of publications in the current Tridion environment /// </summary> /// <returns>List of ListItem objects</returns> public List<ListItem> GetPublications() { PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = this.Client.GetSystemWideListXml(filter); List<ListItem> items = new List<ListItem>(); items.AddRange(publications.Elements(ToolsConfiguration.TridionCmNamespace + "Item") .Select(t => new ListItem() { Value = t.Attribute("ID").Value, Text = t.Attribute("Title").Value }) .ToList()); return items; }
/// <summary> /// TreeNodePopulate event handler /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> public void PopulateNode(Object sender, TreeNodeEventArgs e) { XmlDocument doc = new XmlDocument(); TcmUri uri = new TcmUri(e.Node.Value); if (uri.IsUriNull) // the root node { PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = _client.GetSystemWideListXml(filter); doc.Load(publications.CreateReader()); } else { switch (uri.ItemType) { case ItemType.Publication: PublicationData pub = (PublicationData)_client.Read(uri.ToString(), new ReadOptions()); TreeNode tnF = CreateTreeNode(pub.RootFolder.Title, pub.RootFolder.IdRef); TreeNode tnS = CreateTreeNode(pub.RootStructureGroup.Title, pub.RootStructureGroup.IdRef); TreeNode tnC = CreateTreeNode("Categories and Keywords", string.Format("tcm:{0}-0-131200", uri.ItemId)); if (tnF != null) { e.Node.ChildNodes.Add(tnF); } if (tnS != null) { e.Node.ChildNodes.Add(tnS); } if (tnC != null) { e.Node.ChildNodes.Add(tnC); } break; case ItemType.Folder: XElement items = _client.GetListXml(uri.ToString(), new OrganizationalItemItemsFilterData() { Recursive = false }); doc.Load(items.CreateReader()); break; case ItemType.WorkItem: // fake type id, representing the categories & keywords node! items = _client.GetListXml(string.Format("tcm:0-{0}-1", uri.PublicationId), new TaxonomiesFilterData()); doc.Load(items.CreateReader()); break; case ItemType.StructureGroup: items = _client.GetListXml(uri.ToString(), new OrganizationalItemItemsFilterData() { Recursive = false }); doc.Load(items.CreateReader()); break; case ItemType.Category: items = _client.GetListXml(uri.ToString(), new KeywordsFilterData() { IsRoot = true }); doc.Load(items.CreateReader()); break; case ItemType.Keyword: items = _client.GetListXml(uri.ToString(), new ChildKeywordsFilterData()); doc.Load(items.CreateReader()); break; default: break; } } foreach (XmlElement item in doc.SelectNodes("//tcm:Item", _nsMgr)) { TreeNode tNode = CreateTreeNode(item.GetAttribute("Title"), item.GetAttribute("ID")); if (tNode != null) { e.Node.ChildNodes.Add(tNode); } } }
/// <summary> /// TreeNodePopulate event handler /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> public void PopulateNode(Object sender, TreeNodeEventArgs e) { XmlDocument doc = new XmlDocument(); TcmUri uri = new TcmUri(e.Node.Value); if (uri.IsUriNull) // the root node { PublicationsFilterData filter = new PublicationsFilterData(); XElement publications = _client.GetSystemWideListXml(filter); doc.Load(publications.CreateReader()); } else { switch (uri.ItemType) { case ItemType.Publication: PublicationData pub = (PublicationData)_client.Read(uri.ToString(), new ReadOptions()); TreeNode tnF = CreateTreeNode(pub.RootFolder.Title, pub.RootFolder.IdRef); TreeNode tnS = CreateTreeNode(pub.RootStructureGroup.Title, pub.RootStructureGroup.IdRef); TreeNode tnC = CreateTreeNode("Categories and Keywords", string.Format("tcm:{0}-0-131200", uri.ItemId)); if (tnF != null) { e.Node.ChildNodes.Add(tnF); } if (tnS != null) { e.Node.ChildNodes.Add(tnS); } if (tnC != null) { e.Node.ChildNodes.Add(tnC); } break; case ItemType.Folder: XElement items = _client.GetListXml(uri.ToString(), new OrganizationalItemItemsFilterData() { Recursive = false }); doc.Load(items.CreateReader()); break; case ItemType.WorkItem: // fake type id, representing the categories & keywords node! items = _client.GetListXml(string.Format("tcm:0-{0}-1", uri.PublicationId), new TaxonomiesFilterData()); doc.Load(items.CreateReader()); break; case ItemType.StructureGroup: items = _client.GetListXml(uri.ToString(), new OrganizationalItemItemsFilterData() { Recursive = false }); doc.Load(items.CreateReader()); break; case ItemType.Category: items = _client.GetListXml(uri.ToString(), new KeywordsFilterData() { IsRoot = true }); doc.Load(items.CreateReader()); break; case ItemType.Keyword: items = _client.GetListXml(uri.ToString(), new ChildKeywordsFilterData()); doc.Load(items.CreateReader()); break; default: break; } } foreach (XmlElement item in doc.SelectNodes("//tcm:Item", _nsMgr)) { TreeNode tNode = CreateTreeNode(item.GetAttribute("Title"), item.GetAttribute("ID")); if (tNode != null) { e.Node.ChildNodes.Add(tNode); } } }