Repository.Project.GetCurrentProject: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
{{Template:Repository.GetCurrentProject.Cmt}}


== Syntax==


*GetCurrentProject(){{APIPrefix|As}}[[NameIdPair Class|NameIdPair]]
<onlyinclude>Returns a '''[[NameIdPair Class|NameIDPair]]''' object that represents the name and ID pair of the current project.</onlyinclude>


== Usage Example ==
== Syntax ==
In this usage example, the API is used to connect to a repository, retrieve one of the models in it and then calculate the reliability at a specified time, based on that model.
'''.Project.GetCurrentProject'''
  {{APIComment|'Declare a new repository connection class.}}
 
  Dim MyRepository As New Repository
 
 
== Example ==
{{APIComment|'Connect to a Synthesis repository.}}
'''VBA|VB.NET'''
  Dim Success As Boolean = False
  Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
 
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|'Get a list of the names/IDs of projects in the connected repository.}}
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
  Dim ListOfProjects() As NameIdPair
  ListOfProjects = MyRepository.GetAllProjects
  {{APIComment|'Set the first available project in the repository as the current project.}}
 
  MyRepository.Project.SetCurrentProject(1)
  {{APIComment|'Open the first project in the list.}}
  MyRepository.SetCurrentProject(ListOfProjects(0).ID)
  {{APIComment|'Output example: Display the name and ID of the current project.}}
 
  Dim ProjectName {{APIPrefix|As}} String
  {{APIComment|'Get a list of the names/IDs of models in the current project.}}
  Dim ProjectID {{APIPrefix|As}} Integer
  Dim ListOfModels() As NameIdPair
  ProjectName = MyRepository.Project.GetCurrentProject.Name
  ListOfModels = MyRepository.GetAllModelsInfo()
  ProjectID = MyRepository.Project.GetCurrentProject.ID
 
  MsgBox ({{APIString|"You are currently connected to: "}} & ProjectName & {{APIString|", ID#"}} & ProjectID)
{{APIComment|'Retrieve the first model in the list.}}
  Dim AModel as cModel
  AModel = MyRepository.GetModel(ListOfModels(0).ID)
 
{{APIComment|'Calculate the reliability at time &#61; 50 and save the result. See [[CModel.Reliability|Reliability]].}}
  Dim Rel as Double
  Rel = AModel.Reliability(50)
 
{{APIComment|'Disconnect from the repository.}}
  MyRepository.DisconnectFromRepository

Latest revision as of 17:30, 9 June 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Returns a NameIDPair object that represents the name and ID pair of the current project.

Syntax

.Project.GetCurrentProject


Example

VBA|VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")

 'Set the first available project in the repository as the current project. 
  MyRepository.Project.SetCurrentProject(1)

 'Output example: Display the name and ID of the current project. 
  Dim ProjectName As String
  Dim ProjectID As Integer
  ProjectName = MyRepository.Project.GetCurrentProject.Name
  ProjectID = MyRepository.Project.GetCurrentProject.ID
  MsgBox ("You are currently connected to: " & ProjectName & ", ID#" & ProjectID)