Repository.XFRACAS.WriteMessageToDiagnosticsLog: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
mNo edit summary
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{DISPLAYTITLE:Repository.XFRACAS.WriteMessageToDiagnosticsLog Method}}{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}


{{Template:Repository.WriteToDiagnosticsLog (string,XFRACASDiagnosticEntryType).Cmt}}
 
<onlyinclude>Writes a message to the XFRACAS diagnostics log.</onlyinclude>


== Syntax ==
== Syntax ==
*WriteToDiagnosticsLog(message {{APIPrefix|As String}} , entrytype {{APIPrefix|As}} [[XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticEntryType]])
'''.WriteMessageToDiagnosticsLog''' (''message'', ''entryType'')


Parameters
===Parameters===
:''message'': Message to write to the diagnostics log
''message''
:''entryType'': The type of diagnostics entry type, specified as [[XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]]


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


= Usage Example =
''entryType''
{{APIComment|Code Block}}


:Required. The XFRACAS diagnostics type. Can be any [[XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]] enumeration.
== Example ==
The following example demonstrates how to write messages and exceptions to the XFRACAS diagnostics log.
'''VB.NET'''
{{APIComment|'Connect to the Synthesis enterprise repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIPrefix|Dim}} Success {{APIPrefix|As}} Boolean
  Success = MyRepository.ConnectToSQLRepository ({{APIString|"MyServer"}}, {{APIString|"MyDatabase"}})
{{APIComment|'Record a message to diagnostic log if the connection to the repository is successful.}}
  {{APIPrefix|If}} Success {{APIPrefix|Then}}
  MyRepository.XFRACAS.WriteMessageToDiagnosticsLog({{APIString|"Successfully connected to repository"}}, XFRACASDiagnosticsEntryType.Information)
  {{APIComment|'Get a list of all XFRACAS entities connected to the repository.}}
  {{APIPrefix|Try}}
      {{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} NameIdPair
      ListofXFRACASEntities = MyRepository.XFRACAS.GetAllXFRACASEntities
      {{APIPrefix|Dim}} i {{APIPrefix|As}} Integer
      {{APIPrefix|For}} i = 0 {{APIPrefix|To}} ListOfXFRACASEntities.GetUpperBound(0)
            MessageBox.Show(ListOfXFRACASEntities(i).Name)
      {{APIPrefix|Next}}
  {{APIPrefix|Catch}} Ex {{APIPrefix|As}} Exception
    {{APIComment|'Write error message to diagnostics log.}}
      MyRepository.XFRACAS.WriteExceptionToDiagnosticsLog(Ex, XFRACASDiagnosticsEntryType.Error, {{APIString|"Reading Entities"}})
   
   
'{{APIComment|Connect to the Synthesis repository.}}
  {{APIPrefix|End Try}}
{{APIPrefix|Dim}} Success {{APIPrefix|As Boolean}} = MyRepository.[[Repository.ConnectToRepository|ConnectToRepository]]("RepositoryFileNamePath")
{{APIPrefix|End If}}
'{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
{{APIPrefix|If}} success {{APIPrefix|Then}}
        MyRepository.WriteToDiagnosticsLog("Successfully connected to repository", SynthesisAPI.[[XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]].Information)
    {{APIPrefix|Try}}
        {{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} SynthesisAPI.[[NameIdPair Class|NameIdPair]]= MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
        {{APIPrefix|For}} i {{APIPrefix|As Integer}} = 0 {{APIPrefix|To}} ListOfXFRACASEntities.GetUpperBound(0)
                    MessageBox.Show(ListOfXFRACASEntities(i).Name)
        {{APIPrefix|Next}}
        '{{APIComment|Write error message to diagnostics log}}
    {{APIPrefix|Catch}} ex {{APIPrefix|As}} Exception
        MyRepository.WriteToDiagosticsLog(ex, SynthesisAPI.[[XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]].Error, "Reading Entities")
    {{APIPrefix|End Try}}
  {{APIPrefix|End If}}

Latest revision as of 16:45, 10 March 2016

APIWiki.png


Member of: SynthesisAPI.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.

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.WriteExceptionToDiagnosticsLog(Ex, XFRACASDiagnosticsEntryType.Error, "Reading Entities")

  End Try
End If