APISynthesisResourcesTutorial

 << Back to Quick Start Guide

Synthesis Resources Tutorial
 * 1) Connect to a Synthesis Repository and Project
 * 2) Create a New Synthesis Resource
 * 3) Update an Existing Resource
 * 4) Calculate Results from a Model

This four-part tutorial introduces you to the basic functionalities of the Synthesis API. You will learn how to use the API to connect to a Synthesis repository, create a new resource, update an existing resource and obtain calculated results from a model.

The Synthesis Platform uses repositories to store projects and analysis data. Projects, in turn, hold resources that contain various types of information that can be shared between analyses. Therefore, to create or update a resource in a Synthesis repository, we must begin by first connecting to the repository and then accessing the project that holds that resource.

Part 1: Connect to a Synthesis Repository and Project
1. We'll start with the  class, which provides several methods for connecting to standard or enterprise repositories. In this example, we will use the basic  method to create a simple application.

Create a new module and start with the following basic code for connecting to a standard Synthesis repository.

VBA|VB.NET MyRepository Repository MyRepository.ConnectToRepository

2. Next, use the  method to specify the current (or active) project by using the project's ID number. In this example, we'll first use the  method to get an array of all projects in the repository, and then use the ID number of the first project in the array to set it as the current project.

VBA|VB.NET 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)

Any time you wish to switch to another project in the repository, you can always use the  method to specify a new active project.

However, if you wish to access projects from another repository, you’ll first need to disconnect from the current repository by using the  method, and then use the   method again to connect to the desired repository.

VBA|VB.NET MyRepository.DisconnectFromRepository

Test the Code
Let’s verify that our connections to the repository and project work.

Below is the code list for this example. On the Debug menu, click Start to run the application. A message box displays the name and ID number of the current project in the repository.

VBA|VB.NET 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