Repository.XFRACAS.ImportXFRACASXML: Difference between revisions
John Leavitt (talk | contribs) No edit summary |
John Leavitt (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
Uploads an import byte array for processing and returns the system ID. | Uploads an import byte array for processing and returns the system ID. | ||
For | For information on the business logic of XFRACAS XML Import click here: [[XFRACAS XML Import Documentation]] | ||
== Method Syntax == | == Method Syntax == | ||
{{APIName|Public Function '''ImportXFRACASXML'''(}} | {{APIName|Public Function '''ImportXFRACASXML'''(}} |
Revision as of 18:38, 25 October 2013
Uploads an import byte array for processing and returns the system ID.
For information on the business logic of XFRACAS XML Import click here: XFRACAS XML Import Documentation
Method Syntax
Public Function ImportXFRACASXML(
ByVal
entityID
As Integer
,
ByVal
ImportType
As
XFRACASImportType,
ByVal
byteData
As Byte()
,
ByVal
fileTitle
As String
,
ByVal
fileDescription
As String
)
As Integer
Uploads an import file bytestream for processing and returns the system ID of the uploaded
Parameters
entityID The ID of the entity to import into.
ImportType The type of XFRACAS Import to utilize.
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.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.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.ImportXFRACASXML(DesiredEntityID, XFRACASImportType.Incident, byteArray, "XMLFileTitle", "XMLFileDescription")
Reformatted Usage Example
Declare a new repository connection class.
Private WithEvents MyRepository As New Repository
Connect to the desired Synthesis repository.
Dim Success As 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.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.
Dim byteArray As Byte() = Nothing
Serialize the xmlObject into the byteArray.
Dim SerializeSuccess As Boolean SerializeSuccess = MyRepository.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.ImportXFRACASXML(DesiredEntityID, XFRACASImportType.Incident, byteArray, "XMLFileTitle", "XMLFileDescription")