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

Question

Question

base class for LFObjectListing and LFSearchResultListing

asked on November 18, 2015

 

I have a program in LFSO that generating a ILFObjectListing as a sorted list of document in a folder.    We define the columns of the list and the sort order.   We then use the list to get entity id for the document to display in our custom viewer  in another method.

 

We are using the  Search object to generate LFSearchResultListing  which is set up same way as our ILFObjectListing to filter the listing down to a smaller set.   Both ILFObjectListing  and LFSearchResultListing  would need the Document images displayed in the same way,  Rush tag, then Scac from metadata, then Entity Id.

 

Is there way to access in common both ILFObjectListing and LFSearchResultListing, in particular the entity id.      I am assuming since both object are create with similar object that there is a common base class that can be referenced.    

 

Code Sample

Private Function GetFolderDocumentsSCAC(Optional ByRef SCAC As String = "") As ILFObjectListing
        'generates a array of entries that is sorted by, Rush Status, SCAC, ID
        'use global var entryIDList as output

        Dim params As ILFListingParams = New LFEntryListingParams
        Dim listing As ILFObjectListing
        Dim Folder As LFFolder

        'initialization
        Folder = DB.GetEntryByPath("\PendingReturns")
        params.AddStandardColumn(Column_Type.COLUMN_TYPE_NAME)
        listing = Folder.GetEntryListing(params, 100)

        Try
            If cboDepartment.Text <> "" And cboQuickName.Text <> "" Then
                ' Instantiates the folder whose child entries you wish to list.
                ' entryIDNumber should be an integer representing the entry ID of the
                ' folder you wish to process.
                Folder = DB.GetEntryByPath("\" & Me.cboDepartment.Text & _
                            "\" & Me.cboQuickName.Text & "\")

 

                ' Instantiates the parameters for the information you wish to retrieve about
                ' the folder's child entries.


                ' Adds a column for each piece of information we will retrieve about the 
                ' folder.  In this case, we want to get the name and entry type.
                params.AddStandardColumn(Column_Type.COLUMN_TYPE_ID)

                params.AddStandardColumn(Column_Type.COLUMN_TYPE_ENTRYTYPE)
                params.AddStandardColumn(Column_Type.COLUMN_TYPE_CREATEDATE)
                params.AddTemplateFieldColumn("SCAC")
                params.AddTemplateFieldColumn("Batch Number")
                params.AddStandardColumn(Column_Type.COLUMN_TYPE_TAGS)

 

                ' Specifies that the parameters should be sorted by name, in ascending 
                ' order.
                params.AddColumnTypeToSortBy(Column_Type.COLUMN_TYPE_TAGS, Sort_Direction.SORT_DIRECTION_DESC)
                params.AddTemplateFieldToSortBy("SCAC", Sort_Direction.SORT_DIRECTION_ASC)
                params.AddColumnTypeToSortBy(Column_Type.COLUMN_TYPE_ID, Sort_Direction.SORT_DIRECTION_ASC)


                ' Instantiates an ObjectListing object and populates the object with 
                ' the entry listings for the specified folder.
                listing = Folder.GetEntryListing(params, 100)

                ' Creates string arrays to hold the information for each entry.
                Dim entryType(listing.RowCount) As String
                Dim entryName(listing.RowCount) As String
                Dim entryID(listing.RowCount) As Integer
                Dim entrySCAC(listing.RowCount) As String
                Dim entryTag(listing.RowCount) As Object
                Dim entryDate(listing.RowCount) As Date

                EntryIDList.Capacity = listing.RowCount

                ' Iterates through the entries listed in the ObjectListing object to 
                ' retrieve information for each object.  Note that we must start our iteration 
                ' through listing.RowCount at 1, becasue LFSO starts counting at 1, but
                ' use i-1 for the array, because .Net starts counting at 0.
                For i As Integer = 1 To listing.RowCount
                    ' Retrieves the object's type (folder, document or shortcut)
                    entryType(i - 1) = listing.DatumByColTypeAsString(i, Column_Type.COLUMN_TYPE_ENTRYTYPE)
                    ' Retrieves the object's name
                    entryName(i - 1) = listing.DatumByColTypeAsString(i, Column_Type.COLUMN_TYPE_NAME)
                    ' Retrieves the object's id
                    entryID(i - 1) = listing.DatumByColType(i, Column_Type.COLUMN_TYPE_ID)
                    'retrieves the entry's SCAC
                    entrySCAC(i - 1) = listing.DatumByTemplateFieldAsString(i, "SCAC")
                    entryTag(i - 1) = listing.DatumByColType(i, Column_Type.COLUMN_TYPE_TAGS)
                    entryDate(i - 1) = listing.DatumByColType(i, Column_Type.COLUMN_TYPE_CREATEDATE)

                    'populate global vars
                    EntryIDList.Add(entryID(i - 1))

                Next

                TotalDocuments = listing.RowCount
            Else
                TotalDocuments = 0
            End If
            If TotalDocuments > 0 Then
                CurrentDocument = 1
            Else
                CurrentDocument = 0
            End If
        Catch ex As Exception
            MsgBox("Entire function." & vbCr & vbLf & _
            ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, _
                "frmLaserfiche.GetFolderDocumentsSCAC()")
            End
        End Try
        
        Return listing
    End Function

 End Sub
    Private Sub searchScac(ByVal SCAC As String)
        'search for the scac in the current directory
        'uses the laserfiche search feature that use Repository Acess

        Dim lfSearchObject As New LFSearch
        lfSearchObject = DB.CreateSearch
        Dim SearchString As String = String.Empty
        Dim params As LFSearchListingParams = New LFSearchListingParams
        params.AddStandardColumn(Column_Type.COLUMN_TYPE_NAME)


        SearchString = "{LF:LookIn = " & _
        "{[Bills]} & {LF:LOOKIN=""TransInternational\" & frmLaserfiche.cboDepartment.Text & _
                      "\" & frmLaserfiche.cboQuickName.Text & "}"
        lfSearchObject.Command = SearchString
        ' Sets the search command to your search string.

        lfSearchObject.BeginSearch(True)
        ' Continues to run the search until it is complete.

        ' Columns to be return in the listings
        params.AddStandardColumn(Column_Type.COLUMN_TYPE_ID)
        params.AddStandardColumn(Column_Type.COLUMN_TYPE_CREATEDATE)
        params.AddTemplateFieldColumn("SCAC")
        params.AddTemplateFieldColumn("Batch Number")
        params.AddStandardColumn(Column_Type.COLUMN_TYPE_TAGS)

        ' Specifies that the parameters should be sorted by name, in ascending 
        ' order.
        params.AddColumnTypeToSortBy(Column_Type.COLUMN_TYPE_TAGS, Sort_Direction.SORT_DIRECTION_DESC)
        params.AddTemplateFieldToSortBy("SCAC", Sort_Direction.SORT_DIRECTION_ASC)
        params.AddColumnTypeToSortBy(Column_Type.COLUMN_TYPE_ID, Sort_Direction.SORT_DIRECTION_ASC)

        ' Retrieves the specified information for the list of search hits.  The '0' 

        ' indicates that no rows will be pre-loaded.

        Dim results As LFSearchResultListing = lfSearchObject.GetSearchResultListing(params, 100)

        ' Returns the list of search results.


        lfSearchObject.Dispose()

    End Sub

 

