Partilhar via


CReplicationServer.Commit Method

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

Commits the changes that have been made to a property that is defined for the Commerce Server Staging (CSS) service.

void Commit()

Remarks

You must have CSS administrator permissions to call this method.

You must stop and start the CSS service on the server for the new values to take effect.

The CReplicationServer.Commit method corresponds to the COM method named ReplicationServer.Commit.

Example

The following example checks the value of the CReplicationServer.UseTransactions property to see whether transaction processing is enabled. If it is not enabled, the code enables it, commits the change, and then stops and restarts the server.

#using System.ServiceProcess; // Defined in assembly System.Serviceprocess.dll
// Initialize a service controller to get information on the state of the CSS service
ServiceController ctrl = new ServiceController("Commerce Server Staging");
CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("");
  string transactions = (string)replicationServer.get_UseTransactions();
  if (transactions == "Yes")
  {
      replicationServer.set_UseTransactions("No");
      replicationServer.Commit();
// Stop the CSS service
      replicationServer.Stop();      
// Wait for the CSS service to stop [wait a maximum of 5 minutes] 
ctrl.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 5, 0));
// Check if the CSS service is stopped and then start it.
if(ctrl.Status != ServiceControllerStatus.Stopped)
    Console.WriteLine("Service took too long to stop.");
else
      replicationServer.Start();
  }

Compiling the Code

You must add a using directive for the System.ServiceProcesses namespace to run this sample.

See Also

Other Resources

Managing the CSS Service

How to Set, Modify, and Retrieve Global Properties for a CSS Service

CReplicationServer.Start Method

CReplicationServer.Stop Method

CReplicationServer Class