

Downloading and checking-out is so last year. The fashionable Vault API developer acquires their files. It has more style and class. Also, DocumentService.DownloadFile and DocumentService.CheckoutFile are no more in the 2014 API. So that kind of forces the issue. Connection.FileManager.AcquireFiles is the replacement. I’ll go over the architectural reason for the change in a later article.
Benefits of AcquireFiles
Yes, it’s a pain to have to update your code, but let me go over the benefits before you get too distraught.
- Downloads files to the working folder by default.
- Automatically handles large files.
- Automatically repairs broken references for known CAD file types.
- Can download entire assemblies in one call.
- Multi-thread download. It’s about 2x quicker when downloading an assembly.
- Get/checkout dialog available.
- Automatically sets file attributes, such as read-only and create date.
The only disadvantage that I have come across is that you can’t read a file directly into memory. You always acquire to a location on disk. The workaround is to acquire to a temp location, read the file to memory, then delete the temp file.
Here is some sample code.
|
// C# using VDF = Autodesk.DataManagement.Client.Framework;
public void DownlodFiles(ICollection<VDF.Vault.Currency.Entities.FileIteration> fileIters) { // download individual files to a temp location VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(m_conn); settings.LocalPath = new VDF.Currency.FolderPathAbsolute(@"c:\temp"); foreach (VDF.Vault.Currency.Entities.FileIteration fileIter in fileIters) { settings.AddFileToAcquire(fileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download); }
VDF.Vault.Results.AcquireFilesResults results = m_conn.FileManager.AcquireFiles(settings); }
public void DownloadAssembly(VDF.Vault.Currency.Entities.FileIteration topLevelAssembly) { // download the latest version of the assembly to working folders VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(m_conn); settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true; settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = true; settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest; settings.AddFileToAcquire(topLevelAssembly, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
VDF.Vault.Results.AcquireFilesResults results = m_conn.FileManager.AcquireFiles(settings); }
public void DownloadDialog(VDF.Vault.Currency.Entities.FileIteration fileIter, IntPtr parentWindowHandle) { // pop up the Get/Checkout dialog VDF.Vault.Forms.Settings.InteractiveAcquireFileSettings settings = new VDF.Vault.Forms.Settings.InteractiveAcquireFileSettings( m_conn, parentWindowHandle, "Download files"); settings.AddEntityToAcquire(fileIter);
VDF.Vault.Forms.Library.AcquireFiles(settings); } |
|
' VB Imports VDF = Autodesk.DataManagement.Client.Framework
Public Sub DownlodFiles(fileIters As ICollection(Of VDF.Vault.Currency.Entities.FileIteration)) ' download individual files to a temp location Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(m_conn) settings.LocalPath = New VDF.Currency.FolderPathAbsolute("c:\temp") For Each fileIter As VDF.Vault.Currency.Entities.FileIteration In fileIters settings.AddFileToAcquire(fileIter, _ _ VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download) Next
Dim results As VDF.Vault.Results.AcquireFilesResults = _ m_conn.FileManager.AcquireFiles(settings) End Sub
Public Sub DownloadAssembly(topLevelAssembly As VDF.Vault.Currency.Entities.FileIteration) ' download the latest version of the assembly to working folders Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(m_conn) settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = True settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = True settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = _ VDF.Vault.Currency.VersionGatheringOption.Latest settings.AddFileToAcquire(topLevelAssembly, _ VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Dim results As VDF.Vault.Results.AcquireFilesResults = _ m_conn.FileManager.AcquireFiles(settings) End Sub
Public Sub DownloadDialog(fileIter As VDF.Vault.Currency.Entities.FileIteration, _ parentWindowHandle As IntPtr) ' pop up the Get/Checkout dialog Dim settings As New VDF.Vault.Forms.Settings.InteractiveAcquireFileSettings( _ m_conn, parentWindowHandle, "Download files") settings.AddEntityToAcquire(fileIter)
VDF.Vault.Forms.Library.AcquireFiles(settings) End Sub |


Leave a Reply to Hamid TalebiCancel reply