Repository.ConnectToRepository: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(32 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.ConnectToRepository.Cmt}}


If the extension of the file is *.rserp, then it connects to the enterprise database described in the file. Otherwise MS Access repository is assumed.


{{Template:BooleanReturn.Cmt}}
<onlyinclude>Connects to a standard or enterprise repository. Returns a '''Boolean''' value; when true, indicates a successful connection to the repository.</onlyinclude>
 
== Syntax ==
== Syntax ==
*ConnectToRepository( FileName {{APIPrefix|As String}} ){{APIPrefix|As Boolean}}
'''.ConnectToRepository'''(''FileName'')
 
=== Parameters ===
''FileName''
:Required. String. The complete path to the Synthesis repository. If the file extension is not specified, it assumes that the file is a standard repository.
 


Parameters
== Example ==
:''FileName'': The file path of the Synthesis Repository you will connect to.
This example assumes that a file called "RSRepository1.rsr10" exists in the C: drive. The code ignores the return value.  


== Usage Example ==
  '''VBA|VB.NET'''
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.
   
  {{APIComment|'Declare a new repository connection class.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
  {{APIComment|'Connect to a Synthesis repository.}}
  Dim Success As Boolean = False
  Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
 
  {{APIComment|'Get a list of the names/IDs of projects in the connected repository.}}
  Dim ListOfProjects() As NameIdPair
  ListOfProjects = MyRepository.GetAllProjects
 
{{APIComment|'Open the first project in the list.}}
  MyRepository.SetCurrentProject(ListOfProjects(0).ID)
 
{{APIComment|'Get a list of the names/IDs of models in the current project.}}
  Dim ListOfModels() As NameIdPair
  ListOfModels = MyRepository.GetAllModelsInfo()
 
  {{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 21:53, 13 November 2015

APIWiki.png


Member of: SynthesisAPI.Repository


Connects to a standard or enterprise repository. Returns a Boolean value; when true, indicates a successful connection to the repository.

Syntax

.ConnectToRepository(FileName)

Parameters

FileName

Required. String. The complete path to the Synthesis repository. If the file extension is not specified, it assumes that the file is a standard repository.


Example

This example assumes that a file called "RSRepository1.rsr10" exists in the C: drive. The code ignores the return value.

VBA|VB.NET

Dim MyRepository As New Repository
MyRepository.ConnectToRepository("C:\RSRepository1.rsr10")