Connect or Disconnect from a Synthesis Repository

 << Back to API Tutorials

Basics
 * 1) Connect or Disconnect from a Synthesis Repository
 * 2) Add New Synthesis Resources to a Repository
 * 3) Edit Existing Synthesis Resources
 * 4) Calculate Results from a Model

The Synthesis repositories store projects and analysis data. Before you can read or write data to a repository, you must first connect to it. In this tutorial, you will learn how to connect to a Synthesis repository and access one of its projects, and then disconnect from the repository when a task is done.

Connect to a Synthesis Repository
The  class represents a Synthesis repository. It provides several methods for connecting to either a standard or enterprise repository. In this tutorial, we'll use the basic  method to connect to a standard repository.

1. Create a new module and start with the following basic code. MyRepository Repository MyRepository.ConnectToRepository

2. Next, specify the current (or active) project to use. For this example, we'll access the first project in the repository. Use the  method to get an array of all the projects in the repository, and then use the   method to select the first project in the array. ListofProjects NameIdPair ListOfProjects = MyRepository.Project.GetAllProjects MyRepository.Project.SetCurrentProject(ListofProjects(0).ID) 3. Use the following code to test the response. In this example, we've used the  method to return the name and ID of the current project. ProjectName String ProjectID Integer ProjectName = MyRepository.Project.GetCurrentProject.Name ProjectID = MyRepository.Project.GetCurrentProject.ID  MsgBox ( & ProjectName &  & ProjectID)

4. Disconnect from the current repository by using the  method.

MyRepository.DisconnectFromRepository

Test the Code
Below are the complete code lists for this example. To test them, run the application by clicking Start on the Debug menu. A message box will display the name and ID number of the active project in the repository.

VBA Sub Main MyRepository Repository MyRepository.ConnectToRepository ListofProjects NameIdPair ListOfProjects = MyRepository.Project.GetAllProjects MyRepository.Project.SetCurrentProject(ListofProjects(0).ID) ProjectName String ProjectID Integer ProjectName = MyRepository.Project.GetCurrentProject.Name ProjectID = MyRepository.Project.GetCurrentProject.ID  MsgBox ( & ProjectName &  & ProjectID) MyRepository.DisconnectFromRepository End Sub

VB.NET SynthesisAPI Form1 Button1_Click(sender System.Object, e  System.EventArgs)  Button1.Click MyRepository Repository MyRepository.ConnectToRepository ListofProjects NameIdPair ListOfProjects = MyRepository.Project.GetAllProjects MyRepository.Project.SetCurrentProject(ListofProjects(0).ID) ProjectName String ProjectID Integer ProjectName = MyRepository.Project.GetCurrentProject.Name ProjectID = MyRepository.Project.GetCurrentProject.ID   MsgBox ( & ProjectName &  & ProjectID) MyRepository.DisconnectFromRepository