Vault API - after renaming files the links are broken

Vault API - after renaming files the links are broken

Anonymous
Not applicable
611 Views
2 Replies
Message 1 of 3

Vault API - after renaming files the links are broken

Anonymous
Not applicable

I have renamed files in vault with this code (obtained here). But now the links are broken. What I have missed and is it possible to create the lost links again?

 

File checkedOutNewFile = CheckOut(folders[0], selectedFile);

if (checkedOutNewFile != null)

{

CheckIn(folders[0], checkedOutNewFile, newname, Coment);

}

 

public File CheckOut(Folder folder, File file)

{

string localPath = _connection.WorkingFoldersManager.GetWorkingFolder(folder.FullName).FullPath;

if (!System.IO.Directory.Exists(localPath))

System.IO.Directory.CreateDirectory(localPath);

AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(_connection);

settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = Autodesk.DataManagement.Client.Framework.Vault.Currency.VersionGatheringOption.Latest;

settings.OptionsResolution.OverwriteOption = AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.ForceOverwriteAll;

settings.LocalPath = new VDF.Currency.FolderPathAbsolute(localPath);

settings.AddFileToAcquire(

new VDF.Vault.Currency.Entities.FileIteration(_connection, file),

VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download | VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout);

VDF.Vault.Results.AcquireFilesResults result = _connection.FileManager.AcquireFiles(settings);

foreach (var r in result.FileResults)

{

 

return m_serviceManager.DocumentService.GetFileById(r.File.EntityIterationId);

 

}

public File CheckIn(Folder folder, File file, string newname,string comm)

{

string localPath = _connection.WorkingFoldersManager.GetWorkingFolder(folder.FullName).FullPath;

string filePath = System.IO.Path.Combine(localPath, file.Name);

VDF.Vault.Currency.Entities.FileIteration ff = _connection.FileManager.CheckinFile(

new VDF.Vault.Currency.Entities.FileIteration(_connection, file), comm, false, null, null,

true, newname, file.FileClass, false,

new VDF.Currency.FilePathAbsolute(filePath));

 

 

return m_serviceManager.DocumentService.GetFileById(ff.EntityIterationId);

 

 

}

0 Likes
612 Views
2 Replies
Replies (2)
Message 2 of 3

orbjeff
Advocate
Advocate

Hi there,

 

The fourth parameter in your "CheckinFile" method is the associations array. In your code you are defining this parameter as null (no references/links) which is why your files no longer have the links. You need to capture the association array from the checked out file and use it when checking the file back in.

 

I had this problem a few years ago and while there may be other options with the new Vault API the idea is still the same. See here:

 

http://forums.autodesk.com/t5/vault-customization/maintaining-existing-file-attachments-after-checki...

 

It's not something that is easily fixed to my knowledge so hopefully you discovered this on a development Vault. 

Jeff Johnson
Technical Consultant
MasterGraphics Inc.
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you, Jeff.

0 Likes