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