• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010
    Accepted Solution

    "Value of type long can not be converted to 1-dimansional array of long"

    109 Views, 7 Replies
    02-03-2012 04:42 AM

    I try to change the status on a file from work in progress to released.

     

    but i keep getting the error "Value of type long can not be converted to 1-dimansional array of long"

     

    please help with this, i cant figure out how to change the file status :-(

     

     Dim files As File() = docSvc.GetLatestFilesByFolderId(parentFolder.Id, False)
    
            If (Not files Is Nothing AndAlso files.Length > 0) Then
    
                For Each file As File In files
    
                    Dim MyfileName(0) As String
    
                    MyfileName(0) = "VAULT002.idw"
    
                    If file.Name = MyfileName(0) Then
    
                        'MsgBox(file.FileLfCyc.LfCycStateId.ToString)
    
                        MsgBox(parentFolder.FullName & "/" & file.Name & " - " & "FilID: " & file.Id & " - " & "FilMasterID: " & file.MasterId)
    
                        Dim ThisFileID As Long = file.Id
    
                        Dim ThisFileMasterID(0) As Long
    
                        ThisFileMasterID(0) = file.MasterId
    
                        'Lifecycle Definitions
                        'Name : Monsun Basic Release Process = 6
    
                        'Lifecycle States
                        'Work in Progress = LifecyclestateID 24
                        'For Review = LifecyclestateID 25
                        'Released = LifecyclestateID 26
                        'Obsolete = LifecyclestateID 27
    
                        Dim MyLifecycleDefinition As LfCycDef
    
                        Dim docsvcExt As Autodesk.Connectivity.WebServices.DocumentServiceExtensions
    
                        Dim ThisFileLifecycleStateName As String = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycStateName
                        Dim ThisFileLifeCyclestateID As Long = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycStateId
                        Dim ThisFileLifeCycledefinitionID As Long = docSvc.GetFileById(ThisFileID).FileLfCyc.LfCycDefId
    
                        MsgBox("LifecyclestateName: " & ThisFileLifecycleStateName & " - LifecyclestateID: " & ThisFileLifeCyclestateID & " - Lifecycledefinition: " & ThisFileLifeCycledefinitionID)
    
                        If ThisFileLifeCyclestateID = 24 Then
    
                            ThisFileLifeCyclestateID = 26
    
                            Dim Thisfile As File
    
                            Thisfile = docsvcExt.UpdateFileLifeCycleStates(ThisFileMasterID, ThisFileLifeCyclestateID, ("TEST RELEASE"))
    
                        End If
    
                        Exit For
    
                    End If
    
                Next file
    
            End If

     

    Employee
    Posts: 414
    Registered: 12-12-2006

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-03-2012 05:14 AM in reply to: kbo

    The second parameter in UpdateFileLifeCycleStates needs an array of Long values.  You are passing in a Long instead of a Long().

     

    Also you don't want to hard-code the lifecycle ID values.  It's fine for testing, but those numbers may change.  A better approach is to look lifecycle state based on its system name, which will not change.  You do this by calling GetLifeCycleDefinitionsByIds then scanning through the results for the LfCycDef that matches the system name.



    Doug Redmond
    Software Engineer
    Autodesk, Inc.
    http://justonesandzeros.typepad.com/

    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-03-2012 01:30 PM in reply to: doug.redmond

    I know that this is the problem but please show me how to pass / decleare this long() array?

    I can figure out how to declare this. I really need to figure this out bud i am stuckt here :-(

     

    Can you please show how to do this the right way?

     

    Regards.

     

    Kent boettger

     

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-04-2012 12:58 AM in reply to: kbo

    This is correct way how to call UpdateFileLifeCycleStates in VB.NET - you need to pass arrays fro both masterdIds and stateIds arguments:

     

    Thisfile = docsvcExt.UpdateFileLifeCycleStates(New Long() { ThisFileMasterID }, New Long() { ThisFileLifeCyclestateID }, "TEST RELEASE")



    Jan Liska
    Technical Consultant
    Autodesk, Inc.
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-06-2012 02:18 AM in reply to: jan.liska

    Thank you Jan, I changed my code according to your recommendations tried this new code but now i get a new error. reference to object net set? What is the problem here.

     

      Dim files As File() = DocSrv.GetLatestFilesByFolderId(parentFolder.Id, False)
    
            If (Not files Is Nothing AndAlso files.Length > 0) Then
    
                For Each file As File In files
    
                    Dim MyfileName(0) As String
    
                    MyfileName(0) = Me.TextBox1.Text '"VAULT002.idw"
    
                    If file.Name = MyfileName(0) Then
    
                        With file
    
                            MsgBox("File found")
    
                            Try
    
                                'Lifecycle Definitions
                                'Name : Monsun Basic Release Process = 6
    
                                'Lifecycle States
                                'Work in Progress = LifecyclestateID 24
                                'For Review = LifecyclestateID 25
                                'Released = LifecyclestateID 26
                                'Obsolete = LifecyclestateID 27
    
                                'Get FileID
                                Dim ThisFileID As Long = file.Id
    
                                'Get file master ID
                                Dim ThisFileMasterID() As Long = New Long() {DocSrv.GetFileById(file.Id).MasterId}
    
                                'Create array of LyfecycleStates
                                Dim ThisFileLifeCycleState() As Long = New Long() {24, 25, 26, 27}
    
                                Dim MyFileToUpdate As File = DocSrv.GetFileById(file.Id)
    
                                'Update file LifeCycle state
                                With MyFileToUpdate
    
                                    'MsgBox((ThisFileMasterID(0) & ":" & (ThisFileLifeCycleState(2) & ":" & "TEST RELEASE")))
    
                                    DocSrvExt.UpdateFileLifeCycleStates(New Long() {ThisFileMasterID(0)}, New Long() {ThisFileLifeCycleState(2)}, "TEST RELEASE")
    
                                    MsgBox("LifeCycle state Changed")
    
                                End With
    
                            Catch ex As Exception
    
                                'ERROR HERE "Object reference not set to an instance of an object"
                                MsgBox(ex.Message)
    
                            End Try
    
                        End With
    
                        Exit For
    
                    End If
    
                Next file
    
            End If

     

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-06-2012 10:35 AM in reply to: kbo

    The error means that you're trying to use object which is not initialized yet. I suggest to check your code under debugger to find out more details.



    Jan Liska
    Technical Consultant
    Autodesk, Inc.
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-07-2012 04:50 PM in reply to: jan.liska

    Thanks a lot for your help on this, now i got it all working :-) happy me :-) i tried to debug with no luck, but then i and addet the DocumentServiceExtensions to my login code and now everything works. Just saved month of work, before we go life with our vault. Now i can release all AutoCAD drawings in the vault with one click! When you ever come to Denmark i will buy you a Beer :-) below is the missing part of my code in case others have the same problem.

    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"

     

    Employee
    Posts: 19
    Registered: 10-18-2006

    Re: "Value of type long can not be converted to 1-dimansional array of long

    02-07-2012 11:54 PM in reply to: kbo

    Glad to hear that you were able to solve the problem. If you're using 2012 release I suggest to look at WebServiceManager class which is available in Autodesk.Connectivity.WebServicesTools. The class simplifies access to individual web service classes.



    Jan Liska
    Technical Consultant
    Autodesk, Inc.