Repository.BlockSim.ImportBlockSimXMLFile: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
mNo edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
Synthesis API allows the programmer to import XML files into a current project of BlockSim. The page contains the logic of that importation. All XML files must first be in XML format before they can be successfully imported. This page will demonstrate the importation process.


== Syntax  ==
*ImportBlockSimXMLFile( XMLFile {{APIPrefix|As String}} ) {{APIPrefix|As Boolean}}


Parameters
<onlyinclude>Imports data from an XML file into the current BlockSim project. Returns a '''Boolean''' value; when true, indicates a successful import.</onlyinclude>
:''XMLFile'': The path for the XML file to import.


== Usage Example ==
'''Remarks''': The XML file can include the block properties and information on how the blocks are connected in a reliability block diagram or fault tree diagram. Data on visual aspects, such as diagram style settings, block style settings, etc., are not supported.
'{{APIComment|Declare a new repository connection class.}}
{{APIPrefix|Private WithEvents MyRepository As New Repository}}
'{{APIComment|Connect to the Synthesis repository.}}
{{APIPrefix|Dim}}Success{{APIPrefix|As Boolean}}={{APIPrefix|False}}
  Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
'{{APIComment|Import the XML File to the Synthesis repository.}}
{{APIPrefix|Dim}}SuccessImportXML{{APIPrefix|As Boolean}}
  SuccessImportXML = MyRepository.[[Repository.ImportBlockSimXMLFile|ImportBlockSimXMLFile]]("XMLFilePath")


===Reformatted Usage Example===
== Syntax ==
'''.BlockSim.ImportBlockSimXMLFile'''(''XMLFile'')


{{APIComment|Declare a new repository connection class.}}
=== Parameters ===
        Private WithEvents MyRepository As New Repository
''XMLFile''
:Required. String. The complete path to the XML file to be imported.


{{APIComment|Connect to the Synthesis repository.}}
== Example ==
        Dim Success As Boolean = False
This example assumes that an XML file called "BlockSimData.xml" exists in the C: drive. The code ignores the return value.
        Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
'''VBA|VB.NET'''
 
{{APIComment|Import the XML File to the Synthesis repository.}}
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
        Dim SuccessImportXML As Boolean
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
        SuccessImportXML = MyRepository.[[Repository.ImportBlockSimXMLFile|ImportBlockSimXMLFile]]("XMLFilePath")
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
{{APIComment|'Import the data from the XML file into project #1 in the repository.}}
  MyRepository.Project.SetCurrentProject(1)
  MyRepository.BlockSim.ImportBlockSimXMLFile({{APIString|"C:\BlockSimData.xml"}})

Latest revision as of 20:30, 18 August 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Imports data from an XML file into the current BlockSim project. Returns a Boolean value; when true, indicates a successful import.


Remarks: The XML file can include the block properties and information on how the blocks are connected in a reliability block diagram or fault tree diagram. Data on visual aspects, such as diagram style settings, block style settings, etc., are not supported.

Syntax

.BlockSim.ImportBlockSimXMLFile(XMLFile)

Parameters

XMLFile

Required. String. The complete path to the XML file to be imported.

Example

This example assumes that an XML file called "BlockSimData.xml" exists in the C: drive. The code ignores the return value.

VBA|VB.NET 

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
 
 'Import the data from the XML file into project #1 in the repository. 
  MyRepository.Project.SetCurrentProject(1)
  MyRepository.BlockSim.ImportBlockSimXMLFile("C:\BlockSimData.xml")