Getting the vault status of a Non-Autodesk File with iLogic, and update local file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am after the help of the experts and users here.
We have a lot (over 40,000) Solid Edge files, that we have placed vault and starting to migrate over to Inventor for our CAD software. There is not a Vault Add-in for SE, so it does not tell you when your local copy is out of date...
However, there will be situations that we will need to modify the SE data. when the SE data is checked out, modified and checked in, there is nothing (That we know of) that will tell all the other users that the SE file has been modified. the only thing I can find that shows the file is out of date, is the 2 red arrows on the Vault Status icon.
Ideally, I would like to create a search in Vault, and then filter the Vault Status to only show the files that are out of date. Nope, apparently you cannot filter on the Vault status, or do Autodesk deem it not essential and are not looking into the feature... This has shocked me as every other engineer I have worked with who uses vault, always says how do it check my workspace for out of date files.... this is a different subject that I am raising with Autodesk through other means....
Back on Topic...
Has anyone been able to use iLogic to search non-Autodesk files and get their status from Vault? this is the process I am thinking of:
1. Search a Directory & sub Directories for parts with file extension *.par
2. Check the Vault Status of each file, and if out of date get the latest copy
This sounds like a very simple process but I cannot get it to work.
Has anyone been able to do this successfully?
Below is the code I have created, but I cannot get it to get the vault status for the files. Hopefully it is something very simple...
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
AddReference "QuickstartiLogicLibrary.dll"
Imports VB = Connectivity.Application.VaultBase
Imports System.Diagnostics
Class ThisRule
Private oVaultState1 As String = "CheckOutState"
Private oVaultState2 As String = "ConsumableState"
Private oVaultState3 As String = "ErrorState"
Private oVaultState4 As String = "LocalEditsState"
Private oVaultState5 As String = "LockState"
Private oVaultState6 As String = "RevisionState"
Private oVaultState7 As String = "VersionState"
Private oVaultState8 As String = "NotCheckedOut"
Sub Main
'[ ********** Check if Connected to Vault **********
Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MessageBox.Show("Not Logged In to Vault! - Login first and repeat executing this rule.")
Exit Sub
End If
']
Dim processPath As String = "C:\Vault Working Folder\CAD Data\"
Dim TxtFileName As String = processPath & "Files_Found.txt"
Dim Folder As New IO.DirectoryInfo(processPath)
Dim MyFile As String
Dim MyLocalFile As String
Dim VaultPath As String
Dim FileCount As Integer = IO.Directory.GetFiles(processPath, "*.ipt", IO.SearchOption.AllDirectories).Length
Dim FileExt As String = ".ipt"
Dim TxtFileText As String = processPath
WritetoFile(TxtFileName, TxtFileText, False)
Dim mDocVaultStatus As Dictionary(Of String, String)
'[ 'Check local path for .par files...
For Each File As IO.FileInfo In Folder.GetFiles("*" & FileExt, IO.SearchOption.AllDirectories)
MyFile = File.fullname
VaultPath = MyFile
VaultPath = VaultPath.Replace("C:\Vault Working Folder\", "$/")
'flip the slashes
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath }
Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn, wsFiels(0))
Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileRevisionInfo
MyLocalFile = GetVaultFileStatus(MyFile)
'If MyLocalFile = False Then
TxtFileText = MyFile & " | " & MyLocalFile
WritetoFile(TxtFileName, TxtFileText, True)
'GetFileFromVault(VaultPath)
'End If
Next
']
MessageBox.Show("Done")
End Sub
Private Sub WritetoFile(TxtFileName As String, TextToAdd As String, Optional ByVal AppendToFile As Boolean = True)
'Dim dateString = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")
'Dim TxtFileName As String = ThisDoc.PathAndFileName(False) & "_" & dateString & ".txt"
If AppendToFile = True Then
'____Open and append to an existing text file_______
Dim oAppend As System.IO.StreamWriter
'oFile = TxtFileName
oAppend = IO.File.AppendText(TxtFileName)
oAppend.WriteLine(TextToAdd)
oAppend.Flush()
oAppend.Close()
Else
'____Create and write to a text file_________________
oWrite = System.IO.File.CreateText(TxtFileName)
oWrite.WriteLine(TextToAdd)
'oWrite.WriteLine("File Created on " & DateString)
oWrite.WriteLine("")
oWrite.Close()
End If
End Sub
Public Function GetVaultFileStatus(LocalFullFileName As String) As String
Dim mDocVaultStatus As Dictionary(Of String, String)
mDocVaultStatus = iLogicVault.GetVaultFileStatus(LocalFullFileName)
If mDocVaultStatus.Item(oVaultState1) = oVaultState1 Then
GetVaultFileStatus = oVaultState1
End If
If mDocVaultStatus.Item(oVaultState2) = oVaultState2
GetVaultFileStatus = oVaultState2
End If
If mDocVaultStatus.Item(oVaultState3) = oVaultState3
GetVaultFileStatus = oVaultState3
End If
If mDocVaultStatus.Item(oVaultState4) = oVaultState4
GetVaultFileStatus = oVaultState4
End If
If mDocVaultStatus.Item(oVaultState5) = oVaultState5
GetVaultFileStatus = oVaultState5
End If
If mDocVaultStatus.Item(oVaultState6) = oVaultState6
GetVaultFileStatus = oVaultState6
End If
If mDocVaultStatus.Item(oVaultState7) = oVaultState7
GetVaultFileStatus = oVaultState7
Else
GetVaultFileStatus = "Other"
End If
' This code gives you the values of the Status,
' For Each kvp As KeyValuePair(Of String, String) In mDocVaultStatus
' Dim v1 As String = kvp.Key
' Dim v2 As String = kvp.Value
' Trace.WriteLine("iLogic: " + v1 + " Value: " + v2)
' Next
End Function
End Class
Any help or guidance would be greatly appreciated.