Поделиться через


How to Retrieve Staging Information

You use one of the CReplicationServer enumeration methods to retrieve staging information. Each enumeration method sets e.ErrorCode to -2147422485 (“No more items.”) and returns an empty object to indicate the end of an enumeration.

Note

You must have Commerce Server 2009 Staging (CSS) administrator or operator rights to retrieve staging information.

To retrieve staging information

  1. Open a CReplicationServer object.

  2. Initialize the server object on the specified server by using the CReplicationServer.Initialize method.

  3. Iterate to retrieve each instance of the information. Retrieve the information that you want for the server by calling one of the CReplicationServer enumeration methods in the following list:

    • Enum. Retrieves the global properties that are defined for the CSS service on the server.

    • EnumProjects. Retrieves the projects defined on the server.

      This method returns a CReplicationProject object for each project defined on the server, one for each project until all projects have been enumerated.

    • EnumReplications. Retrieves the set of replication instances that are in a specified state for a project or set of project that are running on a server. If no project is specified, it retrieves the replications for all projects.

      This method returns a CReplicationInstance object for each replication instance found for the projects that match the specified state. One object each is returned until all matching instances have been enumerated. The returned objects contain information about the replication as a whole that include its status and state.

    • EnumRoutes. Retrieves the routes defined on the server.

      This method returns a CReplicationRoute object for each route defined on the server. One object each is returned until all routes have been enumerated.

    • EnumServers. Retrieves the names of the servers that are defined on the server as either a source staging server or destination server. Servers that are defined for projects and routes are retrieved.

Example

The following example displays the names of the projects that are defined on the server named CSS001.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("CSS001");
  Console.WriteLine("The following projects are defined on server CSS001:");
  int iterator = 0;
  object i = iterator as object;
  while (true)
  {
    try
      {
      CReplicationProject project = (CReplicationProject)replicationServer.EnumProjects(ref i);
        Console.WriteLine(project.get_Name());
      }
      catch (System.Runtime.InteropServices.COMException e)
      {
          // Quit if "No more items" error
          if (e.ErrorCode == -2147422485)
              break;
          else
              throw e;
      }
  } 

See Also

Other Resources

What are the Staging API Concepts?

CReplicationInstance Class

CReplicationProject Class

CReplicationRoute Class

Managing the CSS Service Using the Staging API