Лёгкое программирование под Autodesk Vault Часть 40
Этот пример на VB использует GetPropertyDefinitions() и GetPropertyValue() из PropertyManager для получения значения системного и определенного пользователем свойства (UDP) файла.
Может быть не совсем очевидно, как получить параметрPropertyDefinition, который передается в GetPropertyValue().
Для получения PropertyDefinition вы можете использовать GetPropertyDefinitions(), который возвращает PropertyDefinitionDictionary, который является парой ключ-значение. Значение KeyValuePairare является определениями свойств.
В этом примере отображаемое имяPropertyDefinition используется для нахождения определяемого определенного пользователем свойства для передачи его GetPropertyValue().
Для системных свойств вы можете использовать один из членовPropertyDefinitionIds.Server. Этот пример использует PropertyDefinitionIds.Server.LifeCycleDefinition и PropertyDefinitionIds.Server.VersionNumber.
Для проверки этого кода вы можете добавить кнопку к примеру VaultList из Vault SDK и скопировать этот код в проект.
- Private Sub Button5_Click(sender As System.Object, _
 - e As System.EventArgs) Handles Button5.Click
 - ' С целью демонстрации,
 - ' эта информация записана жестко
 - Dim results As VDF.Vault.Results.LogInResult =
 - VDF.Vault.Library.ConnectionManager.LogIn _
 - ("localhost", "Vault", "Administrator", "", _
 - VDF.Vault.Currency.Connections. _
 - AuthenticationFlags.Standard, Nothing)
 - If Not results.Success Then
 - Return
 - End If
 - Dim m_conn As _
 - VDF.Vault.Currency.Connections.Connection _
 - = results.Connection
 - Dim props As PropertyDefinitionDictionary = _
 - m_conn.PropertyManager.GetPropertyDefinitions(
 - VDF.Vault.Currency.Entities.EntityClassIds.Files,
 - Nothing, PropertyDefinitionFilter.IncludeAll)
 - Dim myKeyValPair As KeyValuePair _
 - (Of String, PropertyDefinition)
 - Dim myUDP_DayOFSave As PropertyDefinition _
 - = Nothing
 - Dim propDef As PropertyDefinition
 - For Each myKeyValPair In props
 - ' Определение свойства из KeyValuePair
 - propDef = myKeyValPair.Value()
 - ' Используем отображаемое имя
 - ' для определения PropertyDefinition
 - If propDef.DisplayName = _
 - "wb_Day_Of_IDW_Save" Then
 - 'It is the PropertyDefinition
 - myUDP_DayOFSave = propDef
 - Exit For
 - End If
 - Next
 - Dim myLifeCycleDef As PropertyDefinition = _
 - props(PropertyDefinitionIds.Server. _
 - LifeCycleDefinition)
 - Dim myVerNumDef As PropertyDefinition = _
 - props(PropertyDefinitionIds.Server. _
 - VersionNumber)
 - ' Получаем FileIteration
 - Dim fileIter As _
 - VDF.Vault.Currency.Entities.FileIteration = Nothing
 - ' Измените это на имя файла в вашем хранилище
 - fileIter = _
 - getFileIteration("wB_Assembly_9-23-13.idw", m_conn)
 - ' Имя определения жизненного цикла
 - Dim strLifeCycleName As String = _
 - m_conn.PropertyManager.GetPropertyValue _
 - (fileIter, myLifeCycleDef, Nothing)
 - ' Номер версии
 - Dim strVersionNumber As String = _
 - m_conn.PropertyManager.GetPropertyValue _
 - (fileIter, myVerNumDef, Nothing)
 - ' Получить значение определенного пользователем свойства
 - If Not myUDP_DayOFSave Is Nothing Then
 - Dim strPropertyVal As String = _
 - m_conn.PropertyManager.GetPropertyValue _
 - (fileIter, myUDP_DayOFSave, Nothing)
 - MessageBox.Show("Значение пользовательского свойства " _
 - & myUDP_DayOFSave.DisplayName.ToString() _
 - & " = " & strPropertyVal)
 - End If
 - End Sub
 
Вот код, который получает FileIteration.
- Public Function getFileIteration _
 - (nameOfFile As String, _
 - connection As _
 - VDF.Vault.Currency. _
 - Connections.Connection) _
 - As VDF.Vault.Currency. _
 - Entities.FileIteration
 - Dim conditions As ACW.SrchCond()
 - ReDim conditions(0)
 - Dim lCode As Long = 1
 - Dim Defs As ACW.PropDef() = _
 - connection.WebServiceManager. _
 - PropertyService. _
 - GetPropertyDefinitionsByEntityClassId("FILE")
 - Dim Prop As ACW.PropDef = Nothing
 - For Each def As ACW.PropDef In Defs
 - If def.DispName = _
 - "File Name" Then
 - Prop = def
 - End If
 - 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
 - ' Ищем файлы
 - Dim FileList As List _
 - (Of Autodesk.Connectivity.WebServices.File) = _
 - New List _
 - (Of Autodesk.Connectivity.WebServices.File) '()
 - Dim sBookmark As String = String.Empty
 - Dim Status As ACW.SrchStatus = Nothing
 - While (Status Is Nothing OrElse _
 - 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 Is Nothing) Then
 - FileList.AddRange(files)
 - End If
 - End While
 - Dim oFileIteration As _
 - VDF.Vault.Currency.Entities. _
 - FileIteration = Nothing
 - For i As Integer = _
 - 0 To FileList.Count - 1
 - If FileList(i).Name = _
 - nameOfFile Then
 - oFileIteration = _
 - New VDF.Vault.Currency. _
 - Entities.FileIteration(connection, _
 - FileList(i))
 - End If
 - Next
 - Return oFileIteration
 - End Function
 
Обсуждение: http://adn-cis.org/forum/index.php?topic=977
Опубликовано 24.09.2014Отредактировано 24.09.2014 в 13:50:52