Vault Customization

Vault Customization

Reply
Valued Contributor kbo
Valued Contributor
kbo
Posts: 91
Registered: ‎08-18-2010
Message 1 of 4 (468 Views)
Accepted Solution

How to read systemproperty Provider from File in vault professional

468 Views, 3 Replies
06-06-2012 05:44 AM

We use dwg fore both Autocad and inventor 2D drawings. I run a program that checks the lifecycle state on files with extension ".dwg" and release these files if the state isnt "Released". The problem is that i want to filter out ".dwg" files where the system property Provider equals "Inventor DWG".

 

I know how to get the the master iDs of the files, but how do i read the "provider" property from these files to check if the file is a Autocad or Inventor dwg.

 

Please help with a little code example i vb.net

 

regards Kent Bøttger  

Hello Kent,

 

You can read the Provider property just like reading other file properties in Vault. You can use the PropertyService.GetProperties() method, passing in the property id's of the property values you want and the file id's of the files you want to get the properties from. Here is a brief code sample:

 

 Using wsManager As New WebServiceManager(New UserPasswordCredentials("localhost", "Vault", "Administrator", ""))

     Dim file As File = wsManager.DocumentService.GetLatestFilePathsByNames(New String() {"Drawing1.dwg"}).First().FilePaths.First().File

     Dim providerPropDef As PropDef = wsManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(Function(propDef) propDef.SysName.Equals("Provider"))

     Dim providerPropInst As PropInst = wsManager.PropertyService.GetProperties("FILE", New Long() {file.Id}, New Long() {providerPropDef.Id}).First()

     Dim providerString As String = TryCast(providerPropInst.Val, String)
End Using

The code above doesn't perform any error checking and uses some hard-coded values you'll probably want to change, but it should be enough to get you started. More information on the PropertyService and the methods it provides can be found in the SDK documenation, as well.

 

Regards

Employee
Daniel.Dulzo
Posts: 61
Registered: ‎05-25-2011
Message 2 of 4 (468 Views)

Re: How to read systemproperty Provider from File in vault professional

06-06-2012 10:32 AM in reply to: kbo

Hello Kent,

 

You can read the Provider property just like reading other file properties in Vault. You can use the PropertyService.GetProperties() method, passing in the property id's of the property values you want and the file id's of the files you want to get the properties from. Here is a brief code sample:

 

 Using wsManager As New WebServiceManager(New UserPasswordCredentials("localhost", "Vault", "Administrator", ""))

     Dim file As File = wsManager.DocumentService.GetLatestFilePathsByNames(New String() {"Drawing1.dwg"}).First().FilePaths.First().File

     Dim providerPropDef As PropDef = wsManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(Function(propDef) propDef.SysName.Equals("Provider"))

     Dim providerPropInst As PropInst = wsManager.PropertyService.GetProperties("FILE", New Long() {file.Id}, New Long() {providerPropDef.Id}).First()

     Dim providerString As String = TryCast(providerPropInst.Val, String)
End Using

The code above doesn't perform any error checking and uses some hard-coded values you'll probably want to change, but it should be enough to get you started. More information on the PropertyService and the methods it provides can be found in the SDK documenation, as well.

 

Regards



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Valued Contributor kbo
Valued Contributor
kbo
Posts: 91
Registered: ‎08-18-2010
Message 3 of 4 (462 Views)

Re: How to read systemproperty Provider from File in vault professional

06-07-2012 04:13 AM in reply to: Daniel.Dulzo

Thanks Daniel you code did the trick. I created 2 functions 1 to check for the provider and 1 to check if the file is currently checked out? The problem now is that error 1092 is thrown when a file is checked out? i try to read the

Checked Out By property on the file and if its not empty i know the file is checked out? but it throws an error, what am i missing here.

 

