Get Publishing Target Directory

27 views
Skip to first unread message

Nader Chmait

unread,
Feb 28, 2017, 5:48:31 PM2/28/17
to SmartAPI
Hello,

I'm trying to get the directory of where the publishing target points to on the server.  Here is my code so far:

using (var session = SessionBuilder.CreateOrReplaceOldestSession(login))

{

//this is the currently active project in the session

var selectedProject = session.SelectedProject;

var serverManager = session.ServerManager;

Label1.Text = "Project: " + selectedProject.Name + "<br>";

IProject proj = selectedProject;

List<string> pubList = new List<string>();

foreach (project.Publication.IPublicationTarget t in proj.PublicationTargets.ToList())

{

Label2.Text += t.Name + "<br>";

pubList.Add(t.Name);

}

project.Publication.IPublicationTarget target = selectedProject.PublicationTargets.GetByName(pubList[0]);

Label3.Text = "Guid: " + target.Guid.ToString()

+ "<br> Name: " + target.Name

+ "<br> project: " + target.Project

+ "<br> Session: " + target.Session

+ "<br> url prefix: " + target.UrlPrefix

+ "<br> Type: " + target.Type

+ "<br> <br><br><br><br>";

}


I was able to get every bit of information about the publishing target except for the directory path.  If you know of a way to do that, please let me know.


Thanks a lot!


Nader

Jonas Jacobi

unread,
Mar 1, 2017, 8:08:20 AM3/1/17
to SmartAPI
Hi Nader,

unfortunately the API currently does not support this directly.
What you can do is access the underlying RQL XML element of the publishing target object and get your info from there:

var element = (XmlElement)

                folder.GetType()

                    .GetProperty("XmlElement")

                    .GetValue(folder, null);
var path = element.Attributes["Here you have to insert the name of the RQL attribute containing the path"].Value;

You have to check the log files for the RQL loading the publishing target to get the attribute containing the directory path,
as I don't know it off the top of my head.

Cheers
Jonas

Nader Chmait

unread,
Mar 1, 2017, 10:54:20 AM3/1/17
to SmartAPI
That's awesome, it worked!  Thanks a lot for you help and for the quick reply!

Nader
Reply all
Reply to author
Forward
0 new messages