Jaa


CReplicationInstance.Cancel Method

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

Cancels a replication that is currently running for a Commerce Server Staging (CSS) project.

void Cancel()

Remarks

You must have CSS administrator rights to call this method.

The CReplicationInstance.Cancel method corresponds to the COM method named ReplicationInstance.Cancel.

Example

The following example first checks the status of the replications that are defined for the project named Project1. It then cancels and displays the names of all replications that did not complete successfully (status != 0).

CReplicationServer replicationServer = new CReplicationServer();
replicationServer.Initialize("");
CReplicationProject replicationProject = (CReplicationProject)replicationServer.OpenProject("Project1", CSS_PROJECT_CREATION.OPEN_EXISTING_PROJECT);
Console.WriteLine("The following replications were canceled:");
int iterator = 0;
object i = iterator as object;
CReplicationInstance replicationInstance;
while (true)
{
    try
    {
        replicationInstance = (CReplicationInstance)replicationProject.EnumReplications(2, ref i);
        Int64 status = Convert.ToInt64(replicationInstance.Status);
        if (status != 0)
        {
            // Cancel it
            replicationInstance.Cancel();
            Console.WriteLine(replicationInstance.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

CReplicationProject.EnumReplications Method

CReplicationInstance.Status Property

CReplicationProject.Cancel Method

CReplicationInstance Class