次の方法で共有


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

This topic provides instructions for how to set, modify, and retrieve the global properties that are defined for a Commerce Server 2009 Staging (CSS) service. For information about the CSS service, see Managing the CSS Service.

Note

You must have CSS administrator rights to set or modify a property. You must have CSS administrator or operator rights to retrieve the properties and to stop and restart the CSS service.

To set or modify global properties for the CSS service on a server

  1. Open a CReplicationServer object.

  2. Initialize the server whose properties you want to set by calling the CReplicationServer.Initialize method.

  3. Set or modify a global property by calling the CReplicationServer.Put method.

  4. Call the CReplicationServer.Commit method to commit the changes on the server.

  5. Call the CReplicationServer.Stop method to stop the service.

  6. Wait a maximum of five minutes before you continue the service.

  7. Call the CReplicationServer.Start method to restart the service.

    Note

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

To retrieve global properties for the CSS service on a server

  1. Open a CReplicationServer object.

  2. Initialize the server whose properties you want to retrieve by calling the CReplicationServer.Initialize method.

  3. Retrieve a global property by calling the CReplicationServer.Get method.

Example

The following example sets the MailHost property for the CSS service that is running on the local host to Contoso, commits the changes, and then stops and restarts the service.

// 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("");
  replicationServer.Put("MailHost", "Contoso");
  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();

The following example retrieves the value of the TransactionMethod property to determine whether transaction processing is enabled for the server named Test.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("Test");
  string transactionEnabled = (string)replicationServer.Get("TransactionMethod");
    if (transactionEnabled == "Yes")
      Console.WriteLine("Test has transaction processing.");
    else
      Console.WriteLine("Test does not have transaction processing");

See Also

Other Resources

Managing the CSS Service

Adding and Configuring CSS Servers

How to Retrieve Staging Information

CReplicationServer.Put Method

CReplicationServer.Get Method

CReplicationServer Class

Managing the CSS Service Using the Staging API