Share via


How to Create and Modify a Staging Project

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

The CReplicationProject object provides the functionality to manage staging projects. You use the CReplicationServer.OpenProject method to create a new project or open an existing project by specifying one of two flags.

Note

You must have Commerce Server Staging (CSS) administrator rights to create and modify staging projects.

Before you create a business data project, create the business data configuration XML file. For information about the file syntax, see CSS Business Data XML Configuration File Syntax Elements.

In addition to the project properties in the following list, you can add a schedule to a project. For information about how to add a schedule, see How to Manage Staging Schedules.

To create a project and specify project properties

  1. Create a CReplicationServer object.

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

  3. Call the CReplicationServer.OpenProject method to create and open a new project. Specify the CREATE_NEW_PROJECT flag and the name of the new project. Project names must consist of alphanumeric characters and must not exceed 49 characters.

  4. Add a destination to the project by calling the CReplicationProject.AddDestination method. A destination can be the name of a server, route, or an absolute directory path. Call this method to add as many destinations as you must have to support the staging topology for the project.

    • For a source staging server, specify the waypoint and endpoint servers according to the staging topology. For same-box replication, specify the directory path to receive the replicated data.

    • For a waypoint server, specify the waypoint and endpoint servers according to the staging topology.

    • For an endpoint server, do not specify any destinations for Web content or IIS metabase projects. For business data projects, specify the absolute directory path of the Commerce Server site to receive the replicated data.

    Note

    You cannot specify a route or a waypoint server as a destination for IIS metabase projects. IIS metabase projects only support point to point or point to multipoint staging topologies.

  5. Set the CReplicationProject.LocalDirectory property. This property is used to specify the following:

    • For Web content projects, LocalDirectory specifies the source directory whose files are to be replicated and the endpoint directory where files are transmitted. The directory must be specified in the form: <drive>:/<path>.

    • For IIS metabase projects, LocalDirectory specifies the name of the Web site whose IIS metabase is to be replicated.

    • For business data projects, LocalDirectory specifies the directory to use to temporarily store data that is staged. You must create the local directory on the source staging server only before setting the project local directory. On destination servers, CSS automatically creates the folder. The directory must be specified in the form: <drive>:/<path>.

  6. For an IIS metabase project, set the MetabaseReplication property using the CReplicationProject.Put method.

  7. For a business data project, set the business data project properties CReplicationProject.BusinessDataProject and CReplicationProject.BusinessDataProjectXml.

  8. Optional. Use the CReplicationProject.Put method to set one or more of the following project properties:

    • AfterReceiveScript, AfterSendScript, BeforeReceiveScript, and BeforeSendScrip: the path and file names of pre- and post-processing scripts.

    • MailTo, MailToFail, and MailToSuccess: the e-mail addresses to send notifications of success or failure of a staging replication.

  9. Optional. For Web content projects, call the CReplicationProject.Put method to define any additional project properties.

  10. Optional. Set one or more project flags to control the staging of Web content files by setting the CReplicationProject.Flags property. If the project flags are not set, the project is run with the default flags, Incremental and Route.

  11. Call the CReplicationProject.Commit method to commit the changes that you made to the project.

To modify the properties of an existing project

  1. Create a CReplicationServer object.

  2. Call the CReplicationServer.Initialize method to initialize the server where the project is defined.

  3. Call the CReplicationServer.OpenProject method, specifying the OPEN_EXISTING_PROJECT flag and the name of an existing project.

  4. Call the CReplicationProject.AddDestination or CReplicationProject.RemoveDestination methods to add or remove destinations to the project.

  5. Call the CReplicationProject.Put method to modify one or more project properties.

  6. To change how Web content files are staged, set the CReplicationProject.Flags property.

  7. Call the CReplicationProject.Commit method to commit the changes that you made to the project.

Example

The following example creates a new project named Project2 on server CSS001. It first defines a route named RTNewYork that contains three destination servers and sets the base directory as D:\CSSProd. Then it creates and opens Project2, adds the destination servers CSS101, CSS102, and the route to the project.

This project specifies to deploy the files from the local directory C:\Temp to the five destination servers specified for the project and the route. The project specifies that only the C:\Temp directory, but no subdirectories under it (Flags=4096), are to be replicated.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("CSS001");
  CReplicationRoute replicationRoute = (CReplicationRoute)replicationServer.AddRoute("RtNewYork");
  replicationRoute.AddDestination("CSSNYProd1");
  replicationRoute.AddDestination("CSSNYProd2");
  replicationRoute.AddDestination("CSSNYProd3");
  replicationRoute.set_BaseDirectory(@"D:\CSSProd");
  replicationRoute.Commit();
  CReplicationProject replicationProject = (CReplicationProject)replicationServer.OpenProject("Project2", CSS_PROJECT_CREATION. CREATE_NEW_PROJECT);
  replicationProject.AddDestination("CSS101");
  replicationProject.AddDestination("CSS102");
  replicationProject.AddDestination("RtNewYork");
  replicationProject.set_LocalDirectory(@"C:\Temp");
  // Set the Project replication Flags to 4096, Exclude all subdirectories. Replicate only the current directory.
  replicationProject.set_Flags(4096);
  replicationProject.Commit();

The following example sets the LocalDirectory property to C:\NewDirectory for the project named MyProject. It also adds a new Destination, CSS001, and specifies the authentication credentials for that destination.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("");
  CReplicationProject replicationProject;
  replicationProject = (CReplicationProject)replicationServer.OpenProject("MyProject", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
  replicationProject.Put(“LocalDirectory”, @"C:\NewDirectory");
  replicationProject.AddDestination("CSS001;CSSAdmin;CSS.TestPW.123");
  replicationProject.Commit();

See Also

Other Resources

What Network Topologies does Staging Support?

What are the Staging API Concepts?

Staging Web Sites and Commerce Server Data

Working with Projects and Routes

How to Manage Routes

How to Manage Staging Schedules

How to Start and Stop Project Replication

CReplicationRoute Class

CReplicationProject Class

CReplicationServer Class

Managing Projects and Routes by using the Staging API