Partager via


Enumerating Projects Sample

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

The following example displays the name of each Commerce Server Staging (CSS) project that is defined on a replication server.

Option Explicit 
On Error Resume Next

const CSS_ERROR_NO_PROJECTS_DEFINED = &hC000EED0
const CSS_ERROR_NO_MORE_ITEMS  = &h8000EEEB

dim ReplicationServer
dim ReplicationProject
dim Iterator

set ReplicationServer = CreateObject("CssApi.ReplicationServer")
ReplicationServer.Initialize("")

Wscript.Echo "The server has the following projects:"

Iterator = 0
do while True
'Clear any error text.
Err.Clear

'Get the next project.
set ReplicationProject = ReplicationServer.EnumProjects(Iterator)

'Quit if no projects are defined on the server.
if Err.Number = CSS_ERROR_NO_PROJECTS_DEFINED then 
Wscript.Echo "No projects are defined."
exit do
end if

'Quit if there are no more projects.
if Err.Number = CSS_ERROR_NO_MORE_ITEMS then exit do

'Quit if an empty object was returned.
if IsEmpty(ReplicationProject) then 
Wscript.Echo "An empty project object was returned."
exit do
end if

'Display the name of the project.
Wscript.Echo ReplicationProject.Name
Loop
'Release the objects.
set ReplicationProject = Nothing
set ReplicationServer  = Nothing

See Also

Other Resources

CReplicationServer Class

CReplicationProject Class

COM Staging Examples