Page 1 of 2
GetBestWorkingFolder and Get latest file
Posted: Tue Apr 29, 2008 12:01 pm
by random
I am having issues with getting the latest version of a checked-out file. I am able to connect and checkout the file; however, Get fails with a GetLatestVersionFailedException because I do not have a working folder.
I have attempted to use both GetBestWorkingFolder and GetWorkingFolder to no avail. They both always return null. From what I understand, GetBest* works with inherited working folders while GetWorkingFolder works with explicit working folders. I have setup both scenarios and am still unable to get a working folder.
Is there something that I am missing?
Posted: Tue Apr 29, 2008 12:45 pm
by shannon
can you post a code snippet?
Posted: Wed Apr 30, 2008 8:23 am
by random
Absolutely! Thanks for your help
VaultClientFolder folder = m_client.Repository.Root.FindFolderRecursive( workingFolder );
if( folder == null )
return null;
// Get the working folder otherwise Get will fail.
if( m_client.TreeCache.GetBestWorkingFolder( folder.FullPath ) == null )
return null;
m_client.Refresh();
// TODO should check responses to see if there were errors
VaultClientFile[] files = VaultConnection.GetFiles( folder, fileNames );
VaultLib.VaultResponseItem[] responses = m_client.CheckOut( files, VaultLib.VaultCheckOutType.CheckOut, "" );
// We must do a get after the checkout otherwise the client will not be aware that the file
// exists locally and will not be able to check in later.
if( VaultConnection.GetLatestFiles( files ) )
return new List<VaultClientFile>( files );
return null;
Probably self-evident, but m_client is an instance of the ClientInstance class that has previously been created and is connected to our Vault server.
Also, I made sure that the version of the assemblies and the vault server are the same.
Posted: Wed Apr 30, 2008 9:07 am
by shannon
I forgot to ask, what version of the api are you using?
Posted: Wed Apr 30, 2008 9:08 am
by random
4.1.1.18060
Posted: Wed Apr 30, 2008 9:18 am
by shannon
our VaultConnection class doesn't have a GetFiles or GetLatestFiles method, is this a class you wrote?
Posted: Wed Apr 30, 2008 9:38 am
by random
It is. Here is the code for those methods:
private static VaultClientFile[] GetFiles( VaultClientFolder workingFolder, List<string> fileNames )
{
if( !m_isConnected )
return null;
try
{
List<VaultClientFile> list = new List<VaultClientFile>();
foreach( string fileName in fileNames )
{
if( workingFolder.HasFile( fileName ) )
{
foreach( VaultClientFile file in workingFolder.Files )
{
if( file.Name == fileName )
list.Add( file );
}
}
}
return list.ToArray<VaultClientFile>();
}
catch
{
}
return null;
}
public static bool GetLatestFiles( VaultClientFile[] files )
{
try
{
m_client.Get( files, true, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, null );
m_client.Refresh();
return true;
}
catch
{
}
return false;
}
It is the call to the Get method in GetLatestFiles that is throwing the GetLatestFailedException because of the lack of a working folder.
Posted: Wed Apr 30, 2008 9:46 am
by shannon
How are you setting the working folders? Can you log into the gui client and see that they've actually been set?
Posted: Wed Apr 30, 2008 9:47 am
by random
I can. The root ($) folder is set to "d:\localdev.net" and I force the inheritance of all subfolders. I also tried explicitly setting a working folder but the result was the same.
Posted: Wed Apr 30, 2008 10:15 am
by shannon
I'm working to figure out your problem, but it's taking some time. Can you give me the exact exception information, maybe a stack trace?
Posted: Wed Apr 30, 2008 10:22 am
by random
at VaultClientOperationsLib.ClientInstance.ProcessGetFileRequests(GetFileInfo[] infos, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, Boolean updateHiddenFilesOnly, String ancestorFullPath, Boolean flat, String ancestorDiskPath, OverwritePrompt PromptData, Boolean isLabelGet, String currentPathToLabelItem, Int64 labelID, Boolean isRetry, Boolean isGetByDisplayVersion)
at VaultClientOperationsLib.ClientInstance.Get(VaultClientFile[] files, Boolean forceLatest, MakeWritableType makeWritable, SetFileTimeType setFileTime, MergeType merge, OverwritePrompt PromptData)
at FtsIndexParser.VaultConnection.GetLatestFiles(VaultClientFile[] files) in D:\localdev_vault\Documentation\FtsIndexParser\VaultConnection.cs:line 165
at FtsIndexParser.VaultConnection.CheckOut(String workingFolder, List`1 fileNames) in D:\localdev_vault\Documentation\FtsIndexParser\VaultConnection.cs:line 149
at FtsIndexParser.MainWindow.CloseWindow(Object sender, RoutedEventArgs e) in D:\localdev_vault\Documentation\FtsIndexParser\MainWindow.xaml.cs:line 822
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at FtsIndexParser.App.Main() in D:\localdev_vault\Documentation\FtsIndexParser\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Posted: Wed Apr 30, 2008 10:23 am
by random
Just a note: the file is successfully CheckedOut using the API before the Get method is called.
Posted: Wed Apr 30, 2008 10:59 am
by shannon
Are you setting your working folders using the gui client or in code with the api?
Can you successfully do a get on one of the files from the gui client? (make sure the file needs a get when you test this, i.e. old)
Posted: Wed Apr 30, 2008 10:59 am
by random
Working folders are set in the GUI client. I can do a getlatest without issues through the GUI client.
Posted: Wed Apr 30, 2008 11:48 am
by shannon
Please insert a call to m_client.TreeCache.GetWorkingFolderAssignments before your call to GetBestWorkingFolder and see what it returns.