CSApplicationSiteList Method (Boolean) Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Gets a list of all sites registered in certain installation of Content Studio.

Namespace: ContentStudio
Assembly: CSServer5 (in CSServer5.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public string SiteList(
	bool newSyntax
)

Parameters

newSyntax
Type: SystemBoolean
If true the returned XML follows the new style syntax with values in attributes rather than elements

Return Value

Type: String
XML string

<root>
  <list>
    <cs_site connectionid="1" 
             sitename="TheSite" 
             version="5.0.1 release" 
             webservername="MyServer" 
             adminurl="http://mysite.se/cs" />
  </list>
</root>

With the old syntax style each attribute is replaced with an element with the same name.

Examples

This small sample shows how you can use the SiteList(Boolean) method class to obtain a list of sites registered in Content Studio.
The sample uses remoting configuration technique to enable the application to call CS API remotely.
This is technique has been documented in the article Calling Content Studio API externally in the Content Studio SDK.

using System;
using System.Runtime.Remoting;
using ContentStudio;
namespace RemConfig
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //Configure the Remoting client channels by using the configuration file
                RemotingConfiguration.Configure("RemConfig.exe.config", true);
                //Get a list of all registered sites in content studio
                CSApplication csApp = new CSApplication();
                using(System.IO.StringReader sr = new System.IO.StringReader(csApp.SiteList(true)))
                {
                   using(System.Xml.XmlReader xrd = System.Xml.XmlReader.Create(sr))
                   {
                      Console.WriteLine("Id\tName\t");
                      while (xrd.Read())
                      {
                          if (xrd.NodeType != System.Xml.XmlNodeType.Element)
                              continue;
                          if (xrd.Name == "cs_site")
                          {
                             Console.Write(xrd.GetAttribute("connectionid"));
                             Console.Write("\t");
                             Console.Write(xrd.GetAttribute("sitename"));
                             Console.WriteLine();
                          }
                      }
                      xrd.Close();
                   }
                }
            }
            catch (RemotingException rex)
            {
                Console.WriteLine("ERROR: There is a problem with your remoting configuration!");
                Console.WriteLine(rex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: There was problem with the call!");
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
    }
}
See Also

Reference