Difference between revisions of "Upload XML File to XFRACAS"

From ReliaWiki
Jump to navigation Jump to search
Line 58: Line 58:
 
     ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities
 
     ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities
  
Then, we get the ID# of the target XFRACAS entity:  
+
Then we get the ID# of the target XFRACAS entity:  
  
 
   {{APIComment|'Select an XFRACAS entity. This example gets the first available entity in the array.}}
 
   {{APIComment|'Select an XFRACAS entity. This example gets the first available entity in the array.}}
Line 64: Line 64:
 
     EntityID = ListOfEntities(0).ID
 
     EntityID = ListOfEntities(0).ID
  
The ID# of the entity is a required input for the [[Repository.XFRACAS.ImportXFRACASXMLFile|XFRACAS.ImportXFRACASXMLFile]] method, which uploads the XML file to XFRACAS. In addition, you are required to specify the type of XFRACAS element (e.g., incident, problem, issue, etc.) described in the XML file. In this example, we're uploading an XML file that contains XFRACAS incidents.
+
We use the [[Repository.XFRACAS.ImportXFRACASXMLFile|XFRACAS.ImportXFRACASXMLFile]] method to upload the XML file to XFRACAS. The method requires that you specify the entity ID and the type of XFRACAS element (e.g., incident, problem, issue, etc.) described in the XML file. In this example, we're uploading an XML file that contains XFRACAS incidents.
  
 
Note that the method only sends the XML file to the import queue of the XFRACAS entity; it doesn't process the file for import. The import will need to be triggered, either via the XFRACAS web interface or by the API (see the Notes section below for details).
 
Note that the method only sends the XML file to the import queue of the XFRACAS entity; it doesn't process the file for import. The import will need to be triggered, either via the XFRACAS web interface or by the API (see the Notes section below for details).
Line 88: Line 88:
  
 
* Successful uploads are shown in the '''Inbox''' area of the page. If there are problems with the upload, the Synthesis API will return an error response. See the following table for a list of common error responses.
 
* Successful uploads are shown in the '''Inbox''' area of the page. If there are problems with the upload, the Synthesis API will return an error response. See the following table for a list of common error responses.
* Successfully imports are shown in the '''Processed''' area of the page. If there are problems with the import, the '''Error''' area will show an error log, which you can click to read the details of the error.
+
* Successful imports are shown in the '''Processed''' area of the page. If there are problems with the import, the '''Error''' area will show an error log, which you can click to read the details of the error.
  
  

Revision as of 18:39, 3 April 2017

APIWiki.png


<< Back to Tutorials Main Page

ReliaSoft's XFRACAS is a web-based, closed-loop, incident/failure/data reporting, analysis and corrective action system. You can import data into XFRACAS either via XML files or directly from ReliaSoft's Xfmea, RCM++ or RBI software. In addition, you can use the Synthesis API to create custom solutions for importing XML data. In this tutorial, you'll learn the basics for uploading an XML file to XFRACAS and processing it for import.

Prerequisites

Before you begin:

  • You must at least have read access to a Synthesis enterprise test repository that contains XFRACAS data.
  • In XFRACAS, you must at least have the "Manage Import" admin permissions to an XFRACAS entity.
  • You will need to provide a sample XML file to work with the tutorial. 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 format.


Tutorial: Upload XML file to XFRACAS

The following example demonstrates a basic solution for uploading an XML file to an XFRACAS entity. A discussion of the example follows.

The VBA version of the code sample is available here.

VB.NET

Imports SynthesisAPI 

Module Module1
   Sub Main()

  'Connect to the Synthesis enterprise repository. 
   Dim MyRepository As New Repository
   MyRepository.ConnectToSQLRepository("ServerName", "DatabaseName") 'Replace with values for test repository. 

  'Get a list of all available XFRACAS entities. 
   Dim ListOfEntities() As NameIdPair
   ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities

  'Select an XFRACAS entity. This example gets the first available entity in the array. 
   Dim EntityID As Integer
   EntityID = ListOfEntities(0).ID

  'Upload the XML file to the import queue of the XFRACAS entity. This code assumes that an XML file  
  'called XMLData.xml contains XFRACAS incidents and is saved in the C drive. 
   Dim j As Integer
   j = MyRepository.XFRACAS.ImportXfracasXmlFile(EntityID, SynthesisAPI.XFRACASImportType.Incident, "C:\XMLData.xml", "My new data")
 
   End Sub
End Module

Discussion

Begin by connecting to a Synthesis enterprise repository that contains XFRACAS data. Here, we use the ConnectToSQLRepository method to connect to an SQL repository. (For Oracle, use the ConnectToOracleRepository method.)

 'Connect to the Synthesis enterprise repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToSQLRepository("ServerName", "DatabaseName") 'Replace with values for test repository. 

The next step is to specify the XFRACAS entity that will be receiving the XML file. First, we get an array of all available XFRACAS entities in the repository via the XFRACAS.GetAllXFRACASEntities method.

  'Get a list of all available XFRACAS entities. 
   Dim ListOfEntities() As NameIdPair
   ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities

Then we get the ID# of the target XFRACAS entity:

  'Select an XFRACAS entity. This example gets the first available entity in the array. 
   Dim EntityID As Integer
   EntityID = ListOfEntities(0).ID

We use the XFRACAS.ImportXFRACASXMLFile method to upload the XML file to XFRACAS. The method requires that you specify the entity ID and the type of XFRACAS element (e.g., incident, problem, issue, etc.) described in the XML file. In this example, we're uploading an XML file that contains XFRACAS incidents.

Note that the method only sends the XML file to the import queue of the XFRACAS entity; it doesn't process the file for import. The import will need to be triggered, either via the XFRACAS web interface or by the API (see the Notes section below for details).

  'Upload the XML file to the import queue of the XFRACAS entity. This code assumes that an XML file  
  'called XMLData.xml contains XFRACAS incidents and is saved in the C drive. 
   Dim j As Integer
   j = MyRepository.XFRACAS.ImportXfracasXmlFile(EntityID, XFRACASImportType.Incident, "C:\XMLData.xml", "My new data")


Notes

XML files uploaded to the XFRACAS entity are processed at the next scheduled import, but you can opt to immediately process all the items in the import queue by adding the following code.

 'Force XFRACAS to immediately process all items in the import queue. (Optional) 
  MyRepository.XFRACAS.ProcessXfracasImports

If you prefer to schedule the import at a later time or at recurring intervals, omit the line of code above and set the import schedule via the XFRACAS web interface by choosing Admin > Import, and in the Import Schedule table, click the Edit icon for the desired import type.


Verifying the results of the upload/import

The results of a file upload/import are shown in the Imports page of the XFRACAS web interface (Admin > Tools > Import):

  • Successful uploads are shown in the Inbox area of the page. If there are problems with the upload, the Synthesis API will return an error response. See the following table for a list of common error responses.
  • Successful imports are shown in the Processed area of the page. If there are problems with the import, the Error area will show an error log, which you can click to read the details of the error.


Common Error Responses on File Upload

Response Description
Connection failed
or

Login failed
Common reasons are:
  • You do not have a network connection, or you may have entered the incorrect server name or credentials.
  • The server may not be configured to allow remote connections, has certain firewall settings or is experiencing other issues.
  • You do not have access to the enterprise repository or your user account may be inactive.
  • In SQL Server databases, a login issue may occur if your username is not associated with a SQL Server Login.
There is no connection to a repository
or

Invalid user passed
May occur when you’ve entered the incorrect server or database name for the enterprise repository.

May also occur when you call a repository that does not exist or you’ve inadvertently connected to a standard repository.
You do not have the XFRACAS permissions to perform the operation Occurs when you don’t have Admin permissions to the XFRACAS entity. Also occurs when you call an XFRACAS entity that does not exist.

References