Public Function GetDocumentSCAC(ByRef listing As ILFObjectListing) As ILFDocumentPages

        Dim X As Integer
        Dim Y As Integer
        Dim Tempstring As String
        Dim Tempint As Integer

        BalanceDue = False
        RushBill = False
        Auditor = Space(3)
        AuditorDate = Space(8)
        AuditorTime = Space(4)
        Coder = Space(3)
        CoderDate = Space(8)
        CoderTime = Space(4)
        Try
            Array.Clear(SavePageRotate, 1, 10)
            DocFields.UnlockObject()
            Doc.Dispose()
        Catch ex As Exception
        End Try
        If CurrentDocument > 0 Then
            Try
                Doc = DB.GetEntryByID(listing.DatumByColType(CurrentDocument, Column_Type.COLUMN_TYPE_ID))
                If Doc Is Nothing Then
                    MessageBox.Show("No Document was found.  Please try again", "Laserfich Document is Null", MessageBoxButtons.OK)
                    Return Nothing

                End If

                While Doc.IsLocked And CurrentDocument < TotalDocuments
                    CurrentDocument = CurrentDocument + 1
                    Doc.Dispose()

                    Doc = DB.GetEntryByID(listing.DatumByColType(CurrentDocument, Column_Type.COLUMN_TYPE_ID))

                End While

                If CurrentDocument <= TotalDocuments Then
                    DocumentID = Doc.ID
                    DocFields = Doc.FieldData
                    DocFields.LockObject(Lock_Type.LOCK_TYPE_WRITE)
                Else
                    CurrentDocument = 0
                    TotalDocuments = 0
                End If

            Catch ex As Exception
                Doc.Dispose()
                If CurrentDocument < TotalDocuments Then
                    MessageBox.Show("Document " & listing.DatumByColTypeAsString(CurrentDocument, Column_Type.COLUMN_TYPE_NAME) & _
                                     " can not be retrieved from Laserfiche", "Error in GetDocumentSCAC", MessageBoxButtons.OK)
                    CurrentDocument = CurrentDocument + 1

                Else
                    CurrentDocument = 0
                    TotalDocuments = 0
                End If
            End Try

            If CurrentDocument Then
                Try
                    DocPages = Doc.Pages
                    TotalPages = DocPages.Count
                    For X = 1 To TotalPages
                        Page = DocPages.Item(X)
                        If Page.AnnotationCount(Annotation_Type.ANN_TEXTBOX) > 0 Then
                            Dim Annotation As LFTextboxAnnotation

                            For Y = 1 To Page.AnnotationCount(Annotation_Type.ANN_TEXTBOX)
                                Annotation = Page.Annotation(Annotation_Type.ANN_TEXTBOX, Y)
                                Tempstring = Annotation.Text
                                Tempint = InStr(1, Tempstring, vbLf)
                                If Tempint = 0 Then
                                    Tempint = Len(Tempstring) + 1
                                End If
                                Select Case Mid(Tempstring, 1, Tempint - 1)
                                    Case "OK TO PROCESS"
                                        BalanceDue = True
                                        DisplayOkToProcess(Tempstring, Tempint, False)
                                    Case "RUSH BILL"
                                        RushBill = True
                                        BalanceDue = True
                                    Case "FREIGHT BILL CORRECTION"
                                        DisplayFreightBillCorrection(Tempstring, Tempint, False)
                                    Case "GL NUMBER"
                                        DisplayGLNumber(Tempstring, Tempint, False)
                                    Case "CODING"
                                        DisplayCoding(Tempstring, Tempint, False)
                                End Select
                            Next Y
                        End If
                    Next
                Catch ex As Exception
                    MsgBox("Exporting image." & vbCr & vbLf & _
                        ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, _
                        "frmLaserfiche.GetDocumentSCAC()")
                    End
                End Try
            Else
                TotalPages = 0
            End If
        Else
            TotalPages = 0
        End If
        Try
            If CurrentDocument > 1 Then
                cmdFirstDocument.Enabled = True
                cmdPrevDocument.Enabled = True
            Else
                cmdFirstDocument.Enabled = False
                cmdPrevDocument.Enabled = False
            End If
            If CurrentDocument < TotalDocuments Then
                cmdNextDocument.Enabled = True
                cmdLastDocument.Enabled = True
            Else
                cmdNextDocument.Enabled = False
                cmdLastDocument.Enabled = False
            End If
            lblDocument.Text = "Document: " & Format(CurrentDocument) & _
                " of " & Format(TotalDocuments)
            mnuAddOkToProcess.Enabled = False
            mnuAddCorrection.Enabled = False
            mnuAddGL.Enabled = False
            mnuAddCoding.Enabled = False
            mnuAddExcCodes.Enabled = False
            mnuAddReturn.Enabled = False
            mnuFindBill.Enabled = False
            mnuOkToProcess.Enabled = False
            mnuDuplicate.Enabled = False
            mnuChangeCurrency.Enabled = False
            mnuMoveToAudit.Enabled = False
            mnuMakeRushBatch.Enabled = False
            mnuMoveToDataEntry.Enabled = False
            mnuMoveToDiffAccount.Enabled = False
            mnuMoveToForBOLEntry.Enabled = False
            mnuMoveToDoNotPay.Enabled = False


            If CurrentDocument > 0 Then
                PictureBox1.Visible = True
                mnuHideAnnotations.Enabled = True
                mnuKeepAnnotations.Enabled = True
                mnuKeepAnnotations.Checked = ConfigKeepAnnotations
                mnuPrintBill.Enabled = True
                mnuAddStickyNote.Enabled = True
                mnuAddDocumentation.Enabled = True
                FIndSCACToolStripMenuItem.Enabled = True


                CurrentPage = 1
                cmdZoomIn.Enabled = True
                cmdZoomOut.Enabled = True
                cmdRotate.Enabled = True
                If Mid(Doc.FieldData.FieldAsString("Batch Number"), 1, 1) = "M" Or _
                    Mid(Doc.FieldData.FieldAsString("Batch Number"), 1, 1) = "H" Then
                    txtBatchNo.Text = Doc.FieldData.FieldAsString("Batch Number")
                Else
                    If RushBill Then
                        txtBatchNo.Text = "R" & Format(Doc.ID, "00000000")
                    Else
                        txtBatchNo.Text = "L" & Format(Doc.ID, "00000000")
                    End If
                End If
                txtSorter.Text = Doc.FieldData.FieldByIndex(1) & "/" & _
                    Doc.FieldData.FieldByIndex(2)
                Tempstring = Mid(Doc.FullPath, 2)
                Tempint = InStr(1, Tempstring, "\")
                Tempstring = Mid(Tempstring, 1, Tempint - 1)
                txtFolder.Text = Tempstring
                txtBatchNo.Visible = True
                lblSorter.Visible = True
                txtSorter.Visible = True
                txtFolder.Visible = True
                EnableMenuOptions()
            Else
                PictureBox1.Visible = False
                CurrentPage = 0
                txtBatchNo.Visible = False
                lblSorter.Visible = False
                txtSorter.Visible = False
                txtFolder.Visible = False
                lblInternal.Visible = False
                cmdZoomIn.Enabled = False
                cmdZoomOut.Enabled = False
                cmdRotate.Enabled = False
                mnuHideAnnotations.Enabled = False
                mnuKeepAnnotations.Enabled = False
                mnuKeepAnnotations.Checked = False
                mnuPrintBill.Enabled = False
                mnuAddStickyNote.Enabled = False
                mnuAddDocumentation.Enabled = False
            End If
            PagesDisplayed = 0
            If mnuKeepAnnotations.Checked = True Then
                OkToProcesses = 0
                Corrections = 0
                GlNumbers = 0
                Codings = False
                ExcCodes = 0
                Returns = 0
                DataEntryReturns = 0
                CPCReturns = 0
                Notes = 0
                mnuHideAnnotations.Checked = False
                InvisibleAnnotations()
            End If
        Catch ex As Exception
            MsgBox("Entire function." & vbCr & vbLf & _
            ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, _
                "frmLaserfiche.GetDocumentSCAC()")
            End
        End Try
        Return DocPages
    End Function

0 0

Replies

replied on November 18, 2015

LFObjectListing is the base class of LFSearchResultListing. Both LFEntryListing and LFSearchResultListing can be cast to LFObjectListing.

0 0
replied on November 18, 2015

You use the same "DatumByColType" and related accessors to get that information.  You should be able to cast results listings of any type to the ILFObjectListing interface.  COM doesn't make it easy to discover these other interfaces that an object supports, you might have an easier time using the modern RA library.

0 0
replied on March 3, 2016

Can elements of ILFObjectListing cast to ilfentry?

0 0
replied on March 3, 2016

No, everything you get from a listing will be a piece of data, like a string, date or number.  There are no column specifiers that correspond to anything else.

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

Sign in to reply to this post.