Regards Kent Boettger

 

 

 Public Function ReadPropertyProvider(servername As String, ByVal Myfile As String)

        'Login with Windows User login
        Dim winAuthSvc As WinAuthService = New WinAuthService()

        winAuthSvc.Url = "http://" + servername + "/AutodeskDM/Services/WinAuth/WinAuthService.asmx"
        winAuthSvc.UseDefaultCredentials = True
        winAuthSvc.SecurityHeaderValue = New WinAuthSvc.SecurityHeader()
        'winAuthSvc.SignIn("VaultDemo")
        winAuthSvc.SignIn("VaultDemo")

        Dim DocSrv As DocumentService = New DocumentService()

        DocSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader()
        DocSrv.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrv.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrv.Url = "http://" + servername + "/AutodeskDM/Services/DocumentService.asmx"

        Dim DocSrvExt As DocumentServiceExtensions = New DocumentServiceExtensions()

        DocSrvExt.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader()
        DocSrvExt.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrvExt.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrvExt.Url = "http://" + servername + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"

        Dim PropSrv As PropertyService = New PropertyService()

        PropSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.PropertySvc.SecurityHeader()
        PropSrv.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        PropSrv.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        PropSrv.Url = "http://" + servername + "/AutodeskDM/Services/PropertyService.asmx"

        'Dim login As WinAuthCredentials = New WinAuthCredentials(serverName, "VaultDemo")
        Dim login As WinAuthCredentials = New WinAuthCredentials(servername, "VaultDemo")

        Using serviceManager As New WebServiceManager(login)

            Dim file As File = serviceManager.DocumentService.GetLatestFilePathsByNames(New String() {Myfile}).First().FilePaths.First().File
            'Dim file As File = serviceManager.DocumentService.GetLatestFilePathsByNames(New String() {"KBO1.dwg"}).First().FilePaths.First().File

            Dim providerPropDef As PropDef = serviceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(Function(propDef) propDef.SysName.Equals("Provider"))

            Dim providerPropInst As PropInst = serviceManager.PropertyService.GetProperties("FILE", New Long() {file.Id}, New Long() {providerPropDef.Id}).First()

            Dim providerString As String = TryCast(providerPropInst.Val, String)

            'MsgBox(providerString)

            Return providerString

        End Using

    End Function

    Public Function ReadPropertyCheckedOutBy(servername As String, ByVal Myfile As String)

        'Login with Windows User login
        Dim winAuthSvc As WinAuthService = New WinAuthService()

        winAuthSvc.Url = "http://" + servername + "/AutodeskDM/Services/WinAuth/WinAuthService.asmx"
        winAuthSvc.UseDefaultCredentials = True
        winAuthSvc.SecurityHeaderValue = New WinAuthSvc.SecurityHeader()
        'winAuthSvc.SignIn("VaultDemo")
        winAuthSvc.SignIn("VaultDemo")

        Dim DocSrv As DocumentService = New DocumentService()

        DocSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader()
        DocSrv.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrv.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrv.Url = "http://" + servername + "/AutodeskDM/Services/DocumentService.asmx"

        Dim DocSrvExt As DocumentServiceExtensions = New DocumentServiceExtensions()

        DocSrvExt.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentExSvc.SecurityHeader()
        DocSrvExt.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        DocSrvExt.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        DocSrvExt.Url = "http://" + servername + "/AutodeskDM/Services/DocumentServiceExtensions.asmx"

        Dim PropSrv As PropertyService = New PropertyService()

        PropSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.PropertySvc.SecurityHeader()
        PropSrv.SecurityHeaderValue.UserId = winAuthSvc.SecurityHeaderValue.UserId
        PropSrv.SecurityHeaderValue.Ticket = winAuthSvc.SecurityHeaderValue.Ticket
        PropSrv.Url = "http://" + servername + "/AutodeskDM/Services/PropertyService.asmx"

        'Dim login As WinAuthCredentials = New WinAuthCredentials(serverName, "VaultDemo")
        Dim login As WinAuthCredentials = New WinAuthCredentials(servername, "VaultDemo")

        Using serviceManager As New WebServiceManager(login)

            Dim file As File = serviceManager.DocumentService.GetLatestFilePathsByNames(New String() {Myfile}).First().FilePaths.First().File
            'Dim file As File = serviceManager.DocumentService.GetLatestFilePathsByNames(New String() {"KBO1.dwg"}).First().FilePaths.First().File

            Dim checkedoutbyPropDef As PropDef = serviceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(Function(propDef) propDef.SysName.Equals("Checked Out By"))

            Dim checkedoutbyPropInst As PropInst = serviceManager.PropertyService.GetProperties("FILE", New Long() {file.Id}, New Long() {checkedoutbyPropDef.Id}).First()

            Dim checkedoutbyString As String = TryCast(checkedoutbyPropInst.Val, String)
            'MsgBox(providerString)

            Return checkedoutbyString

        End Using

    End Function

 

 

 

Valued Contributor kbo
Valued Contributor
kbo
Posts: 91
Registered: ‎08-18-2010
Message 4 of 4 (456 Views)

Re: How to read systemproperty Provider from File in vault professional

06-07-2012 06:50 AM in reply to: kbo

never mind i did the check this way, Again daniel thanks for your help.

 

 If file.CheckedOut = True Then

                                MsgBox(Myfile & " Is Checked Out")

                                GoTo DONT_RELEASE

                            End If

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.