Repository.WriteToDiagnosticsLog: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
Line 52: Line 52:


== Reformatted Usage Example ==
== Reformatted Usage Example ==
{{APIComment|Declare a new repository connection class.}}
        Private WithEvents MyRepository As [[New Repository]]


{{APIComment|Connect to the Synthesis repository.}}
{{APIComment|Connect to the Synthesis repository.}}
         Dim Success As Boolean = False
         {{APIPrefix|Dim}} Success {{APIPrefix|As Boolean}} = MyRepository.[[Repository.ConnectToRepository|ConnectToRepository]]("RepositoryFileNamePath")
        Success = MyRepository.[[Repository.ConnectToRepository|ConnectToRepository]]("RepositoryFileNamePath")
 
{{APIComment|Start "If" Statement}}
{{APIPrefix|If}} success {{APIPrefix|Then}}
           
{{APIComment|Start "try" Statement}}
{{APIPrefix|Try}}


{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
{{APIComment|Get the list of XFRACAS Entities in the current project in the connected repository.}}
         Dim ListOfXFRACASEntities() As [[NameIdPair Class|NameIdPair]]
         {{APIPrefix|Dim}} ListOfXFRACASEntities() {{APIPrefix|As}} SynthesisAPI.[[NameIdPair Class|NameIdPair]]= MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
        ListOfXFRACASEntities = MyRepository.[[Repository.GetAllXFRACASEntities|GetAllXFRACASEntities]]()
                {{APIPrefix|For}} i {{APIPrefix|As Integer}} = 0 {{APIPrefix|To}} ListOfXFRACASEntities.GetUpperBound(0)
                    MessageBox.Show(ListOfXFRACASEntities(i).Name)
 
{{APIComment|Start diagnostics messages}}
        {{APIPrefix|Next}}
 
 
{{APIComment|Write error message to diagnostics log}}
{{APIPrefix|Catch}} ex {{APIPrefix|As}} Exception
                MyRepository.[[Repository.WriteToDiagnosticsLog|WriteToDiagosticsLog]](ex, SynthesisAPI.[[Repository.XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]].Error, "Reading Entities")


{{APIComment|Import the XML file into the entity desired.  In this example, the first entity is used.}}
{{APIComment|End "try" Statement}}
        Dim ImportXMLSystemID As Integer
  {{APIPrefix|End Try}}
        ImportXMLSystemID = MyRepository.[[Repository.ImportXFRACASXMLFile|ImportXFRACASXMLFile]](ListOfXFRACASEntities(0).ID, [[XFRACASImportType]].Incident, "XMLFileName", "XMLFileDescription")
{{APIPrefix|Else}}


{{APIComment|Process the imported file.}}
{{APIComment|Write warning message to diagnostics log}}
        MyRepository.[[Repository.ProcessXfracasImports|ProcessXfracasImports]]()


{{APIComment|Create place to see where code is breaking instead of writing to your own logfile}}
MyRepository.[[Repository.WriteToDiagnosticsLog|WriteToDiagosticsLog]]("Unable to connect to repository", SynthesisAPI.[[Repository.XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]].Warning)
        MyRepository.[[Repository.WriteToDiagnosticsLog|WriteToDiagosticsLog]]({{APIPrefix|ByVal}}Diagnostics Message {{APIPrefix|As}}String, entryType {{APIPrefix|AS}}[[Repository.XFRACASDiagnosticsEntryType Enumeration|XFRACASDiagnosticsEntryType]].Information)
  {{APIPrefix|End If}}

Revision as of 16:37, 28 April 2014



This subroutine adds diagnostic information into the diagnostics log. There are two methods that can be used. Both are shown.

This method is an overloaded method which means the same signature will accept different sets of arguments. Both available methods are shown separately.

First Available Method

Writes a message to the diagnostics log

Syntax

Parameters

message: Message to write to the diagnostics log
entryType: The type of diagnostics entry type, specified as XFRACASDiagnosticsEntryType

Second Available Method

Writes exception information to the diagnostics log

Syntax

Parameters

exObject: Represents an error that occurs during application execution
entryType: The type of diagnostics entry type, specified as XFRACASDiagnosticsEntryType
comment: Optional comment to write to the diagnostics log

Usage Example

Code Block


' Connect to the Synthesis repository. 
Dim Success As Boolean = MyRepository.ConnectToRepository("RepositoryFileNamePath")
 ' Get the list of XFRACAS Entities in the current project in the connected repository. 
  If success Then
           Try
               Dim ListOfXFRACASEntities() As SynthesisAPI.NameIdPair= MyRepository.GetAllXFRACASEntities()
               For i As Integer = 0 To ListOfXFRACASEntities.GetUpperBound(0)
                   MessageBox.Show(ListOfXFRACASEntities(i).Name)
               Next
          ' Write error message to diagnostics log 
           Catch ex As Exception
               MyRepository.WriteToDiagosticsLog(ex, SynthesisAPI.XFRACASDiagnosticsEntryType.Error, "Reading Entities")
           End Try
  Else
          ' Write warning message to diagnostics log 
           MyRepository.WriteToDiagosticsLog("Unable to connect to repository", SynthesisAPI.XFRACASDiagnosticsEntryType.Warning)
  End If



Reformatted Usage Example

Connect to the Synthesis repository.

       Dim Success As Boolean = MyRepository.ConnectToRepository("RepositoryFileNamePath")

Start "If" Statement

If success Then
            

Start "try" Statement

Try

Get the list of XFRACAS Entities in the current project in the connected repository.

       Dim ListOfXFRACASEntities() As SynthesisAPI.NameIdPair= MyRepository.GetAllXFRACASEntities()
               For i As Integer = 0 To ListOfXFRACASEntities.GetUpperBound(0)
                   MessageBox.Show(ListOfXFRACASEntities(i).Name)

Start diagnostics messages

        Next


Write error message to diagnostics log

Catch ex As Exception
               MyRepository.WriteToDiagosticsLog(ex, SynthesisAPI.XFRACASDiagnosticsEntryType.Error, "Reading Entities")

End "try" Statement

  End Try
Else

Write warning message to diagnostics log

MyRepository.WriteToDiagosticsLog("Unable to connect to repository", SynthesisAPI.XFRACASDiagnosticsEntryType.Warning)
  End If