Jaa


CReplicationServer.EnumServers Method

Retrieves the names of servers that are defined for a project or for a route on the Commerce Server Staging (CSS) server.

object EnumServers(ref object iterator, Microsoft.CommerceServer.Staging.Interop.CSS_SERVER_TYPES serverType)

Parameters

  • iterator
    Used by the service to enumerate the list of servers. This value should be initialized to 0 (zero) and should not be modified.

  • serverType
    The type of server to be retrieved. The following table identifies the valid values for the serverType parameter.

    Server type

    Value

    Description

    STAGER

    1

    Returns source staging servers.

    ENDPOINT

    2

    Returns destination servers.

Return Value

The name of the server.

Remarks

You must have CSS administrator or operator permissions to call this method.

This method retrieves the names of all servers that are defined for a project or for a route on the replication server.

This method sets e.ErrorCode to -1073680630 (“No destination servers defined.”) when there are no destination servers that are defined on the server and to -2147422485 (“No more items.”) to indicate the end of the enumeration.

The CReplicationServer.EnumServers method corresponds to the COM method named ReplicationServer.EnumServers.

Example

The following example displays the names of the destination servers (serverType= ENDPOINT) that are defined on the server named gondar.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("gondar");
  string status;
  CReplicationProject replicationProject = (CReplicationProject)replicationServer.OpenProject("Project2", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
  replicationProject.GetProjectStatus(out status);
  Console.WriteLine("The staging servers are:");
  int iterator = 0;
  object i = iterator as object;
  while (true)
  {
    try
    {
    string server = (string)replicationServer.EnumServers(ref i, CSS_SERVER_TYPES.ENDPOINT);
          Console.WriteLine(server);
    }
      catch (System.Runtime.InteropServices.COMException e)
      {
      // Quit if "No more items" error
      if (e.ErrorCode == -2147422485)
         break;
      else
         throw e;
      }
  }

See Also

Other Resources

Managing the CSS Service

How to Retrieve Staging Information

CReplicationServer.ServerName Property

CReplicationServer Class