Message 1 of 4
Query if parts has already been retrieved in Vault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi dear community,
And again a problem:D
The goal is to reverse the code below so that it compares the local folder with the one in the Vault and sees if and which files have not yet been retrieved from the Vault.
The code now works the other way around.
I hope you can help me
Thanks a lot
Imports System Imports System.IO Imports System.Text Imports ACW = Autodesk.Connectivity.WebServices Imports VDF = Autodesk.DataManagement.Client.Framework Imports VB = Connectivity.Application.VaultBase AddReference "Autodesk.Connectivity.WebServices.dll" AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll" AddReference "Connectivity.Application.VaultBase.dll"
Class LocalWorkspaceCheck Shared FileTypes As New List(Of String) From {".ipt", ".iam", ".dwg", ".ipn", ".xlsx"} Shared LocalWorkspace As String = "C:\your local vault" Sub Main Dim starttime As DateTime = Now Dim mVltCon As VDF.Vault.Currency.Connections.Connection mVltCon = VB.ConnectionManager.Instance.Connection If mVltCon Is Nothing Then MessageBox.Show("You MUST be logged in to Vault to perform this action.", "Not Logged", MessageBoxButtons.OK , MessageBoxIcon.Information) Exit Sub End If PresentNonVaultFiles() MsgBox("timer 1 " & Now.Subtract(starttime).TotalSeconds.ToString("0.00")) End Sub Sub PresentNonVaultFiles() Dim SearchLocation As String = LocalWorkspace Dim filelist As New List(Of String) Call GetListOfNonVaultFiles(SearchLocation, filelist) If filelist.Count > 0 Then i = MessageBox.Show(filelist.Count & " file(s) found. These are files that may NOT exist in Vault. Please check one by one to make sure they don't exist in Vault." & vbLf & vbLf & _ " Would you like to see the files?", _ "Non-Vault Files",MessageBoxButtons.YesNo,MessageBoxIcon.Question) If i = vbNo Then Return End If Else MessageBox.Show("No files found", "Non-Vault Files", MessageBoxButtons.OK , MessageBoxIcon.Information) Return End If Dim fileListAsString As String = String.Join(System.Environment.NewLine, filelist.ToArray()) Dim textFile As String = LocalWorkspace & "NonVaultFiles.txt" My.Computer.FileSystem.WriteAllText(textFile, fileListAsString, False) System.Diagnostics.Process.Start(textFile) MessageBox.Show("The file was created in the following directory: " & LocalWorkspace & "NonVaultFiles.txt", "File Created", MessageBoxButtons.OK , MessageBoxIcon.Information) End Sub Sub GetListOfNonVaultFiles(ByVal SearchLocation As String, ByRef filelist As List(Of String)) For Each file As String In Directory.GetFiles(SearchLocation) Dim attributes = IO.File.GetAttributes(File) If (FileTypes.Contains(IO.Path.GetExtension(File))) Then If ((attributes And FileAttributes.ReadOnly) <> FileAttributes.ReadOnly) Then If (Search_Vault_by_FilePath(File, LocalWorkspace) Is Nothing) Then filelist.Add(File) End If End If Next For Each dir As String In Directory.GetDirectories(SearchLocation) If (Right(Dir,2) <> "_V") And Not Dir.Contains("OldVersions") Then GetListOfNonVaultFiles(Dir, filelist) End If Next End Sub Function Search_Vault_by_FilePath(filePath As String, LocalWorkspace As String) As ACW.File() Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection If mVltCon Is Nothing Then Return Nothing Dim VaultPath As String = filePath.Replace(LocalWorkspace, "$/").Replace("\", "/") MessageBox.Show("Vault",VaultPath) Dim Results As ACW.File() = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(New String() {VaultPath}) If (Results(0).Id = -1) Then Return Nothing Return Results End Function End Class