Aras Community

Welcome to Aras Community Sign in | Join | Help
Aras Community
Please Also Visit the Project Site to Download Add-Ons and Solutions
Jump to Projects

Re: vault a file from vb.net

  •  10-19-2007, 1:17 PM

    Re: vault a file from vb.net

    I had the same problem on a project last month.   The solution is quite easy.      Innovator uses a distributed/replicated vaulting model.   The File Item has a relationship to Vault item,  that allows you to specify which vault the file should be stored into.     A File can be Located in 1 or more Vaults,  but has to be in at least one Vault.    The error message indicates that at least one instance of the Located relationship is required.

    here's what I usually do:

    After connecting,  the first query I run is to request the Default Vault for the current user,  this confirms that the connection parameters are valid,  and gets the Vault ID that I need.  This also gets the URL to the Vault Server (you have this hard-coded in your sample).  

    When you create the File item,  you also need to create a Located relationship underneath it to specify the vaulting meta-data.  Then do the Apply().  VB.NET sample follows:

            Dim ConnectTest As Item = inn.newItem("User", "get")
            ConnectTest.setAttribute("select", "default_vault")
            ConnectTest.setProperty("login_name", vUsername)
            Dim ConnectTestResult As Item
            ConnectTestResult = ConnectTest.apply()
            If ConnectTestResult.isError() Then
                MsgBox("Error: " & ConnectTestResult.getErrorDetail(), , "Publish2Innovator")
                MyConnection.Logout()
                Return
            End If
            vDefaultVault = ConnectTestResult.getProperty("default_vault")

    This sample takes the username provided, and tries to connect, and if successful, returns the ID of the default vault for this user.  Next sample shows how to use this with the File item.

                Dim File As Item = MyItem.newItem("File", "add")
                File.setProperty("filename", filename)
                File.setProperty("actual_filename", pathname)
                File.setProperty("checkedout_path", pathname.Substring(0, pathname.LastIndexOf("\")))
                File.attachPhysicalFile(pathname, vDefaultVault)
    I am using a different IOM function here,  that sets the filename and builds the Located relationship in one step.   You could also more explicitly just create the relationship under your File item:

               Dim fileItm As Item = inn.newItem("File", "add")
               Dim fileLocatedRel As Item = inn.newItem("Located", "add")
               fileItm.setFileName("C:\Gary\CMII\Legend.dwg")
               fileLocatedRel.setProperty("related_id",vDefaultVault)
               fileItm.addRelationship(fileLocatedRel)
               Dim Res As IOM.Item = fileItm.apply()

    Let me know if this works.    NOTE:  there were some fixes in the IOM.DLL  (patch for the 8.1.1 publically released version).   Drop me an email if you want the updated IOM.   pschroer@aras.com

     

     


     


    Peter Schroer
    Aras Corp
    pschroer@aras.com
    Filed under:
View Complete Thread
Powered by Community Server, by Telligent Systems