Repository.XFRACAS.ImportXFRACASXML: Difference between revisions
Jump to navigation
Jump to search
Kate Racaza (talk | contribs) No edit summary |
Kate Racaza (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
<onlyinclude>Imports an | <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, | 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|'Add code to connect to a Synthesis repository.}} | |||
{{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository | |||
{{APIComment|...}} | |||
{{APIComment|'Get a list of XFRACAS entities in the current project in the connected repository.}} | |||
{{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} NameIdPair | |||
ListOfXFRACASEntities = MyRepository.XFRACAS.GetAllXFRACASEntities() | |||
{{APIComment|'Search the entities list for the desired entity name, to find the Entity ID}} | |||
{{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 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 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
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")