Client API - SetActiveRepository

This forum is now locked, since Gold Support is no longer offered.

Moderator: SourceGear

Locked
ISBE
Posts: 11
Joined: Thu May 20, 2004 7:50 am

Client API - SetActiveRepository

Post by ISBE » Wed May 26, 2004 12:06 pm

The following code is the C# example for setting an active repository.

VaultRepositoryInfo[] reps = null;
//List all the repositories on the server.
client.ListRepositories(ref reps);
//Search for the one that we want.
foreach (VaultRepositoryInfo r in reps)
{
if (String.Compare(r.RepName,repositoryName, true) == 0)
{
//This will load up the client side cache files and refresh the repository structure.
//See http://support.sourcegear.com/viewtopic.php?t=6 for more on client side cache files.
client.SetActiveRepositoryID(r.RepID, client.Connection.Username, r.UniqueRepID, true, true);
break;
}
}


The following code is my attempt to convert it to VB.NET. I do not seem to have all of the information I need to convert this correctly. There seem to be variable declarations that I must make which I can only guess at what datatype or object they must be. I am using VS.NET 2002, framework 1.0 and Vault 2.0.3. Can you help?

Dim reps As VaultClientOperationsLib.VaultClientRepository
'???Dim r As VaultClientOperationsLib.VaultClientRepository
Dim ref As Array()
Dim repositoryName As String
fobjMyClientDev.ListRepositories(ref) ', reps)

'Search for the one that we want by name.
For Each r In reps

' If it matches...
If (String.Compare(r.RepName, repositoryName, True) = 0) Then

' Set this as the active repository.
fobjMyClientDev.SetActiveRepositoryID( _
r.RepID, _
fobjMyClientDev.Connection.Username, _
r.UniqueRepID, _
True, _
True)
Exit Sub 'break()
End If
Next

If (fobjMyClientDev.ActiveRepositoryID = -1) Then
Throw New Exception("Repository not found.")
End If

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Wed May 26, 2004 12:50 pm

ISBE:

I'm assuming you are connecting as a client. If so, most of the types used will be found in VaultClientNetLib.ClientService{}. If you browse the VaultClientNetLib.ClientService dll, you should see types to use.

For your example, try using:

' the repository info array
Dim reps As VaultClientNetLib.ClientService.VaultRepositoryInfo()

' now ask the server for a list of repositories.
ci.ListRepositories(ByRef ref)

Hope that helps.
Linda Bauer
SourceGear
Technical Support Manager

Locked