You are viewing limited content. For full access, please sign in.

Question

Question

ClientAutomation.ClientManager.GetAllClientWindows does not find main window of already opened client

asked on July 27, 2015

I am trying to write a LF Workflow custom activity which generates pages for a document. Generating page part of the code worked in a stand-alone program. When I tried to use the code inside a custom activity code, the GetAllClientWindows() function does NOT find the main window of the client, which was already opened. Does it mean Workflow cannot interact with ClientAutomation? Thanks.   

    Public Class GeneratePagesActivity
        Inherits CustomSingleEntryActivity

        'Global variables
        Dim myGeneratePagesOptions As New Laserfiche.ClientAutomation.GeneratePagesOptions()

        ''' <summary>
        ''' Called when the activity is run by the workflow server. Implement the logic of your activity in this method. 
        ''' Access methods for setting tokens, getting token values, and other functions from the base class or the execution 
        ''' context parameter. 
        ''' </summary>
        Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus
            Using wrapper As ConnectionWrapper = executionContext.OpenConnectionRA92()
                Dim mySession As Laserfiche.RepositoryAccess.Session = CType(wrapper.Connection, Session)
                ' Note: You must add the Laserfiche.RepositoryAccess reference to this project for this to work.
                ' TODO: Your code here

                Dim entryInfo As LaserficheEntryInfo = Me.GetEntryInformation(executionContext)
                Dim docInfo As DocumentInfo = Laserfiche.RepositoryAccess.Document.GetDocumentInfo(entryInfo.Id, mySession)
                If docInfo IsNot Nothing AndAlso docInfo.PageCount = 0 Then
                    Using lfclient As New ClientManager()
                        'Get Client program's main window (FolderBrowser)
                        Dim OpenFolderBrowsers As IList(Of ClientWindow) = lfclient.GetAllClientWindows(ClientWindowType.Main)
                        If OpenFolderBrowsers Is Nothing OrElse OpenFolderBrowsers.Count = 0 Then
                            Throw New ApplicationException("Cannot find a client window.")
                        End If
                        Dim myFolderBrowser As MainWindow = TryCast(OpenFolderBrowsers(0), MainWindow)

                        'Generate pages
                        GeneratePagesForDocument(myFolderBrowser, entryInfo.Id)

                        'Generate text if possible
                        Dim myTE As TextExtractor = TextExtractor.LoadExtractor
                        myTE.ExtractFrom(docInfo)
                    End Using
                End If
            End Using

            Return MyBase.Execute(executionContext)
        End Function

        Private Sub GeneratePagesForDocument(myFolderBrowser As MainWindow, docEntry As Integer)
            'Generate image pages. This only works with client programm opened.
            myGeneratePagesOptions.ShowUI = False

            Dim docs As New List(Of Integer)
            docs.Add(docEntry)

            ' Generate image pages for the specified electronic document.
            myFolderBrowser.GeneratePages(docs, myGeneratePagesOptions)
        End Sub
    End Class

 

0 0

Replies

replied on July 27, 2015

Workflow runs as a service, there is no way to launch the Client or interact with the Client window open in another user's session (potentially on a different machine).

1 0
replied on January 5, 2016 Show version history

One way i could think of doing it by having workflow send a post request with entry id to a web service on same machine as LF Client then run the same code to convert it to pages.

0 0
replied on July 28, 2015

There are not any functions built into Laserfiche to really automate the conversion of PDF to TIFF.  If you search for Ghostscripts, you will find several posts with examples of how to convert PDF to TIFF using the GhostScript DLL.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.