Repository.XFRACAS.ImportXFRACASXML: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:




<onlyinclude>Imports an import byte stream into a desired XFRACAS entity. Returns an '''Integer''' that represents the system ID of the byte array.</onlyinclude>
<onlyinclude>Imports an XML byte array into a desired XFRACAS entity. Returns an '''Integer''' that represents the system ID of the byte array.</onlyinclude>


All XML files must first be in the XFRACAS format before they can be successfully imported. To view the XFRACAS formats, refer to the [[XFRACAS XML Import Documentation]].
All XML files must first be in the XFRACAS XML format before they can be successfully imported. To view the XFRACAS formats, see to [http://www.synthesisplatform.net/XFRACAS/en/XML_XFRACAS9_and_10.pdf XFRACAS9/10 Import Business Logic] (PDF) document.


== Syntax ==
== Syntax ==
Line 22: Line 22:
''byteData''
''byteData''


:Byte. The byte array of the XML to import. (Required)
:Byte(). The byte array of the XML to import. (Required)


''fileTitle''
''fileTitle''
Line 32: Line 32:
:String. A description of the XML to import. (Required)
:String. A description of the XML to import. (Required)


<!--
 
== Example ==
== Example ==
 
  '''VB.NET'''
  '{{APIComment|Declare a new repository connection class.}}
{{APIPrefix|Private WithEvents MyRepository As New [[Repository Class|Repository]]}}
   
   
  '{{APIComment|Connect to the desired Synthesis repository.}}
  {{APIComment|'Add code to connect to a Synthesis repository.}}
{{APIPrefix|Dim}}Success{{APIPrefix|As Boolean}}={{APIPrefix|False}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
{{APIComment|...}}
   
   
  '{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
  {{APIComment|'Get a list of XFRACAS entities in the current project in the connected repository.}}
{{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} [[NameIdPair Class|NameIdPair]]
  {{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} NameIdPair
ListOfXFRACASEntities = MyRepository.XFRACAS.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
  ListOfXFRACASEntities = MyRepository.XFRACAS.GetAllXFRACASEntities()
   
   
  '{{APIComment|Search the Entities for the desired Entity name, to find the Entity ID}}
  {{APIComment|'Search the entities list for the desired entity name, to find the Entity ID}}
{{APIPrefix|Dim}} DesiredEntityID {{APIPrefix|As Integer}}
  {{APIPrefix|Dim}} DesiredEntityID {{APIPrefix|As Integer}}
         For Each Entity {{APIPrefix|As}} NameIdPair In ListOfXFRACASEntities()
         For Each Entity {{APIPrefix|As}} NameIdPair In ListOfXFRACASEntities()
             If Entity.Name = "DesiredEntityName"
             If Entity.Name = {{APIString|"DesiredEntityName"}}
               DesiredEntityID = Entity.ID
               DesiredEntityID = Entity.ID
               Exit For
               Exit For
             End If
             End If
         Next
         Next
  '{{APIComment|Define an serializable XML Object.}}
   
{{APIPrefix|Dim}} xmlObject {{APIPrefix|As Object}} = {{APIPrefix|Nothing}}
{{APIComment|'Define a serializable XML object, and then populate it with values to import.}}
'{{APIComment|populate the xmlObject with values to import}}
  {{APIPrefix|Dim}} xmlObject {{APIPrefix|As Object}} = {{APIPrefix|Nothing}}
  '{{APIComment|Define the byte array.}}
  {{APIComment|...}}
{{APIPrefix|Dim}}byteArray {{APIPrefix|As}} Byte() = {{APIPrefix|Nothing}}
   
'{{APIComment|Serialize the xmlObject into the byteArray.}}
{{APIPrefix|Dim}} SerializeSuccess {{APIPrefix|As Boolean}}
{{APIComment|'Define the byte array, and then serialize the object to the byte array.}}
   SerializeSuccess = MyRepository.XFRACAS.[[Repository.SerializeXMLObjectToByteArray|SerializeXMLObjectToByteArray]](byteArray, xmlObject)
  {{APIPrefix|Dim}} byteArray {{APIPrefix|As}} Byte() = {{APIPrefix|Nothing}}
  '{{APIComment|Import the XML byte array into the entity desired. In this example, we assume the XML object type describes an Incident.}}
   MyRepository.XFRACAS.SerializeXMLObjectToByteArray(byteArray, xmlObject)
{{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
   
ImportXMLSystemID = MyRepository.XFRACAS.[[Repository.ImportXFRACASXML|ImportXFRACASXML]](DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")
{{APIComment|'Import the XML byte array into the desired XFRACAS entity. In this example, we assume that the XML object type describes an Incident.}}
-->
  {{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
  ImportXMLSystemID = MyRepository.XFRACAS.[[Repository.ImportXFRACASXML|ImportXFRACASXML]](DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, {{APIString|"XMLFileTitle"}}, {{APIString|"XMLFileDescription"}})

Revision as of 22:48, 19 August 2015

APIWiki.png


Member of: SynthesisAPI10.Repository


Imports an XML byte array into a desired XFRACAS entity. Returns an Integer that represents the system ID of the byte array.

All XML files must first be in the XFRACAS XML format before they can be successfully imported. To view the XFRACAS formats, see to XFRACAS9/10 Import Business Logic (PDF) document.

Syntax

.XFRACAS.ImportXFRACASXML(entityID, importType, byteData, fileTitle, fileDescription)

Parameters

entityID

Integer. The ID number of the XFRACAS entity to import the data into. (Required)

importType

The type of XFRACAS element (e.g., incident, problem, etc.) to import. Can be any XFRACASImportType constant. (Required)

byteData

Byte(). The byte array of the XML to import. (Required)

fileTitle

String. The file title of the XML file byte array to import. (Required)

fileDescription

String. A description of the XML to import. (Required)


Example

VB.NET

 'Add code to connect to a Synthesis repository. 
 Dim MyRepository As New Repository
 ... 

 'Get a list of XFRACAS entities in the current project in the connected repository. 
 Dim ListOfXFRACASEntities() As NameIdPair
 ListOfXFRACASEntities = MyRepository.XFRACAS.GetAllXFRACASEntities()

 'Search the entities list for the desired entity name, to find the Entity ID 
 Dim DesiredEntityID As Integer
       For Each Entity As NameIdPair In ListOfXFRACASEntities()
           If Entity.Name = "DesiredEntityName"
              DesiredEntityID = Entity.ID
              Exit For
           End If
       Next

 'Define a serializable XML object, and then populate it with values to import. 
 Dim xmlObject As Object = Nothing
  ... 


 'Define the byte array, and then serialize the object to the byte array. 
 Dim byteArray As Byte() = Nothing
 MyRepository.XFRACAS.SerializeXMLObjectToByteArray(byteArray, xmlObject)

 'Import the XML byte array into the desired XFRACAS entity. In this example, we assume that the XML object type describes an Incident. 
 Dim ImportXMLSystemID As Integer
 ImportXMLSystemID = MyRepository.XFRACAS.ImportXFRACASXML(DesiredEntityID, XFRACASImportType.Incident, byteArray, "XMLFileTitle", "XMLFileDescription")