List of Checked out files

List of Checked out files

GrahamB8
Contributor Contributor
1,668 Views
5 Replies
Message 1 of 6

List of Checked out files

GrahamB8
Contributor
Contributor

Hi all,

 

Ive just started looking at doing some basic API work and wanted to make a form which will return a list of checked out files including the users that have them checked out. Sure I can do this with an advanced search filter but I want to eventually extend this to encoumpass multiple Vaults.

 

I have watched a few of Dougs videos and have successfully logged into one of our servers and returned a list of the documents to a basic list box.

I now want to build on this to return only checked out files and the user names that have them checked out.

 

Can anyone point me in the right direction for more literature that can help me, I have found the 'IsCheckedOut' Property in the Vault SDK .chm file but apart from being discriptive theres no examples of its used for amatures like myself.

 

Ive wrote a few very basic C# and VB.net standalone applications.

 

Cheers

G

0 Likes
Accepted solutions (1)
1,669 Views
5 Replies
Replies (5)
Message 2 of 6

GrahamB8
Contributor
Contributor
Imports Autodesk.Connectivity.WebServices
Imports Autodesk.Connectivity.WebServicesTools

Public Class Form1

    Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim cred As New UserPasswordCredentials("Servername", "Vault", "User", "Password")

        Using mgr As New WebServiceManager(cred)
            'Dim root As Folder = mgr.DocumentService.GetFolderRoot()
            'PrintFolder(root, mgr)

            Dim filePropDefs As PropDef() = _
                 mgr.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
            Dim checkedOutPropDef As PropDef = _
                filePropDefs.[Single](Function(n) n.SysName = "CheckoutUserName")
            ' SrchOper 5 => is not empty
            Dim isCheckedOut As New SrchCond() With { _
                   .PropDefId = checkedOutPropDef.Id, _
                   .PropTyp = PropertySearchType.SingleProperty, _
                   .SrchOper = 5, _
                   .SrchRule = SearchRuleType.Must _
            }

            Dim bookmark As String = String.Empty
            Dim status As SrchStatus = Nothing
            Dim totalResults As New List(Of File)()
            While status Is Nothing OrElse totalResults.Count < status.TotalHits

                Dim results As File() = _
                   mgr.DocumentService.FindFilesBySearchConditions( _
                    New SrchCond() {isCheckedOut}, _
                    Nothing, Nothing, False, True, bookmark, _
                       status)

                If results IsNot Nothing Then
                    totalResults.AddRange(results)
                    ListBox1.Items.AddRange(results)
                Else
                    Exit While
                End If
            End While
        End Using
    End Sub
End Class

This is where I have got to but the results in my List box are:

 

"Autodesk.Connectivity.WebServices.File"

 

Capture.JPG

0 Likes
Message 3 of 6

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi,

 

Below is an update to your code. It has a new For Each loop that adds the Name of the file and the name of the user who has it checked out to a list box.

 

It uses the Name property of the File and GetProperties with the File.Id and PropDef.Id to get the to the users name. (I tested using the VaultList SDK sample)

 

 

 

   While status Is Nothing OrElse totalResults.Count < status.TotalHits

                Dim results As File() = _
                   mgr.DocumentService.FindFilesBySearchConditions( _
                    New SrchCond() {isCheckedOut}, _
                    Nothing, Nothing, False, True, bookmark, _
                       status)

                If results IsNot Nothing Then
                    totalResults.AddRange(results)
                    'WB commented
                    'ListBox1.Items.AddRange(results)                  
                Else '()
                    Exit While
                End If
            End While
           

            'WB added
            Dim _File As File
            For Each _File In totalResults

                Dim propValues() As PropInst = mgr.PropertyService.GetProperties("FILE", New Long() {_File.Id}, New Long() {checkedOutPropDef.Id})
                Dim _CheckoutUserName As String = propValues(0).Val
               

                Me.m_listBox.Items.Add(_File.Name & "  " & "Checked out by" & "  " & _CheckoutUserName)

            Next

        End Using
    End Sub

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 4 of 6

GrahamB8
Contributor
Contributor

Thanks Wayne that was perfect!

0 Likes
Message 5 of 6

ktelangCGFU6
Participant
Participant

The Serveridentity cannot be a string in usercredentials in new vault api . How to define serveridentity. I typically use VDF login to pass the user credentials. I am having tough time using that approach. can any body help

0 Likes
Message 6 of 6

Markus.Koechl
Autodesk
Autodesk

The ServerIdentities class has two properties of type System.String: DataServer and FileServer. No change in the latest API.
You might leverage the API-Onboarding-ConsoleApp template in the SDK to get the full code for a WebService login.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes