By Wayne Brill
This VB example uses GetPropertyDefinitions() and the GetPropertyValue() of the the PropertyManager to retrieve the value of system and a user defined property (UDP) for a file. It may not be obvious how to get the PropertyDefinition parameter that you need to pass to GetPropertyValue().
To get the PropertyDefinition you can use GetPropertyDefinitions() which returns a PropertyDefinitionDictionary which is a key value pair. The value of the KeyValuePair are property definitions. In this example the display name of the PropertyDefinition is used to find a user defined property to use with GetPropertyValue().
For system properties you can use one of the members of PropertyDefinitionIds.Server. This example is using PropertyDefinitionIds.Server.LifeCycleDefinition and PropertyDefinitionIds.Server.VersionNumber.
To try this code you can add a button to the VaultList SDK sample and copy in this code.
PrivateSub Button5_Click(sender As System.Object, _
e As System.EventArgs) Handles Button5.Click
' For demonstration purposes,
'the information is hard-coded.
Dim results As VDF.Vault.Results.LogInResult =
VDF.Vault.Library.ConnectionManager.LogIn _
("localhost", "Vault", "Administrator", "", _
VDF.Vault.Currency.Connections. _
AuthenticationFlags.Standard, Nothing)
IfNot results.Success Then
Return
EndIf
Dim m_conn As _
VDF.Vault.Currency.Connections.Connection _
= results.Connection
Dim props AsPropertyDefinitionDictionary = _
m_conn.PropertyManager.GetPropertyDefinitions(
VDF.Vault.Currency.Entities.EntityClassIds.Files,
Nothing, PropertyDefinitionFilter.IncludeAll)
Dim myKeyValPair AsKeyValuePair _
(OfString, PropertyDefinition)
Dim myUDP_DayOFSave AsPropertyDefinition _
= Nothing
Dim propDef AsPropertyDefinition
ForEach myKeyValPair In props
' Property definition from KeyValuePair
propDef = myKeyValPair.Value()
' Using the display name to identify
' the PropertyDefinition
IfpropDef.DisplayName = _
"wb_Day_Of_IDW_Save"Then
'It is the PropertyDefinition
myUDP_DayOFSave = propDef
Exit For
EndIf
Next
Dim myLifeCycleDef AsPropertyDefinition = _
props(PropertyDefinitionIds.Server. _
LifeCycleDefinition)
Dim myVerNumDef AsPropertyDefinition = _
props(PropertyDefinitionIds.Server. _
VersionNumber)
' Get the FileIteration
Dim fileIter As _
VDF.Vault.Currency.Entities.FileIteration = Nothing
'Change this to the name of a file in your vault
fileIter = _
getFileIteration("wB_Assembly_9-23-13.idw", m_conn)
'Name of the life cycle definition
Dim strLifeCycleName AsString = _
m_conn.PropertyManager.GetPropertyValue _
(fileIter, myLifeCycleDef, Nothing)
'Version number
Dim strVersionNumber AsString = _
m_conn.PropertyManager.GetPropertyValue _
(fileIter, myVerNumDef, Nothing)
'Get the user defined property value
IfNot myUDP_DayOFSave IsNothingThen
Dim strPropertyVal AsString = _
m_conn.PropertyManager.GetPropertyValue _
(fileIter, myUDP_DayOFSave, Nothing)
MessageBox.Show("Value of custom prop " _
& myUDP_DayOFSave.DisplayName.ToString() _
& " = "& strPropertyVal)
EndIf
EndSub
Here is the code that gets the FileIteration.
PublicFunction getFileIteration _
(nameOfFile AsString, _
connection As _
VDF.Vault.Currency. _
Connections.Connection) _
As VDF.Vault.Currency. _
Entities.FileIteration
Dim conditions As ACW.SrchCond()
ReDim conditions(0)
Dim lCode AsLong = 1
Dim Defs As ACW.PropDef() = _
connection.WebServiceManager. _
PropertyService. _
GetPropertyDefinitionsByEntityClassId("FILE")
Dim Prop As ACW.PropDef = Nothing
ForEach def As ACW.PropDefIn Defs
If def.DispName = _
"File Name"Then
Prop = def
EndIf
Next def
Dim searchCondition As _
ACW.SrchCond = New ACW.SrchCond()
searchCondition.PropDefId = _
Prop.Id
searchCondition.PropTyp = _
ACW.PropertySearchType.SingleProperty
searchCondition.SrchOper = lCode
searchCondition.SrchTxt = nameOfFile
conditions(0) = searchCondition
' search for files
Dim FileList AsList _
(Of Autodesk.Connectivity.WebServices.File) = _
NewList _
(Of Autodesk.Connectivity.WebServices.File) '()
Dim sBookmark AsString = String.Empty
Dim Status As ACW.SrchStatus = Nothing
While (Status IsNothingOrElse _
FileList.Count < Status.TotalHits)
Dim files As Autodesk.Connectivity. _
WebServices.File() = connection.WebServiceManager.
DocumentService.FindFilesBySearchConditions _
(conditions, _
Nothing, Nothing, True, True, _
sBookmark, Status)
If (Not files IsNothing) Then
FileList.AddRange(files)
EndIf
EndWhile
Dim oFileIteration As _
VDF.Vault.Currency.Entities. _
FileIteration = Nothing
For i AsInteger = _
0 To FileList.Count - 1
If FileList(i).Name = _
nameOfFile Then
oFileIteration = _
New VDF.Vault.Currency. _
Entities.FileIteration(connection, _
FileList(i))
EndIf
Next
Return oFileIteration
EndFunction