public string getSchemaByTcm(string tcmuri) { string xmljson = "XML"; try { string output = string.Empty; coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["UserName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString())); SchemaFieldsData schemaFieldsData = coreService.Client.ReadSchemaFields("tcm:" + tcmuri, false, null); if (xmljson.ToString().ToLower() == "json") { output = JsonConvert.SerializeObject(schemaFieldsData); } else { output = JsonConvert.SerializeObject(schemaFieldsData); XmlDocument doc = new XmlDocument(); using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(output), XmlDictionaryReaderQuotas.Max)) { XElement xml = XElement.Load(reader); doc.LoadXml(xml.ToString()); } output = doc.InnerXml.ToString(); } return(output);// xmljson.ToString().ToLower() == "json" ? ConvertTojson.ConvertXmlToJson(schemasXml.ToString()) : schemasXml.ToString(); } catch (Exception ex) { return(ex.Message.ToString()); } }
static void Main(string[] args) { //Read data from SF Console.WriteLine("Please enter 1 to connect With SF And Write Data In Tridion"); int input = int.Parse(Console.ReadLine()); coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["cmsUserName"].ToString(), ConfigurationManager.AppSettings["cmsPassword"].ToString(), ConfigurationManager.AppSettings["cmsDomain"].ToString())); if (input == 1) { List <Lead> leadList = SFConnect.connectWithSFAndWriteDataInTridion(); WriteDataInTridion.createDataInTridion(coreService, ConfigurationManager.AppSettings["SchemaID"].ToString(), leadList); } else { List <Lead> leadList = ReadDataFromTridion.getLeadList(coreService); SFConnect.connectWithTridionAndWriteDataInSF(leadList); } //Create a new record //if (true) //{ // coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["cmsUserName"].ToString(), ConfigurationManager.AppSettings["cmsPassword"].ToString(), ConfigurationManager.AppSettings["cmsDomain"].ToString())); // List<Lead> leadList = ReadDataFromTridion.getLeadList(coreService); // SFConnect.connectWithSFAndWriteData(leadList); //} }
public string GetAllCategoriesWithInPubByTcmUri(string tcmuri) { string xmljson = "xml"; try { string output = string.Empty; coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["UserName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString())); var componentData = coreService.Client.GetList("tcm:" + tcmuri, new CategoriesFilterData()); //TridionComponent.GetAllCategoriesWithInPubByTcmUri(coreService, tcmuri); if (xmljson.ToString().ToLower() == "json") { output = JsonConvert.SerializeObject(componentData); } else { output = JsonConvert.SerializeObject(componentData); XmlDocument doc = new XmlDocument(); using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(output), XmlDictionaryReaderQuotas.Max)) { XElement xml = XElement.Load(reader); doc.LoadXml(xml.ToString()); } output = doc.InnerXml.ToString(); } return(output); } catch (Exception ex) { return(ex.Message.ToString()); } }
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()); } }
public string GetMultimediaComponentByPubID(string tcmuri) { 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; var filter = new RepositoryItemsFilterData(); filter.ItemTypes = new ItemType[] { ItemType.Component }; filter.ComponentTypes = new ComponentType[] { ComponentType.Multimedia }; filter.Recursive = true; var listXml = coreService.Client.GetListXml("tcm:" + tcmuri, filter); if (xmlOrJson.ToString().ToLower() == "json") { output = JsonConvert.SerializeObject(listXml); } else { output = listXml.ToString(); } return(output); } catch (Exception ex) { return(ex.Message.ToString()); } }
public string getComponentByTcm(string tcmuri) { try { coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationManager.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationManager.AppSettings["UserName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString())); var component = coreService.Client.Read("tcm:" + tcmuri, null) as ComponentData; return(component.Content.ToString()); } catch (Exception ex) { return(ex.Message.ToString()); } }
public string GetListOfAllFolder(string tcmuri) { 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; var rootFolderUri = "tcm:" + tcmuri; OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData(); var listXml = coreService.Client.GetListXml(rootFolderUri, filter); return(listXml.ToString()); } catch (Exception ex) { return(ex.Message.ToString()); } }
public string GetKeywordByCategory(string tcmuri) { string xmljson = "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())); var filter = new OrganizationalItemItemsFilterData(); var category = "tcm:" + tcmuri; var keywords = coreService.Client.GetListXml(category, filter); return(xmljson.ToString().ToLower() == "json" ? JsonConvert.SerializeObject(keywords) : keywords.ToString()); } catch (Exception ex) { return(ex.Message.ToString()); } }
public string GetComponentTemplateByPubID(string tcmuri) { string xmljson = "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())); var filter = new RepositoryItemsFilterData(); filter.ItemTypes = new[] { ItemType.ComponentTemplate, }; filter.Recursive = true; var listXml = coreService.Client.GetListXml("tcm:" + tcmuri, filter); return(xmljson.ToLower() == "json" ? JsonConvert.SerializeObject(listXml) : listXml.ToString()); } catch (Exception ex) { return(ex.Message.ToString()); } }
public string GetUserList() { 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; var listXml = coreService.Client.GetSystemWideListXml(new UsersFilterData { BaseColumns = ListBaseColumns.IdAndTitle, IsPredefined = false }); XmlDocument doc = new XmlDocument(); doc.LoadXml(listXml.ToString()); output = xmlOrJson.ToString().ToLower() == "json" ? JsonConvert.SerializeObject(doc) : doc.ToString(); return(doc.InnerXml); } catch (Exception ex) { return(ex.Message.ToString()); } }
public static void process(List <News> DataFromExchange) { try { coreService = CoreServiceFactory.GetCoreServiceContext(new Uri(ConfigurationSettings.AppSettings["CoreServiceURL"].ToString()), new NetworkCredential(ConfigurationSettings.AppSettings["UserName"].ToString(), ConfigurationSettings.AppSettings["Password"].ToString(), ConfigurationSettings.AppSettings["Domain"].ToString())); SchemaFieldsData schemaFieldData = coreService.Client.ReadSchemaFields(ConfigurationSettings.AppSettings["SchemaID"].ToString(), true, new ReadOptions()); foreach (News p in DataFromExchange) { string serializeXml = ""; bool bln = helper.helper.Serialize <News>(p, ref serializeXml); string xml = serializeXml; var tcmuri = TridionComponent.GenerateComponent(coreService, xml, helper.helper.SetPublication(ConfigurationSettings.AppSettings["FolderLocation"].ToString(), ConfigurationSettings.AppSettings["SchemaID"].ToString()), helper.helper.SchemaType.Component, ConfigurationSettings.AppSettings["FolderLocation"].ToString(), p.title, p.title); if (p.IsPublish.ToLower() == "true") { TridionComponent.Publish(tcmuri, ConfigurationSettings.AppSettings["PublicationTargetIDs"].ToString(), coreService); } } } catch (Exception ex) { throw ex; } }