I made a iLogic Version Checker for my colleagues.

I made a iLogic Version Checker for my colleagues.

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

I made a iLogic Version Checker for my colleagues.

machiel.veldkamp
Collaborator
Collaborator

Hi, 

 

maybe you're in the same boat as I am. Make tools for at the office; everyone ends up using them. 

 

I usually change some things in tools once every few weeks. Bug fixes, new features... you know. 

 

Some colleagues tho... they don't check the Vault for new versions. EVER.

 

 

INTRODUCING NOW. THE iLOGIC VERSION CHECKERRRRR

 

Just make a folder somewhere on you companies' network disk and make a textfile with the current versionnumber! 

 

Include the iLogic sippet in your custom rule and... voila! You colleagues will get the message and the tool won't run until they GET the new version from the vault. 

 

🙂

 

 

VersionFolder = "G:\Folder\01 iLOGIC VERSIONS"	'Make Folder Somewhere with Textfiles
iLogicName = "ExactNameOfYourTool" 				'Name of the Current 
Dim ExpectedVersion As Integer = 1
oFile = VersionFolder & "\" & iLogicName & ".txt"

'read the file
oRead = System.IO.File.OpenText(oFile)
Dim FileVersion As Integer = oRead.ReadToEnd()
oRead.Close()


If FileVersion = ExpectedVersion Then
	Trace.WriteLine(FileVersion & " Version is correct.")
Else
	MessageBox.Show("Expected Version: " & FileVersion & vbNewLine &  " Current Version on your PC: " & ExpectedVersion,  "OLD VERSION. DO GET FROM VAULT")
	exit Sub
End If

 

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

___________________________
641 Views
1 Reply
Reply (1)
Message 2 of 2

AlexFielder
Advisor
Advisor

Depending on the version of Vault you're running, you could in theory have iLogic get the relevant file for you. 

This rule I wrote a while back needs Vault Professional/Workgroup for access to the API and takes a ruleargument called "filename" to get it working. It also makes use of Windows Authentication for logging into the vault, so if you aren't using that you will need to tinker:

 

AddReference "Autodesk.Connectivity.WebServices"
AddReference "Autodesk.DataManagement.Client.Framework.Forms"
AddReference "Autodesk.DataManagement.Client.Framework.Vault"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.Forms"

Imports ACW = Autodesk.Connectivity.WebServices
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports Autodesk.DataManagement.Client.Framework.Vault.Services
Imports Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections
'''
''' Copied from this thread: https://forums.autodesk.com/t5/vault-customization/vault-login-vb-net/m-p/7735557#M5944
'''
Sub Main()
	If Not RuleArguments.Exists("filename") Then 'no filename was passed to the rule!
		MessageBox.Show("We can't do this without a filename to search for/check-out!")
	Else
		Dim filename As String = RuleArguments.Value("filename")
		Dim Connection As VDF.Vault.Currency.Connections.Connection = Nothing
	 '  Download file
		Try
			Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("localhost", "Vault", "", "", AuthenticationFlags.WindowsAuthentication, Nothing)
	        Connection = results.Connection


	            Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
				Dim oFile As ACW.File = Nothing
				
	            Try
					
					oFile = FindVaultFileByFileName(Connection, filename)
					
					If oFile IsNot Nothing Then
					
						oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(Connection, oFile)
					
					End If
					
	            Catch ex As Exception
	                MsgBox("File can't be found.")
	            End Try

	            If oFileIteration IsNot Nothing Then
	                'get settings
	                Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(Connection)
					If Not oFileIteration.IsCheckedOut Then
	                	oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout 'VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download
					End If
	                oSettings.AddEntityToAcquire(oFileIteration)
	                Dim myAcquiredFilesResults As VDF.Vault.Results.AcquireFilesResults = Connection.FileManager.AcquireFiles(oSettings)
					If myAcquiredFilesResults.FileResults.First().Status = VDF.Vault.Results.FileAcquisitionResult.AcquisitionStatus.Success Then
	                	Logger.Info("File: " & filename & " successfully checked out")
					End If
	            End If

		Catch ex As Exception
	            MsgBox("File can't be donwloaded. Maybe it's currently opened.")
		Finally
	            VDF.Vault.Library.ConnectionManager.LogOut(Connection)
		End Try
	End If
End Sub

Private Function FindVaultFileByFileName(Connection As VDF.Vault.Currency.Connections.Connection, filename As String) As ACW.File

    Dim result As ACW.File = Nothing

    Dim filePropDefs As ACW.PropDef() = Connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
    Dim fileNamePropDef As ACW.PropDef = filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")

    ' is equal
    Dim fileNameMatch As New ACW.SrchCond()
    fileNameMatch.PropDefId = fileNamePropDef.Id
    fileNameMatch.PropTyp = ACW.PropertySearchType.SingleProperty
    fileNameMatch.SrchOper = 3
    fileNameMatch.SrchRule = ACW.SearchRuleType.Must
    fileNameMatch.SrchTxt = filename

    Dim bookmark As String = String.Empty
    Dim searchStatus As ACW.SrchStatus = Nothing
    Dim searchResults As ACW.File() = Connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {fileNameMatch}, Nothing, Nothing, False, True, bookmark, searchStatus)

    If searchResults IsNot Nothing Then
        If searchResults.Length > 0 Then
           result = searchResults(0)
        End If
    End If

    Return result

End Function