How to check if User has latest version for .iLogicvb file in Vault?

How to check if User has latest version for .iLogicvb file in Vault?

machiel.veldkamp
Collaborator Collaborator
115 Views
1 Reply
Message 1 of 2

How to check if User has latest version for .iLogicvb file in Vault?

machiel.veldkamp
Collaborator
Collaborator

Hi!

I'm debugging some stuff. Turns out; some user doesn't have the latest version of the iLogic Rule he uses. 

 

I'm looking to get some snippet where I can get a boolean out or a local version number I can compare to the Vault version. 

 

This is what I have now:


' Function that returns the property value for any Vault File (input is "C:/....../file.ext")

 

Function VaultProperty(oPropertyName As String, FullFileName As String)
		VaultPath = FullFileName.Replace("C:\Workspace\", "$/")
		VaultPath = VaultPath.Replace("\", "/")

		Dim VaultPaths() As String = New String() {VaultPath }
		Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)

		'Ts file exists in the Vault. 
		Dim FileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, wsFiels(0))
		If (PropDefDict.TryGetValue(oPropertyName, definition))
			oPropertyValue = mVltCon.PropertyManager.GetPropertyValue(FileIt, definition, Nothing)
		End If
		Return oPropertyValue
End Function

 

You need to declare some stuff in the header and class:

In header

Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports AWS = Autodesk.Connectivity.WebServices
Imports VB = Connectivity.Application.VaultBase
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties
AddReference "Connectivity.Application.VaultBase.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault"

 

in class: 

	Shared Dim mVltCon As VDF.Vault.Currency.Connections.Connection
	Shared Dim PropDefDict As PropertyDefinitionDictionary
	Private vaultAddinID As String = "{48B682BC-42E6-4953-84C5-3D253B52E77B}"
	Private vaultAddin As ApplicationAddIn

 

In Main()

 

mVltCon = VB.ConnectionManager.Instance.Connection
PropDefDict = mVltCon.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, Nothing, PropertyDefinitionFilter.IncludeAll)
iLogicRuleFile = "C:\Workspace\...\File.iLogicVb"
oVersionNumber = (VaultProperty("VersionNumber",iLogicRuleFile))

 

 Any tips on how to get the local version number OR any other way to see if the file is out of date?

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
Accepted solutions (1)
116 Views
1 Reply
Reply (1)
Message 2 of 2

machiel.veldkamp
Collaborator
Collaborator
Accepted solution

Found some stuff. Here's the result.

 

Function VaultFileIsUpToDate(FullFileName As String)
		'Returns TRUE is up to date; returns false if NOT up-to-date OR not in Vault
		
		'Get dict Of all 'local' file properties
		Dim props As VDF.Vault.Currency.Properties.PropertyDefinitionDictionary = _
		mVltCon.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, Nothing, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll)
		
		'get file status property
		Dim statusprop As VDF.Vault.Currency.Properties.PropertyDefinition = props(VDF.Vault.Currency.Properties.PropertyDefinitionIds.Client.VaultStatus)
		'convert computer file path To a vault path
		'may vary on how user's vault is configured
		Dim vaultPath() As String = {FullFileName.Replace("C:\Workspace\", "$/").Replace("\", "/")}

		'search for the file
		Dim wsFiles() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(vaultPath)

		'theoretically, there can only ever be one file that matches this file path....
		If wsFiles IsNot Nothing AndAlso wsFiles.Count = 1 AndAlso wsFiles.First.Name IsNot Nothing Then
			
			'convert vault server file to vault local file
			Dim mFileIt As New VDF.Vault.Currency.Entities.FileIteration(mVltCon, wsFiles(0))
			
			'get the vault local status of the file.
			Dim status As VDF.Vault.Currency.Properties.EntityStatusImageInfo = mVltCon.PropertyManager.GetPropertyValue(mFileIt, statusprop, Nothing)
				
			If status IsNot Nothing Then
				'check a couple values
				Dim localedits As Boolean 				= status.Status.LocalEditsState 	= VDF.Vault.Currency.Properties.EntityStatus.LocalEditsStateEnum.HasLocalEdits
				Dim MatchesOlderVersion As Boolean 		= status.Status.VersionState 		= VDF.Vault.Currency.Properties.EntityStatus.VersionStateEnum.MatchesOlderVaultVersion
				Dim matcheslatestversion As Boolean 	= status.Status.VersionState 		= VDF.Vault.Currency.Properties.EntityStatus.VersionStateEnum.MatchesLatestVaultVersion
				Dim checkedoutcurrentuser As Boolean 	= status.Status.CheckoutState 		= VDF.Vault.Currency.Properties.EntityStatus.CheckoutStateEnum.CheckedOutByCurrentUser
				Dim MatchesNoVaultVersion As Boolean 	= status.Status.VersionState 		= VDF.Vault.Currency.Properties.EntityStatus.VersionStateEnum.MatchesNoVaultVersion
				
				'status.Status.VersionState = VDF.Vault.Currency.Properties.
				'do something with the values
                If matcheslatestversion 
					Return True
				Else
					Return False
				End If
				
				If MatchesOlderVersion Then Return False
				
				'display all of the proerties at once.
'				MsgBox( _
'				"localedits = " & localedits & vbNewLine & _
'				"checkedoutcurrentuser = " & checkedoutcurrentuser & vbNewLine & _
'				"matcheslatestversion = " & matcheslatestversion & vbNewLine & _
'				"MatchesOlderVersion = " & MatchesOlderVersion & vbNewLine & _
'				"MatchesNoVaultVersion = " & MatchesNoVaultVersion & vbNewLine _
'				)
			End If
		Else
			Return False
		End If
	End Function

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes