2 Replies Latest reply on Dec 4, 2018 8:23 AM by MARCO TULIO RAMOS FILHO

    EPDM API BatchUnlock AddSelection InvalidArg error?

    Tyler Johnson

      New to the EPDM API as we are just now implementing a vault for the first time.  I'm working on a solution for a machine that processes drawing files automatically and need to make sure the machine is checking in all the files it creates.


      I can loop file.unlockFile and check them in individually but the api help specifically states using batchunlock is faster/more efficient.  So I'm trying to use it but I'm stuck on the addselection method.  It's throwing an error and telling me The Parameter Is Incorrect with an invalidarg error code.


      I've tried everything I can think of.  It's not like there's a lot going on and most of this code is copied right from the api help examples.


      What am I missing?



      Imports EPDM.Interop.epdm

      Module Module1

          Sub Main()


                  Dim batchUnlocker As IEdmBatchUnlock = Nothing

                  Dim fileList As New List(Of String)

                  Dim vault5 As IEdmVault5 = New EdmVault5()

                  Dim vault7 As IEdmVault7 = DirectCast(vault5, IEdmVault7)

                  Dim file As IEdmFile5 = Nothing

                  Dim folder As IEdmFolder5 = Nothing

                  Dim selection() As EdmSelItem = Nothing


                  If Not vault7.IsLoggedIn Then

                      vault7.LoginAuto("Eng Vault", vbNull)

                  End If


                  batchUnlocker = vault7.CreateUtility(EdmUtility.EdmUtil_BatchUnlock)


                  Using reader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\filelist.txt")

                      While Not reader.EndOfData


                      End While


                  End Using


                  If fileList.Count = 0 Then

                      Exit Sub


                      Array.Resize(selection, fileList.Count)

                      Dim i As Integer = 0

                      For Each filePath In fileList

                          file = vault7.GetFileFromPath(filePath, folder)

                          selection(i).mlDocID = file.ID

                          selection(i).mlProjID = folder.ID

                          i = i + 1


                      batchUnlocker.AddSelection(vault5, selection)

                  End If


                  batchUnlocker.CreateTree(vbNull, EdmUnlockBuildTreeFlags.Eubtf_MayUnlock)

                  fileList = batchUnlocker.GetFileList(EdmUnlockFileListFlag.Euflf_GetUnlocked)



              Catch ex As Exception



              End Try

          End Sub

      End Module