Repository.XFRACAS.WriteMessageToDiagnosticsLog: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:


== Example ==
== Example ==
The following example demonstrates how to write messages and exceptions to the XFRACAS diagnostics log. It assumes that the repository has existing connections to XFRACAS entities.  
The following example demonstrates how to write messages and exceptions to the XFRACAS diagnostics log. It assumes that the enterprise repository has existing connections to XFRACAS entities.  


  '''VB.NET'''
  '''VB.NET'''
   
   
  {{APIComment|'Connect to the Synthesis repository. The following code}}
  {{APIComment|'Connect to the Synthesis enterprise repository.}}
{{APIComment|'assumes that a file called "RSRepository1.rsr10" exists in the C: drive.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} Success {{APIPrefix|As}} Boolean
   {{APIPrefix|Dim}} Success {{APIPrefix|As}} Boolean
   Success = MyRepository.ConnectToRepository ({{APIString|"C:\RSRepository1.rsr10"}})
   Success = MyRepository.ConnectToSQLRepository ({{APIString|"MyServer"}}, {{APIString|"MyDatabase"}})
   
   
  {{APIComment|'Record a message to diagnostic log if the connection to the repository is successful.}}
  {{APIComment|'Record a message to diagnostic log if the connection to the repository is successful.}}
Line 44: Line 43:
   {{APIPrefix|Catch}} Ex {{APIPrefix|As}} Exception
   {{APIPrefix|Catch}} Ex {{APIPrefix|As}} Exception
     {{APIComment|'Write error message to diagnostics log.}}
     {{APIComment|'Write error message to diagnostics log.}}
       MyRepository.XFRACAS.WriteExceptionToDiagosticsLog(Ex, XFRACASDiagnosticsEntryType.Error, {{APIPrefix|"Reading Entities"}})
       MyRepository.XFRACAS.WriteExceptionToDiagosticsLog(Ex, XFRACASDiagnosticsEntryType.Error, {{APIString|"Reading Entities"}})
   
   
   {{APIPrefix|End Try}}
   {{APIPrefix|End Try}}
  {{APIPrefix|End If}}
  {{APIPrefix|End If}}

Revision as of 15:22, 5 November 2015

Template:InProgress

APIWiki.png


Member of: SynthesisAPI9.Repository


Writes a message to the XFRACAS diagnostics log.

Syntax

.WriteMessageToDiagnosticsLog (message, entryType)

Parameters

message

Required. String. The message to write to the XFRACAS diagnostics log.

entryType

Required. The XFRACAS diagnostics type. Can be any XFRACASDiagnosticsEntryType enumeration.


Example

The following example demonstrates how to write messages and exceptions to the XFRACAS diagnostics log. It assumes that the enterprise repository has existing connections to XFRACAS entities.

VB.NET

 'Connect to the Synthesis enterprise repository. 
  Dim MyRepository As New Repository
  Dim Success As Boolean
  Success = MyRepository.ConnectToSQLRepository ("MyServer", "MyDatabase")

 'Record a message to diagnostic log if the connection to the repository is successful. 
  If Success Then
  MyRepository.XFRACAS.WriteMessageToDiagnosticsLog("Successfully connected to repository", XFRACASDiagnosticsEntryType.Information)

  'Get a list of all XFRACAS entities connected to the repository.  
  Try
     Dim ListOfXFRACASEntities() As NameIdPair
     ListofXFRACASEntities = MyRepository.XFRACAS.GetAllXFRACASEntities

     Dim i As Integer
     For i = 0 To ListOfXFRACASEntities.GetUpperBound(0)
           MessageBox.Show(ListOfXFRACASEntities(i).Name)
     Next 

  Catch Ex As Exception
     'Write error message to diagnostics log. 
     MyRepository.XFRACAS.WriteExceptionToDiagosticsLog(Ex, XFRACASDiagnosticsEntryType.Error, "Reading Entities")

  End Try
End If