How can i get version of local file via API?

How can i get version of local file via API?

Anonymous
Not applicable
3,730 Views
9 Replies
Message 1 of 10

How can i get version of local file via API?

Anonymous
Not applicable

Hi, I can see (Local=Version##) in Vault 2017 Pro client. How can i get this version via Vault API? Many thanks.

0 Likes
Accepted solutions (1)
3,731 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Would the GetFileByVersion command in the document service class work? I'll be honest, I've never tried it, but a quick glance makes me think this will help you

 

Hope it does,

Dave 

0 Likes
Message 3 of 10

psaarloos
Collaborator
Collaborator
Accepted solution

Hi,

 

You can get the EntityStatus of a file using the code below. That would allow you to check the local version compared to the vaulted version (ex.. MatchesLatestVaultVersion, MatchesOlderVaultVersion,etc). It doesn't tell you which version it is however. But, in the case this check returns 'MatchesOlderVaultVersion', you could get all the versions of a file by using GetFilesByMasterId, create a FileIteraction for each file version and verify the Checksum property of each FileIteration against the checksum of the file on disk..I hope this workflow works for you!

 

FileIteration fileIteration = new FileIteration(_connection, file);
FilePathAbsolute filePath = _connection.WorkingFoldersManager.GetPathOfFileInWorkingFolder(fileIteration);

PropertyDefinition propDef = _connection.PropertyManager.GetPropertyDefinitionBySystemName(Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.PropertyDefinitionIds.Client.VaultStatus);
var propValue = _connection.PropertyManager.GetPropertyValue(fileIteration, propDef, null);
EntityStatusImageInfo statusInfo = propValue as EntityStatusImageInfo;

 

 

 

 

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
Message 4 of 10

Anonymous
Not applicable

Thank you Dave,

GetFileByVersion needs versionNumber as a parameter. My wish is straight opposite - to get this version, something like
int GetLocalFileVersion(string fileName) that would return the file version number. As Vault client can show this version, I assumed that I can ask this number.

0 Likes
Message 5 of 10

Anonymous
Not applicable

Thank you Pim for good example.

My thought was if Vault have done all the stuff needed to identify version of local file (you could see the picture I've attached to the question) so i can just ask Vault Client to give this number and do not mess with checksums etc.

 

0 Likes
Message 6 of 10

psaarloos
Collaborator
Collaborator

Hi,

 

I see your point, but my guess is that the History tab uses this kind of functionality to calculate the local file version. The API can't 'ask' the server through a web service call, because it's a calculation that can have different results on different clients.

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
Message 7 of 10

Anonymous
Not applicable

Ah, I see where I misunderstood your question.

 

After reading through the subsequent discussion, I am wondering if there is some way to map the version number property from Vault into an Inventor Property (would have to be a custom property, I assume). Then, it's just inherently in the local file at all times and Vault maintains the link. Is that possible?

0 Likes
Message 8 of 10

Anonymous
Not applicable

Hi Pim,

Thank you for following the question.

Having "different results on different clients" is exactly the thing I need. My hope was based on the explanation has VDF is working to get file statuses, it needs client-specific information about the file. If Autodesk.DataManagement.* can get client-side properties, there could be a way to get this client-file version via VDF to. And as I can see - it's not possible. Yet 🙂 Possibly, i should send this idea to Vault developers.

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hi Dave,

sorry for my explanation.

Thank you for the idea. I've checked two versions of the same file - they are binary identical. So i hardly believe version is written in the file. Disappointing.

0 Likes
Message 10 of 10

awatt
Advocate
Advocate

Sow how does the inventor add-in determine version number? Does it do a pattern match against file modify date, file size, etc?  Is there a defined list of properties it searches?

0 Likes