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

Question

Question

Importing Briefcase Folder using SDK

asked on January 25, 2018 Show version history

Hi,

I have set up a VB.net script to export and import a briefcase file. The briefcase contains a folder, subfolders and documents.

When exporting I am using the following condition:

    'Create briefcase & add entries
        Dim myBriefcase as New BriefcaseExporter(RASession)
        myBriefcase.AddEntry(myEntry,BriefcaseSourceOptions.RecurseFolders)

    'Briefcase export
        Try
            myBriefcase.Export(exportPath)
        Catch e as Exception
            errorCheck = True
            errorMessage = "Briefcase export error. " & e.ToString
        End Try

When I manually import the briefcase it works fine but when I attempt to import via a script it does not import the subfolders and documents, only the root folder in the briefcase.

Is there a condition similar to the export I need to specify to solve this?

Thanks,

Dom

0 0

Replies

replied on January 25, 2018

Can you post the code you are using to import the briefcase? All I see here is the export portion.

Also, are you saying that when you export using the code and import manually it works? Or do you mean it only works if both the export and import are done manually?

0 0
replied on January 26, 2018

Hi Jason,

It works if I export using my code but import manually. Here is my import code:

    'Set variables
        Dim monitoredFolder as String  = "E:\OwnCloud\"
        Dim importFolderPath as String = "\Workflow\Forms\1. Import\"

        Dim searchString as String = "*.lfb"
        Dim errorCheck as Boolean = False
        Dim errorMessage as String = ""

    'Identify files to import
        Dim importFiles = System.IO.Directory.GetFiles(monitoredFolder,searchString,System.IO.SearchOption.AllDirectories)

    'Set import volume
        Dim importVolume as VolumeInfo = Volume.GetInfo("DEFAULT",RASession)

    'Search for import folder and create
        Dim importFolderSearch as new Laserfiche.RepositoryAccess.Search(RASession)
        Dim folderSearchSyntax as String = "{LF:Name=" & """" & "1. Import" & """" & ", Type=""F""} & {LF:LOOKIN=""\Workflow\Forms""}"
        MsgBox(folderSearchSyntax)

        importFolderSearch.Command = folderSearchSyntax
        importFolderSearch.Run()
        While importFolderSearch.Status <> SearchStatus.Done
            System.Threading.Thread.Sleep(5000)
        End While

        Dim importFolderSearchResults As SearchStatistics = importFolderSearch.GetSummaryStats
        If importFolderSearchResults.FolderCount = 0 Then
            Try
            Laserfiche.RepositoryAccess.Folder.Create(importFolderPath,importVolume.Name,EntryNameOption.AutoRename,RASession)
            Catch e as Exception
                MsgBox("Failed to create folder" & e.toString)
            End Try
        Else
        End If

        Dim importFolder as FolderInfo = Folder.GetFolderInfo(importFolderPath,RASession)
        MsgBox(importFolder.Path)

    'Loop through files and import
        Dim myBriefcase as New BriefcaseImporter(importFolder,importVolume,RASession)

        Try
            For Each file as String in importFiles
                If file.Contains("\ForServer\") Then
                    myBriefcase.Import(file)
                    System.IO.File.Delete(file)
                Else
                End If
            Next
        Catch e as Exception
            errorCheck = True
            errorMessage = e.ToString
        End Try

    'Set tokens
        SetTokenValue("Error Check", errorCheck)
        SetToken("Error Message", errorMessage)

 

0 0
replied on January 26, 2018 Show version history

I've tidied up my code and tested again and it appears to be working OK. I did sometimes get duplicated documents being created but it seems to be fine now. Below is the updated code.

        Dim dirFolderName as String = "E:\OwnCloud\"
        DIm dirSearchStr as String = "*.lfb"
        Dim dirFiles = Directory.GetFiles(dirFolderName,dirSearchStr,SearchOption.AllDirectories)

        Dim laserficheVolume as VolumeInfo = Volume.GetInfo("DEFAULT",RASession)
        Dim laserficheFolderName as String = "\Workflow\Forms\1. Import\"
        Dim laserficheFolder as FolderInfo
        
        Dim errorCheck as Boolean = False
        Dim errorMessage as String  = ""
        
        Try
            laserficheFolder = Folder.GetFolderInfo(laserficheFolderName,RASession)
        Catch
            Folder.Create(laserficheFolderName,laserficheVolume.Name,EntryNameOption.None,RASession)
            laserficheFolder = Folder.GetFolderInfo(laserficheFolderName,RASession)
        End Try
        
        Dim briefcaseImport as New BriefcaseImporter(laserficheFolder,laserficheVolume,RASession)

        Try
            For Each dirFile as String in dirFiles
                If dirFile.Contains("\ForServer\") Then
                    MsgBox("Importing... " & dirFile)
                    briefcaseImport.Import(dirFile)
                    File.Delete(dirFile)
                Else
                    MsgBox("Ignoring... " & dirFile)
                End If
            Next
        Catch e as Exception
            errorCheck = True
            errorMessage = e.ToString
        End Try

        SetTokenValue("Error Check", errorCheck)
        SetTokenValue("Error Message", errorMessage)

 

0 0
replied on January 26, 2018

I don't see any obvious issues with the import code. I tested it and everything worked as expected. Is it possible there is a permissions issue with the account running the script? Have you tried running the script from the editor, if so, does it work there?

0 0
replied on January 26, 2018

Okay, so it might just be an issue with the way the variables were being assigned. The import settings don't have anything to tell it to ignore subfolders so it should be bringing in everything in the briefcase.

1 0
replied on January 26, 2018

Yeah it appears to be OK now! surprise I'll keep testing and see if I find anything.

0 0
replied on January 26, 2018

Something I find helpful during testing is to create tokens for all of the variables and track them in the workflow; that way you can see exactly what you are getting when the script runs and track down any odd/unexpected behavior.

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

Sign in to reply to this post.