Page 1 of 1

ClientInstance.LocalStoreBasePath

Posted: Thu Dec 13, 2007 11:16 am
by Cast
The C# API uses a local folder for managing client info at the call of ServerOperations.Login(). (ex. C:\Documents and Settings\Default User\Local Settings\Application Data\Sourcegear\...)

I have found that the value of this local folder is kept in ServerOperations.client.ClientInstance.LocalStoreBasePath after a successful login attempt.

Is there a way to set the path that these files are pulled into before the ServerOperations.Login() call?

Thank you.

Code: Select all

ServerOperations.client.LoginOptions.URL = svHostname;
ServerOperations.client.LoginOptions.User = svUsername;
ServerOperations.client.LoginOptions.Password = svPassword;
ServerOperations.client.LoginOptions.Repository = svRepository;
ServerOperations.Login();

Posted: Thu Dec 13, 2007 11:39 am
by jeremy_sg
Unfortunately, if you want to set this option, you'll need to use the more detailed login method. This sample should get you close to what you need.

Code: Select all

ServerOperations.client.ClientInstance.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client, "C:\\wherever" );
ServerOperations.client.ClientInstance.Login(hostname, username, password);
ServerOperations.SetRepository("repositoryName");

Posted: Fri Dec 14, 2007 8:06 am
by Cast
I set this and all worked great. Thank you! This is a really cool product.

Unfortunately my newbie colors are going to fly at this moment... this client cache folder was removed accidentally instead of the working folder at the end of an activity.
After doing this, it seems the server/client assumes this client-cache always exists. The folder isn't being populated, now... and this is causing a handful of different errors. For instance, trying to :

ServerOperations.SetRepository(svRepository);

now causes...

Code: Select all

System.ArgumentNullException: Value cannot be null.
Parameter name: path2
   at System.IO.Path.Combine(String path1, String path2)
   at VaultClientOperationsLib.TreeCache..ctor(Int32 repID, String username, String uniqueRepositoryID, String localStoreBasePath, ClientInstance ci)
   at VaultClientOperationsLib.ClientInstance.SetActiveRepositoryID(Int32 id, String username, String uniqueRepositoryID, Boolean doRefresh, Boolean updateKnownChangesAll)
   at VaultClientIntegrationLib.ServerOperations.SetRepository(VaultRepositoryInfo repositoryInfo)
   at VaultClientIntegrationLib.ServerOperations.SetRepository(String repositoryName)
   at Handler.ProcessRequest(HttpContext context) in e:\dotnet_code\Vault\Handler.ashx:line 79
I've tried to use all of the .Refresh*() methods I could find for pulling the client cache, but it is hosed. Do you have any suggestions for this? :oops:

Posted: Fri Dec 14, 2007 10:36 am
by jeremy_sg
The problem is that it's attempting to concatenate your local base store path with the unique repository GUID, but that GUID is null. I'm not sure how that could be happening. Could you try to use a more explicit method of setting the repository? Here's the code that the VaultClientIntegrationLib uses to set the repository. Let me know especially if theRep.UniqueRepID is null.

Code: Select all

if (repositoryName != null && repositoryName.Length > 0)
			{
				VaultRepositoryInfo theRep = null;

				VaultRepositoryInfo[] reps = null;
				client.ClientInstance.ListRepositories(ref reps);

				foreach (VaultRepositoryInfo r in reps)
				{
					if (r.RepName.ToLower() == repositoryName.ToLower())
					{
						theRep = r;
						break;
					}
				}

				if (theRep != null)
				{
	client.ClientInstance.SetActiveRepositoryID(theRep.RepID, client.LoginOptions.User, theRep.UniqueRepID, true, true);;
				}
				else
				{
					throw new UsageException(string.Format("Repository {0} not found", client.LoginOptions.Repository));
				}
			}

Posted: Fri Dec 14, 2007 2:11 pm
by Cast
Ah! Since I had done away with using the simplified Login method, ServerOperations.client.LoginOptions.User was no longer being used... so it was being passed in as an empty string for the SetActiveRepositoryID call, in your code above.

After I set this property explicitly, it works fine.

Thank you so much!