Vault API: Getting information about the Vault server

By Marat Mirgaleev

Issue

Please, advise how I can get the Vault version and some other information from my code.

Solution

The Autodesk.Connectivity.WebServices.InformationService class is designed for this purpose. You may find useful this post about it in the Doug Redmond’s blog.

Ok, let’s show how to work with it in a short sample.

I will use my MyVaultServiceManager class from this post to connect to the server. It will let me to write the sample as simple like this:

  // A sample how to work with the Vault InformationService
  //=================================================================
  class InfoServiceSample
  {
 
    // Show some information about the current Vault server
    //===============================================================
    public static void ShowServerInfo()
    {
      // Establish a connection to the server
      using (MyVaultServiceManager mgr = new MyVaultServiceManager(
                                MyVaultServiceManager.Mode.ReadOnly))
      {
        try
        {
          // Print the server name
          string svrInfo = "Server:t" 
                   + mgr.Services.InformationService.GetServerName();
 
          // Print all products available
          Product[] PdSupported = 
              mgr.Services.InformationService.GetSupportedProducts();
          svrInfo += "nProduct List:"
                   + "n-------------------------------------------";
          foreach (Product Pd in PdSupported)
          {
            svrInfo += "n   Product Name:tt " + Pd.ProductName
              + "n   Product Version:tt " + Pd.ProductVersion
              + "n   Product Display Name:t " + Pd.DisplayName
              + "n   - - - - - - - - - - - - - - - - - - - - - - -";
          }
          MessageBox.Show(svrInfo, "Server Info");
        }
        catch (System.Exception err)
        {
          MessageBox.Show(err.ToString());
        }
      }
 
    } // ShowServerInfo()
  } // class InfoServiceSample

On my system this code produces the following result:

                   image


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading