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
Solved! Go to Solution.
Solved by Daniel.Dulzo. Go to Solution.
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
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
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