Article Details
Id:18081
Product:finPOWER Connect
Type:NEW
Version:3.04.00
Opened:15/04/2021
Closed:08/06/2021
Released:30/06/2021
Job: J026374

HTML Widgets; New mechanism to create File Export Packages from processes

A new mechanism to allow HTML Widgets (or background processes, including finPOWER Connect Cloud Schedule Processes) to create export package that appear in the new "Downloads" tab in the Processes view in finPOWER Connect Cloud has been added.

An Export Package can contain one or more files. Within the file system, these are represented by individual files but from the Processes view, Downloads tab in finPOWER Connect, all files in a package are shown as a single entry and can be downloaded individually or, if there is more than one file, bundled together in a Zip file.

When running from finPOWER Connect Cloud, the exported files will be stored in a /Processes folder under the Reporting Folder specified on the Documents page of the Web Configurations form.

When running from finPOWER Connect desktop, the files will be sent to the User's Export folder.

The following Script sample slowly creates a File Export Package containing 10 text files:

Dim FileExportPackageHandler As finwsFileExportPackageHandler
Dim FileName As String
Dim i As Integer
Dim Success As Boolean

' Assume Success
Success = True

' Create a new Package
Success = finBL.HtmlWidgetUtilities.CreateProcessFileExportPackageHandler("Test Package", ScriptInfo.ScriptId, FileExportPackageHandler)

' Test
If Success Then
  With FileExportPackageHandler
    For i = 0 To 100
      ' Add a file (once every 10 iterations)
      If i Mod 10 = 0 Then
        ' Get Package File Name and add to list (since we're not passing in a unique name, this will automatically be incremented)
        FileName = .CreateFileName("Test.txt")

        ' Write File
        If Not finBL.Runtime.FileUtilities.WriteTextFile(fileName, "This is file " & i) Then
          Success = False
          Exit For
        End If
      End If

      ' Update Status (ignore errors)
      ' NOTE: This also updates the Package's status file
      .StatusUpdateInProgress(i)

      ' Pause
      System.Threading.Thread.Sleep(200)
    Next

    ' Update Status (ignore errors)
    If Success Then
      .StatusUpdateComplete()
    Else
      .StatusUpdateFailed(finBL.Error.Message(True))
    End If
  End With
End If

NOTE: When running from finPOWER Connect desktop, there is an optional parameter in the StatusUpdateComplete() method to "finaliseDesktopExport". If this is True (the default) then the .status file will be removed and the package prefix (the GUID) will be removed from all of the package files.