public void CreateNewPubTargets() { var targetTypeList = GetTargetTypes(); var pubTargets = GetPublicationTargets(); foreach (var target in _targets) { // Do not add when publish target is existing if (!pubTargets.Exists(pt => pt.Title == target.Name)) { // Lookup wanted target type and publication var wantedTargetType = targetTypeList.First(tt => tt.Title == target.TargetType); var wantedPub = GetPublication(target.LinkedPublicationPrefix); if (wantedPub == null) { throw new Exception("Could not find a publication starting with " + target.LinkedPublicationPrefix); } // Setup new Pub Target object var pt = _core.GetDefaultData(ItemType.PublicationTarget, null) as PublicationTargetData; pt.Title = target.Name; pt.Description = target.Description; pt.Publications = new[] { new LinkToPublicationData() { IdRef = wantedPub.Id } }; pt.TargetTypes = new[] { new LinkToTargetTypeData() { IdRef = wantedTargetType.Id } }; pt.TargetLanguage = "None"; TargetDestinationData destination = new TargetDestinationData { ProtocolSchema = new LinkToSchemaData { IdRef = "tcm:0-6-8" }, Title = target.DestinationName, ProtocolData = "<HTTPS xmlns=\"http://www.tridion.com/ContentManager/5.0/Protocol/HTTPS\"><UserName>n/a</UserName><Password>n/a</Password><URL>" + target.Url + "</URL></HTTPS>" }; pt.Destinations = new[] { destination }; //Store _core.Create(pt, _readOpts); } } }
public void CreateNewPubTargets() { var targetTypeList = GetTargetTypes(); var pubTargets = GetPublicationTargets(); foreach (var target in _targets) { // Do not add when publish target is existing if (!pubTargets.Exists(pt => pt.Title == target.Name)) { // Lookup wanted target type and publication var wantedTargetType = targetTypeList.First(tt => tt.Title == target.TargetType); var wantedPub = GetPublication(target.LinkedPublicationPrefix); if (wantedPub == null) { throw new Exception("Could not find a publication starting with " + target.LinkedPublicationPrefix); } // Setup new Pub Target object var pt = _core.GetDefaultData(ItemType.PublicationTarget, null) as PublicationTargetData; pt.Title = target.Name; pt.Description = target.Description; pt.Publications = new[] { new LinkToPublicationData() { IdRef = wantedPub.Id } }; pt.TargetTypes = new[] { new LinkToTargetTypeData() { IdRef = wantedTargetType.Id } }; pt.TargetLanguage = "None"; TargetDestinationData destination = new TargetDestinationData { ProtocolSchema = new LinkToSchemaData { IdRef = "tcm:0-6-8" }, Title = target.DestinationName, ProtocolData = "<HTTPS xmlns=\"http://www.tridion.com/ContentManager/5.0/Protocol/HTTPS\"><UserName>n/a</UserName><Password>n/a</Password><URL>" + target.Url + "</URL></HTTPS>" }; pt.Destinations = new[] { destination }; //Store _core.Create(pt, _readOpts); } } }
/// <summary> /// Initializes a new instance of the <see cref="TargetDestination"/> class. /// </summary> /// <param name="client"><see cref="T:TcmCoreService.Client" /></param> /// <param name="binaryContentData"><see cref="T:Tridion.ContentManager.CoreService.Client.TargetDestinationData" /></param> public TargetDestination(Client client, TargetDestinationData targetDestinationData) : base(client) { mTargetDestinationData = targetDestinationData; }
internal void CreatePublicationTarget(XElement site, WebsiteHelper.TargetLanguage language) { string targetName = site.Element("Name").Value; string targetTypeId = TcmUri.UriNull; string url = string.Empty; if (language == WebsiteHelper.TargetLanguage.Aspnet || language == WebsiteHelper.TargetLanguage.REL) { url = "http://localhost:" + site.Element("Port").Value + "/httpupload.aspx"; } else if (language == WebsiteHelper.TargetLanguage.Jsp) { url = "http://localhost:" + site.Element("Port").Value + "/" + site.Element("ContextRoot").Value + "/httpupload"; } TargetTypesFilterData filter = new TargetTypesFilterData(); //filter.ForRepository.IdRef = Configuration.WebsitePublicationId; foreach (XElement node in _client.GetSystemWideListXml(filter).Nodes()) { if (node.Attribute("Title").Value.Equals(targetName)) { targetTypeId = node.Attribute("ID").Value; break; } } if (targetTypeId.Equals(TcmUri.UriNull)) { TargetTypeData targetType = (TargetTypeData)_client.GetDefaultData(ItemType.TargetType, null); targetType.Title = targetName; targetType.Description = targetName; targetType = (TargetTypeData)_client.Save(targetType, _readOptions); targetTypeId = targetType.Id; } PublicationTargetsFilterData pFilter = new PublicationTargetsFilterData(); string pTargetId = TcmUri.UriNull; foreach (XElement node in _client.GetSystemWideListXml(pFilter).Nodes()) { if (node.Attribute("Title").Value.Equals(targetName)) { pTargetId = node.Attribute("ID").Value; break; } } if (pTargetId.Equals(TcmUri.UriNull)) { PublicationTargetData pt = (PublicationTargetData)_client.GetDefaultData(ItemType.PublicationTarget, null); pt.Title = targetName; pt.Description = targetName; pt.Publications = new[] { new LinkToPublicationData { IdRef = Configuration.WebsitePublicationId } }; pt.TargetTypes = new[] { new LinkToTargetTypeData { IdRef = targetTypeId } }; SchemaData protocolSchema = (SchemaData)_client.Read("/webdav//HTTPS.xsd", _readOptions); //_client.GetSystemWideListXml() TargetDestinationData destination = new TargetDestinationData { ProtocolSchema = new LinkToSchemaData { IdRef = protocolSchema.Id }, Title = targetName, ProtocolData = "<HTTPS xmlns=\"" + protocolSchema.NamespaceUri + "\"><UserName>notused</UserName><Password>notused</Password><URL>" + url + "</URL></HTTPS>" }; pt.Destinations = new[] { destination }; if (language == WebsiteHelper.TargetLanguage.Aspnet) { pt.TargetLanguage = "ASP.NET"; } else { pt.TargetLanguage = "JSP"; } _client.Save(pt, null); } }
/// <summary> /// Initializes a new instance of the <see cref="TargetDestination"/> class. /// </summary> /// <param name="client"><see cref="T:TcmCoreService.Client" /></param> /// <param name="binaryContentData"><see cref="T:Tridion.ContentManager.CoreService.Client.TargetDestinationData" /></param> public TargetDestination(Client client, TargetDestinationData targetDestinationData) : base(client) { mTargetDestinationData = targetDestinationData; }