다음을 통해 공유


CReplicationProject.Start Method

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

Starts the replication of a Commerce Server Staging (CSS) project.

object Start(int flags)

Parameters

  • flags
    The flags for this particular replication. Specify 0 (zero) to use the flags that are defined for the project. For a description of the flags, see CSS API Flags.

Return Value

A new CReplicationInstance object.

Remarks

You must create a project before you call this method. If you have not defined a project before you call the Start method, the method call fails and sets the error code to -1073680687 ("Could not find the project.").

The CReplicationProject.Start method corresponds to the COM method named ReplicationProject.Start.

Example

The following example starts the project named Project1 with default flags (0). The project is canceled if the replication takes longer than expected.

CReplicationServer replicationServer = new CReplicationServer();
replicationServer.Initialize("");
CReplicationProject replicationProject;
replicationProject = (CReplicationProject)replicationServer.OpenProject("Project1", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
CReplicationInstance replicationInstance;
replicationInstance = (CReplicationInstance)replicationProject.Start(0);
  int i = 0;
  int sleepTime = 2000;
  int maxNumberOfPolls = 100;
    while (true)
    {
    replicationInstance.Query();
    // If replication is in one of the terminal states, exit.
         if ((int)replicationInstance.State == 0 || // Empty
            (int)replicationInstance.State == 9 || // Done
            (int)replicationInstance.State == 4 || // Aborted
            (int)replicationInstance.State == 5 || // Canceled
            (int)replicationInstance.State == 8) // Partial
      {
            break;
      }
      else
      {
            System.Threading.Thread.Sleep(sleepTime);
            if (i++ > maxNumberOfPolls)
            {
                  Console.WriteLine("Replication took longer than expected ... Canceling project");
                  replicationProject.Cancel();
            }
      }
}

See Also

Other Resources

Projects

How to Start and Stop Project Replication

CSS API Flags

CReplicationInstance.State Property

CReplicationProject.StartReplicationClient Method

CReplicationInstance Class

CReplicationProject.Cancel Method

CReplicationProject Class