' SummaryPage2_RecentActions_Summary
Option Explicit On
Option Strict On

' #################################################################
' Recent Actions Summary

' Version: 1.00 (26/04/2016)

' Usage: The Recent Actions report in the Task Manager
' #################################################################

' Constants

' Objects
Private mRecentActions As ISRecentActions

' Other
Private mThreaded As Boolean

Public Function Main(source As Object,
                     eventId As String,
                     eventArgs As ISKeyValueList,
                     ByRef handled As Boolean,
                     ByRef returnValues As ISKeyValueList,
                     ByRef text As String) As Boolean

  Dim UserPk As Integer

  ' Assume Success
  Main = True

  ' Initialise
  UserPk = eventArgs.GetInteger("UserPk")

  ' Get or Load Recent Actions
  If UserPk = finBL.CurrentUser.UserPk AndAlso Not finBL.IsRunningFromWeb Then
    ' Current User (and not running from the Web)
    mRecentActions = finBL.RecentActions
  Else
    mRecentActions = finBL.CreateRecentActions()
    mRecentActions.LoadPk(UserPk)
  End If

  ' Get Constants
  With ScriptInfo.Constants
  End With

  ' Handle Events
  Select Case eventId
    Case ""
      ' Main event, i.e., return main page content
      Main = CreatePage(text)
  End Select

End Function

Private Function CreatePage(ByRef html As String) As Boolean

  Dim Ok As Boolean
  Dim sb As finHtmlSummaryPage2StringBuilder

  ' Assume Success
  Ok = True

  ' Initialise
  sb = finBL.CreateHtmlSummaryPage2StringBuilder()

  ' Initialise HTML
  With sb
    .Initialise(ScriptInfo)
    .HtmlHeaderBegin("", isefinSummaryPageStyle.None)
    .HtmlHeaderEnd()
  End With

  ' Recent Actions Summary
  sb.SummaryTablesAppend(finBL.SummaryPageStandardBlocks.RecentActions_Summary(ScriptInfo, mRecentActions, 99, True, Nothing))

  ' Finalise HTML
  sb.HtmlFinalise()

  ' Resolve Templates
  html = sb.ToString(True)

  Return Ok

End Function