ADN Club > Vault API

Как получить свойства текущего файла?

(1/2) > >>

Пашин Евгений:
Добрый день, коллеги.

Подскажите как получить свойства выделенного файла, при изменении состояния жизненного цикла.



Какие библиотеки подключить, интерфейсы, события?

Александр Ривилис:
Посмотри не подойдёт ли тебе эта статья: http://adndevblog.typepad.com/manufacturing/2013/12/getting-properties-of-file-interation-with-vault-development-framework-in-vault-2014-api.html

Пашин Евгений:

--- Цитата: Александр Ривилис от 25-05-2017, 12:41:53 ---Посмотри не подойдёт ли тебе эта статья: http://adndevblog.typepad.com/manufacturing/2013/12/getting-properties-of-file-interation-with-vault-development-framework-in-vault-2014-api.html
--- Конец цитаты ---

Я уже пробовал этот код. Тут он перебирает все файлы в хранилище. А мне нужен только тот, который выделил я, точнее его Id, причём при изменении состояния жизненного цикла.

Александр Ривилис:
А этот тоже пробовал: https://forums.autodesk.com/t5/vault-customization/vault-2015-c-get-selected-file-properties-and-values/td-p/5733448 ?

Пашин Евгений:

--- Цитата: Александр Ривилис от 25-05-2017, 13:06:16 ---А этот тоже пробовал: https://forums.autodesk.com/t5/vault-customization/vault-2015-c-get-selected-file-properties-and-values/td-p/5733448 ?
--- Конец цитаты ---

А в этой статье тоже не ясно, как найти SelectedFile.Id:


--- Код - C# [Выбрать] ---public static void PrintProperties(VDF.Vault.Currency.Connections.Connection connection, File selectedFile)        {            VDF.Vault.Currency.Entities.FileIteration fileInteration = new FileIteration(connection, selectedFile);            var propDefs = connection.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll);            foreach (var key in propDefs.Keys)            {                // Print the Name from the Definition and the Value from the Property                object propValue = connection.PropertyManager.GetPropertyValue(fileInteration, propDefs[key], null);                logit.logger(string.Format("== LIB 1 DICT == >>   '{0}' = '{1}'", key.ToString(), propValue == null ? "" : propValue.ToString()));            }        }
Как Raghulan нашёл selectedFile?



Есть простой пример в C:\Program Files (x86)\Autodesk\Autodesk Vault 2017 SDK\vs15\VB\HelloWorldVB\:

--- Код - vb.net [Выбрать] ---'...AddHandler helloWorldCmdItem.Execute, AddressOf HelloWorldCommandHandler'...         Private Sub HelloWorldCommandHandler(s As Object, e As CommandItemEventArgs)            Try                ' The Context part of the event args tells us information about what is selected.                ' Run some checks to make sure that the selection is valid.                If e.Context.CurrentSelectionSet.Count() = 0 Then                    MessageBox.Show("Nothing is selected")                ElseIf e.Context.CurrentSelectionSet.Count() > 1 Then                    MessageBox.Show("This function does not support multiple selections")                Else                    ' we only have one item selected, which is the expected behavior                     Dim selection As ISelection = e.Context.CurrentSelectionSet.First()                                       Dim mgr As WebServiceManager = e.Context.Application.Connection.WebServiceManager                     ' Look of the File object.  How we do this depends on what is selected.                    Dim selectedFile As File = Nothing                    If selection.TypeId = SelectionTypeId.File Then                        ' our ISelection.Id is really a File.MasterId                        selectedFile = mgr.DocumentService.GetLatestFileByMasterId(selection.Id)                    ElseIf selection.TypeId = SelectionTypeId.FileVersion Then                        ' our ISelection.Id is really a File.Id                        selectedFile = mgr.DocumentService.GetFileById(selection.Id)                    End If                     If selectedFile Is Nothing Then                        MessageBox.Show("Selection is not a file.")                    Else                        ' this is the message we hope to see                        MessageBox.Show([String].Format("Hello World! The file size is: {0} bytes", selectedFile.FileSize))                    End If                End If            Catch ex As Exception                ' If something goes wrong, we don't want the exception to bubble up to Vault Explorer.                MessageBox.Show("Error: " & ex.Message)            End Try        End Sub
Это хорошо, при работе по нажатию кнопки, точнее по событию выполнения команды, где входным параметров является CommandItemEventArgs.
А есть ли вариант при отрабатывании события изменения состояния жизненного цикла файла/папки/пользовательского объекта? То есть мне нужно знать, какой подключить ****EventArgs для события UpdateFileLifecycleStateEvents!!!


--- Код - vb.net [Выбрать] ---'...AddHandler Autodesk.Connectivity.WebServices.DocumentServiceExtensions.UpdateFileLifecycleStateEvents.Post, AddressOf Get_Lifecycle_Changes'...     Public Sub Get_Lifecycle_Changes(ByVal e As *****EventArgs - что здесь написать?)        Dim Connection As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection = VltApp.Connection        Dim WebManager As Autodesk.Connectivity.WebServicesTools.WebServiceManager = Connection.WebServiceManager        Dim allUsers() As Autodesk.Connectivity.WebServices.User = WebManager.AdminService.GetAllUsers()         For Each mUsr As Autodesk.Connectivity.WebServices.User In allUsers            Dim newUsr As New vltUser            With newUsr                .firstName = mUsr.FirstName                .lastName = mUsr.LastName                .name = mUsr.Name                .userEmail = mUsr.Email                .userId = mUsr.Id                .userIsActive = mUsr.IsActive            End With            VltUsers.allUsers.Add(newUsr)        Next        MsgBox("Вы только что изменили состояние жизненного цикла") ' Here is message that user changed the state of lifecycle of selected file        Dim nf As New Main(VltUsers)        nf.ShowDialog()         Dim selection As ISelection = e.Context.CurrentSelectionSet.First() ' ???????????????????????????????????????????????????? Is not working        Dim fileProperties As Autodesk.Connectivity.WebServices.PropInst() = WebManager.PropertyService.GetPropertiesByEntityIds("FILE", New Long() {selection.Id})  'For a selected file        'Dim folderProperties As Autodesk.Connectivity.WebServices.PropInst() = WebManager.PropertyService.GetPropertiesByEntityIds("FLDR", New Long() {FileID}) ' For a selected folder        MsgBox(selection.Id)    End Sub


Навигация

[0] Главная страница сообщений

[#] Следующая страница

Перейти к полной версии