Vault API - Determining who a file is checked out to

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
dvydra
Posts: 1
Joined: Tue Aug 31, 2004 12:38 am

Vault API - Determining who a file is checked out to

Post by dvydra » Tue Aug 31, 2004 12:44 am

Hi,
I am trying to use the API to integrate Vault with our application, and I cannot figure out how to determine to whom a file is checked out.

I can call ClientInstance.IsCheckedOutByMeOnAnyMachine and ClientInstance.IsCheckedOutExclusiveByAnyone which at least tells me if it's Checked in, Checked out by someone else, or Checked out by me.

However, short of iterating through the user list and passing each username to ClientInstance.IsCheckedOutBySpecificUser, I can't see a way to determine the user that has a file checked out.

Any suggestions?

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Wed Sep 08, 2004 10:35 am

In the Vault GUI client, we use code like this to display all of the users who have a certain item checked out.

Code: Select all

	foreach (VaultClientCheckOutItem coitem in 	myClientInstance.TreeCache.CheckOuts)
	{
		if (file.ID == coitem.FileID)
		{
			foreach (VaultClientCheckOutUser couser in coitem.CheckOutUsers)
			{
				// We may need a comma.
				if (CheckOutUsers.Length > 0)
				{
					CheckOutUsers += ", ";
				}

				CheckOutUsers += couser.Name;
				switch (couser.LockType)
				{
					case VaultCheckOutType.None:
					break;
					case VaultCheckOutType.CheckOut:
					break;
					case VaultCheckOutType.Exclusive:
						CheckOutUsers += " (Exclusive)";
						break;
				}
			}

			// Stop us from looping through the rest of the IDs.
			break;
		}
	}

Post Reply