Repository.XFRACAS.ImportXFRACASXML: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
  '{{APIComment|Declare a new repository connection class.}}
  '{{APIComment|Declare a new repository connection class.}}
  {{APIPrefix|Private WithEvents MyRepository As New [[Repository Class|Repository]]}}
  {{APIPrefix|Private WithEvents MyRepository As New [[Repository Class|Repository]]}}
  '{{APIComment|Connect to the desired Synthesis repository.}}
  '{{APIComment|Connect to the desired Synthesis repository.}}
  {{APIPrefix|Dim}}Success{{APIPrefix|As Boolean}}={{APIPrefix|False}}
  {{APIPrefix|Dim}}Success{{APIPrefix|As Boolean}}={{APIPrefix|False}}
  Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
  Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
  '{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
  '{{APIComment|Get the 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 Class|NameIdPair]]
  ListOfXFRACASEntities = MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
  ListOfXFRACASEntities = MyRepository.XFRACAS.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
  '{{APIComment|Search the Entities for the desired Entity name, to find the Entity ID}}
  '{{APIComment|Search the Entities for the desired Entity name, to find the Entity ID}}
  {{APIPrefix|Dim}} DesiredEntityID {{APIPrefix|As Integer}}
  {{APIPrefix|Dim}} DesiredEntityID {{APIPrefix|As Integer}}
Line 48: Line 51:
  '{{APIComment|Serialize the xmlObject into the byteArray.}}
  '{{APIComment|Serialize the xmlObject into the byteArray.}}
  {{APIPrefix|Dim}} SerializeSuccess {{APIPrefix|As Boolean}}
  {{APIPrefix|Dim}} SerializeSuccess {{APIPrefix|As Boolean}}
   SerializeSuccess = MyRepository.[[Repository.SerializeXMLObjectToByteArray|SerializeXMLObjectToByteArray]](byteArray, xmlObject)
   SerializeSuccess = MyRepository.XFRACAS.[[Repository.SerializeXMLObjectToByteArray|SerializeXMLObjectToByteArray]](byteArray, xmlObject)
  '{{APIComment|Import the XML byte array into the entity desired.  In this example, we assume the XML object type describes an Incident.}}
  '{{APIComment|Import the XML byte array into the entity desired.  In this example, we assume the XML object type describes an Incident.}}
  {{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
  {{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
  ImportXMLSystemID = MyRepository.[[Repository.ImportXFRACASXML|ImportXFRACASXML]](DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")
  ImportXMLSystemID = MyRepository.XFRACAS.[[Repository.ImportXFRACASXML|ImportXFRACASXML]](DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")
 
 
=== Reformatted Usage Example ===
{{APIComment|Declare a new repository connection class.}}
        Private WithEvents MyRepository As New [[Repository Class|Repository]]
 
{{APIComment|Connect to the desired Synthesis repository.}}
        Dim Success As Boolean = False
        Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
 
{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
        Dim ListOfXFRACASEntities() As [[NameIdPair Class|NameIdPair]]
        ListOfXFRACASEntities = MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
 
{{APIComment|Search the Entities 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
 
{{APIComment|Define an serializable XML Object.}}
        Dim xmlObject As Object = Nothing
        'populate the xmlObject with values to import
 
{{APIComment|Define the byte array.}}
        Dim byteArray As Byte() = Nothing
 
{{APIComment|Serialize the xmlObject into the byteArray.}}
        Dim SerializeSuccess As Boolean
        SerializeSuccess = MyRepository.[[Repository.SerializeXMLObjectToByteArray|SerializeXMLObjectToByteArray]](byteArray, xmlObject)
 
{{APIComment|Import the XML byte array into the entity desired.  In this example, we assume the XML object type describes an Incident.}}
        Dim ImportXMLSystemID As Integer
        ImportXMLSystemID = MyRepository.ImportXFRACASXML(DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")

Revision as of 15:54, 27 May 2015



Synthesis API allows the programmer to import XML files into XFRACAS. The page contains the logic of that importation. All XML files must first be in the XFRACAS format before they can be successfully imported. To view XFRACAS formats, refer to the XFRACAS XML Import Documentation business logic contents.


This is different from importing XML files directly into XFRACAS. If the programmer wishes to import files directly into XFRACAS instead of using Synthesis API, they should view the XFRACAS XML Import Documentation for the steps of that importation.

The ImportXFRACASXML method uploads an import byte array for processing and returns the system ID.

Syntax

  • ImportXFRACASXML( entityID As Integer, ImportType As XFRACASImportType , byteData As Byte(), fileTitle As String, fileDescription As String) As Integer

Parameters:

entityID:The ID of the entity to import into.
ImportType: The type of XFRACAS Import to utilize, specified as XFRACASImportType.
byteData: The byte array of the XML to import.
fileTitle: The file title of the XML file byte array to import.
fileDescription: A description of the XML to import.

Usage Example

Code Block

' Declare a new repository connection class. 
Private WithEvents MyRepository As New Repository

' Connect to the desired Synthesis repository. 
DimSuccessAs Boolean=False
Success = MyRepository.ConnectToSQLRepository("SQLServerPath", "SQLDatabaseName")

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

' Search the Entities 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 an serializable XML Object. 
Dim xmlObject As Object = Nothing
' populate the xmlObject with values to import 
' Define the byte array. 
DimbyteArray As Byte() = Nothing
' Serialize the xmlObject into the byteArray. 
Dim SerializeSuccess As Boolean
 SerializeSuccess = MyRepository.XFRACAS.SerializeXMLObjectToByteArray(byteArray, xmlObject)
' Import the XML byte array into the entity desired.  In this example, we assume the XML object type describes an Incident. 
Dim ImportXMLSystemID As Integer
ImportXMLSystemID = MyRepository.XFRACAS.ImportXFRACASXML(DesiredEntityID, XFRACASImportType.Incident, byteArray, "XMLFileTitle", "XMLFileDescription")