<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I made a iLogic Version Checker for my colleagues. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/i-made-a-ilogic-version-checker-for-my-colleagues/m-p/8553853#M79682</link>
    <description>&lt;P&gt;Depending on the version of Vault you're running, you could in theory have iLogic get the relevant file for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This &lt;A title=" Linked in case I update it!" href="https://github.com/AlexFielder/iLogic/blob/master/Helper%20Rules/Checkout%20Requested%20File%20From%20Vault.iLogicVb" target="_blank" rel="noopener"&gt;rule I wrote&lt;/A&gt; 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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;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: " &amp;amp; filename &amp;amp; " 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 &amp;gt; 0 Then
           result = searchResults(0)
        End If
    End If

    Return result

End Function
&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Jan 2019 10:27:20 GMT</pubDate>
    <dc:creator>AlexFielder</dc:creator>
    <dc:date>2019-01-28T10:27:20Z</dc:date>
    <item>
      <title>I made a iLogic Version Checker for my colleagues.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/i-made-a-ilogic-version-checker-for-my-colleagues/m-p/8553621#M79681</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;maybe you're in the same boat as I am. Make tools for at the office; everyone ends up using them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually change some things in tools once every few weeks. Bug fixes, new features... you know.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some colleagues tho... they don't check the Vault for new versions. EVER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;INTRODUCING NOW. THE iLOGIC VERSION CHECKERRRRR&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just make a folder somewhere on you companies' network disk and make a textfile with the current versionnumber!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;VersionFolder = "G:\Folder\01 iLOGIC VERSIONS"	'Make Folder Somewhere with Textfiles
iLogicName = "ExactNameOfYourTool" 				'Name of the Current 
Dim ExpectedVersion As Integer = 1
oFile = VersionFolder &amp;amp; "\" &amp;amp; iLogicName &amp;amp; ".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 &amp;amp; " Version is correct.")
Else
	MessageBox.Show("Expected Version: " &amp;amp; FileVersion &amp;amp; vbNewLine &amp;amp;  " Current Version on your PC: " &amp;amp; ExpectedVersion,  "OLD VERSION. DO GET FROM VAULT")
	exit Sub
End If&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 08:37:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/i-made-a-ilogic-version-checker-for-my-colleagues/m-p/8553621#M79681</guid>
      <dc:creator>machiel.veldkamp</dc:creator>
      <dc:date>2019-01-28T08:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: I made a iLogic Version Checker for my colleagues.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/i-made-a-ilogic-version-checker-for-my-colleagues/m-p/8553853#M79682</link>
      <description>&lt;P&gt;Depending on the version of Vault you're running, you could in theory have iLogic get the relevant file for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This &lt;A title=" Linked in case I update it!" href="https://github.com/AlexFielder/iLogic/blob/master/Helper%20Rules/Checkout%20Requested%20File%20From%20Vault.iLogicVb" target="_blank" rel="noopener"&gt;rule I wrote&lt;/A&gt; 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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;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: " &amp;amp; filename &amp;amp; " 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 &amp;gt; 0 Then
           result = searchResults(0)
        End If
    End If

    Return result

End Function
&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Jan 2019 10:27:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/i-made-a-ilogic-version-checker-for-my-colleagues/m-p/8553853#M79682</guid>
      <dc:creator>AlexFielder</dc:creator>
      <dc:date>2019-01-28T10:27:20Z</dc:date>
    </item>
  </channel>
</rss>

