GetBestWorkingFolder and Get latest file
Moderator: SourceGear
GetBestWorkingFolder and Get latest file
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?
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?
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.
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.
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.
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.
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()
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()