Repository.XFRACAS.ImportXFRACASXML: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{DISPLAYTITLE:Repository.XFRACAS.ImportXfracasXml Method}}{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}


[[Synthesis API Reference|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.


<onlyinclude>Uploads the XML byte array to the XFRACAS import queue. Returns an '''Integer''' that represents the record ID of the byte array.</onlyinclude>


This is different than the 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.
{{Template:API_XFRACASNote}}


== Syntax ==
== Syntax ==
*ImportXFRACASXML( entityID {{APIPrefix|As Integer}}, ImportType {{APIPrefix|As}} [[XFRACASImportType]] , byteData {{APIPrefix|As Byte()}}, fileTitle {{APIPrefix|As String}}, fileDescription {{APIPrefix|As String}}) {{APIPrefix|As Integer}}


Parameters:
'''.XFRACAS.ImportXfracasXml'''(''entityID'', ''importType'', ''byteData'', ''fileTitle'', ''fileDescription'')
:''entityID'':The ID of the entity to import into.


:''ImportType'': The type of XFRACAS Import to utilize, specified as [[XFRACASImportType]].
===Parameters===


:''byteData'': The byte array of the XML to import.
''entityID''


:''fileTitle'': The file title of the XML file byte array to import.
:Required. Integer. The ID number of the XFRACAS entity to import the data into.  


:''fileDescription'': A description of the XML to import.
''importType''


== Usage Example ==
:Required. The type of XFRACAS element (e.g., incident, problem, etc.) to import. Can be any [[XFRACASImportType Enumeration|XFRACASImportType]] constant.
{{APIComment|Code Block}}


'{{APIComment|Declare a new repository connection class.}}
''byteData''
{{APIPrefix|Private WithEvents MyRepository As New [[Repository Class|Repository]]}}
'{{APIComment|Connect to the desired Synthesis repository.}}
{{APIPrefix|Dim}}Success{{APIPrefix|As Boolean}}={{APIPrefix|False}}
Success = MyRepository.[[Repository.ConnectToSQLRepository|ConnectToSQLRepository]]("SQLServerPath", "SQLDatabaseName")
'{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
{{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} [[NameIdPair Class|NameIdPair]]
ListOfXFRACASEntities = MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
'{{APIComment|Search the Entities for the desired Entity name, to find the Entity ID}}
{{APIPrefix|Dim}} DesiredEntityID {{APIPrefix|As Integer}}
        For Each Entity {{APIPrefix|As}} NameIdPair In ListOfXFRACASEntities()
            If Entity.Name = "DesiredEntityName"
              DesiredEntityID = Entity.ID
              Exit For
            End If
        Next
'{{APIComment|Define an serializable XML Object.}}
{{APIPrefix|Dim}} xmlObject {{APIPrefix|As Object}} = {{APIPrefix|Nothing}}
'{{APIComment|populate the xmlObject with values to import}}
'{{APIComment|Define the byte array.}}
{{APIPrefix|Dim}}byteArray {{APIPrefix|As}} Byte() = {{APIPrefix|Nothing}}
'{{APIComment|Serialize the xmlObject into the byteArray.}}
{{APIPrefix|Dim}} SerializeSuccess {{APIPrefix|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.}}
{{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
ImportXMLSystemID = MyRepository.[[Repository.ImportXFRACASXML|ImportXFRACASXML]](DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")


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


=== Reformatted Usage Example ===
''fileTitle''
{{APIComment|Declare a new repository connection class.}}
        Private WithEvents MyRepository As New [[Repository Class|Repository]]


{{APIComment|Connect to the desired Synthesis repository.}}
:Required. String. The file title of the XML file byte array to import.
        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.}}
''fileDescription''
        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}}
:Required. String. A description of the XML to import.
        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.}}
== Example ==
        Dim byteArray As Byte() = Nothing


{{APIComment|Serialize the xmlObject into the byteArray.}}
'''VB.NET'''
        Dim SerializeSuccess As Boolean
        SerializeSuccess = MyRepository.[[Repository.SerializeXMLObjectToByteArray|SerializeXMLObjectToByteArray]](byteArray, xmlObject)
{{APIComment|'Connect to a Synthesis enterprise repository.}}
 
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|Import the XML byte array into the entity desired.  In this example, we assume the XML object type describes an Incident.}}
  MyRepository.ConnectToSQLRepository({{APIString|"MyServer"}}, {{APIString|"MyDatabase"}})
        Dim ImportXMLSystemID As Integer
        ImportXMLSystemID = MyRepository.ImportXFRACASXML(DesiredEntityID, [[XFRACASImportType]].Incident, byteArray, "XMLFileTitle", "XMLFileDescription")
{{APIComment|'Define a serializable XML object, and then populate it with values to import.}}
  {{APIPrefix|Dim}} xmlObject {{APIPrefix|As Object}} = {{APIPrefix|Nothing}}
  {{APIComment|...}}
{{APIComment|'Define the byte array, and then serialize the object to the byte array.}}
  {{APIPrefix|Dim}} byteArray {{APIPrefix|As}} Byte() = {{APIPrefix|Nothing}}
  MyRepository.XFRACAS.SerializeXMLObjectToByteArray(byteArray, xmlObject)
{{APIComment|'Import the XML byte array into XFRACAS entity ID# 10.}}
  {{APIPrefix|Dim}} ImportXMLSystemID {{APIPrefix|As Integer}}
  ImportXMLSystemID = MyRepository.XFRACAS.ImportXfracasXml(10, XFRACASImportType.Incident, byteArray, {{APIString|"XMLFileTitle"}}, {{APIString|"XMLFileDescription"}})

Latest revision as of 17:00, 12 August 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Uploads the XML byte array to the XFRACAS import queue. Returns an Integer that represents the record ID of the byte array.


Remarks: The XML file will be processed at the next scheduled import, or you can choose to process immediately all items in the import queue by using the ProcessXfracasImports method.

For the XML file to be imported successfully, you must have the "Manage Import" admin permission in the XFRACAS entity where you are uploading the file, and the XML file must be in the correct XFRACAS XML format. The XFRACAS 11 Import Business Logic (PDF) document provides a complete description of the XFRACAS format.

Syntax

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

Parameters

entityID

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

importType

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

byteData

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

fileTitle

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

fileDescription

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


Example

VB.NET

 'Connect to a Synthesis enterprise repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToSQLRepository("MyServer", "MyDatabase")

 '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 XFRACAS entity ID# 10. 
  Dim ImportXMLSystemID As Integer
  ImportXMLSystemID = MyRepository.XFRACAS.ImportXfracasXml(10, XFRACASImportType.Incident, byteArray, "XMLFileTitle", "XMLFileDescription")