Upload XML File to XFRACAS: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
(Redirected page to API Tutorials)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:API}}{{Template:BacktoPrevPage}}
#REDIRECT [[API_Tutorials]]
 
ReliaSoft's [http://xfracas.reliasoft.com/ 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 [http://www.reliasoft.com/xfmea/index.htm Xfmea], [http://www.reliasoft.com/rcm/index.htm RCM++] or [http://www.reliasoft.com/rbi/index.htm 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 [http://www.synthesisplatform.net/XFRACAS/en/XML_XFRACAS9_and_10.pdf XFRACAS9/10 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.
 
'''VB.NET'''
{{APIPrefix|Imports}} SynthesisAPI
{{APIPrefix|Module}} Module1
    {{APIPrefix|Sub}} Main()
  {{APIComment|'Connect to the Synthesis enterprise repository.}}
    {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
    MyRepository.ConnectToSQLRepository({{APIString|"ServerName"}}, {{APIString|"DatabaseName"}}){{APIComment|'Replace with values for test repository.}}
  {{APIComment|'Get a list of all available XFRACAS entities.}}
    {{APIPrefix|Dim}} ListOfEntities() {{APIPrefix|As}} NameIdPair
    ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities
  {{APIComment|'Select an XFRACAS entity. This example gets the first available entity in the array.}}
    {{APIPrefix|Dim}} EntityID {{APIPrefix|As}} Integer
    EntityID = ListOfEntities(0).ID
  {{APIComment|'Upload the XML file to the import queue of the XFRACAS entity. This code assumes that an XML file}}
  {{APIComment|'called XMLData.xml contains XFRACAS incidents and is saved in the C drive.}}
    {{APIPrefix|Dim}} j {{APIPrefix|As}} Integer
    j = MyRepository.XFRACAS.ImportXfracasXmlFile(EntityID, SynthesisAPI.XFRACASImportType.Incident, {{APIString|"C:\XMLData.xml"}}, {{APIString|"My new data"}})
 
    {{APIPrefix|End Sub}}
{{APIPrefix|End Module}}
 
===Discussion===
Begin by connecting to a Synthesis enterprise repository that contains XFRACAS data. Here, we use the [[Repository.ConnectToSQLRepository|ConnectToSQLRepository]] method to connect to an SQL repository. (For Oracle, use the [[Repository.ConnectToOracleRepository|ConnectToOracleRepository]] method.) 
 
{{APIComment|'Connect to the Synthesis enterprise repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToSQLRepository({{APIString|"ServerName"}}, {{APIString|"DatabaseName"}}){{APIComment|'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 [[Repository.XFRACAS.GetAllXFRACASEntities|XFRACAS.GetAllXFRACASEntities]] method.
  {{APIComment|'Get a list of all available XFRACAS entities.}}
    {{APIPrefix|Dim}} ListOfEntities() {{APIPrefix|As}} NameIdPair
    ListOfEntities = MyRepository.XFRACAS.GetAllXfracasEntities
 
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.}}
    {{APIPrefix|Dim}} EntityID {{APIPrefix|As}} Integer
    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.
 
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).
 
  {{APIComment|'Upload the XML file to the import queue of the XFRACAS entity. This code assumes that an XML file}}
  {{APIComment|'called XMLData.xml contains XFRACAS incidents and is saved in the C drive.}}
    {{APIPrefix|Dim}} j {{APIPrefix|As}} Integer
    j = MyRepository.XFRACAS.ImportXfracasXmlFile(EntityID, XFRACASImportType.Incident, {{APIString|"C:\XMLData.xml"}}, {{APIString|"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.
 
{{APIComment|'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.
* 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.
 
 
'''Common Error Responses on File Upload'''
{|border="1" align="center" cellpadding="5" cellspacing="0" style="border-collapse: collapse; width:;"
|- style="background:#f0f0f0;"
|Response||Description
|-
|Connection failed <br>or<br><br> 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 <br>or<br><br> Invalid user passed
|May occur when you’ve entered the incorrect server or database name for the enterprise repository.<br><br> 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===
*[[Repository.XFRACAS.GetAllXFRACASEntities|Repository.XFRACAS.GetAllXFRACASEntities Method]]
*[[Repository.XFRACAS.ImportXFRACASXMLFile|Repository.XFRACAS.ImportXFRACASXMLFile Method]]

Latest revision as of 22:12, 12 April 2017

Redirect to: