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

Question

Question

Using XML Files to Import Documents

asked on February 7, 2022

Hi!  I'm working on writing a program that uses an XML file with the ImportEngine to import documents into Laserfiche.  We have an older program that does a similar thing with an LST file. 

How do I designate/create the volume with in an XML file.  I found where I can designate/create the folder.  I've looked at the sample files provided and the ImportEngine.xsd, but I'm not seeing anything regarding volumes.

 

Sample from a LST file:

LASERFICHE IMPORT LIST
FOLDERS(820552)
VOLUME(HSPLBT202202)
DOCUMENT(820552-1 1300390)
STARTFIELDS

...

0 0

Answer

SELECTED ANSWER
replied on February 7, 2022

If you want to make a new volume to import into, you can either use the administration console to create it, or do it within the SDK (Laserfiche.RepositoryAccess) using Volume.Create:

VolumeInfo newVol = new VolumeInfo(session);
newVol.Name = "ImportVolume";
newVol.FixedPath = "\\path\to\volume";
newVol = Volume.Create(newVol,session);

When importing the xml, you can set the volume name on the import with the ImportEngine.VolumeName property:

ImportEngine importEngine = new ImportEngine(session);
importEngine.RootPath = EntryPath.Make(@"\", folderName);
importEngine.VolumeName = "ImportVolume"

// ...

 

0 0
replied on February 8, 2022

Thanks!  I was afraid doing the SDK was the only way to do it.  The XML file would have worked for me better because I could have split the create of import XML from the actual import.

 

Is there a way to check if a volume already exists when you try to create it, or does the Volume.Create handle it?

 

0 0
replied on February 8, 2022

Use Volume.GetInfo to check if the volume exists:


VolumeInfo GetOrCreateVolume(string volumeName, Session session)
{
    try
    {
        VolumeInfo vol = Volume.GetInfo(volumeName, session);
        return vol;
    }
    catch
    {
        // Doesn't exist, have to create it
        VolumeInfo newVol = new VolumeInfo(session);
        newVol.Name = volumeName;
        newVol.FixedPath = "\\path\to\volume";
        newVol = Volume.Create(newVol, session);
        return newVol;
    }
}

 

0 0

Replies

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

Sign in to reply to this post.