Jaa


How to Retrieve Project Information

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

You use one of the CReplicationProject enumeration methods to retrieve information for a project. 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 Staging (CSS) administrator or operator rights to retrieve project information.

To retrieve project information

  1. Open a CReplicationServer object.

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

  3. Call the CReplicationServer.OpenProject method to open an existing project.

  4. Iterate to retrieve each instance of the information. Retrieve the information that you want by calling one of the project enumeration methods in the following list:

    • Enum. Retrieves a property assigned to a project.

    • EnumAccess. Retrieves the set of users and their CSS user rights who are authorized to administer the project.

    • EnumDestination. Retrieves the names of all destinations. This includes those destinations defined in routes that are defined for the project.

    • EnumItems. Retrieves information about files in a specified directory that were replicated for a project.

      This method returns a CReplicationItem object for each file in the specified directory, one for each item that is called until all relevant items have been enumerated. The returned objects are the files for standard projects and containers for metabase projects.

      Note

      This method is only valid for Web content and Internet Information Server (IIS) metabase projects.

    • EnumReplications. Retrieves the set of replication instances that are in a specified state for a project that is running on a server.

      This method returns a CReplicationInstance object for each replication instance found for the project that matches 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 includes its status and state.

    • EnumSchedules. Retrieves the schedules that are defined for a project

      This method returns a CReplicationSchedule object for each replication schedule found for the project, one for each schedule until all schedules have been enumerated. The returned objects contain the properties that are defined for the schedule.

Example

The following example displays the destinations defined for the project named Project1.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("");
  CReplicationProject replicationProject;
  replicationProject = (CReplicationProject)replicationServer.OpenProject("Project1", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
  Console.WriteLine("The destination servers for Project1 are:");
  int iterator = 0;
  object i = iterator as object;
  while (true)
  {
      try
      {
          string destination = (string)replicationProject.EnumDestination(ref i);
          Console.WriteLine(destination);
      }
      catch (System.Runtime.InteropServices.COMException e)
      {
       // Exit if "No more items" error
       if (e.ErrorCode == -2147422485)
        break;
    else
        throw e;
      }
  }

See Also

Other Resources

What are the Staging API Concepts?

CReplicationItem Class

CReplicationSchedule Class

CReplicationInstance Class

CReplicationProject Class

Managing Projects and Routes by using the Staging API