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

Question

Question

import document ASP.net Code

SDK
asked on February 16, 2014

Dear,

 

I have written code as below to upload a document in to Laserfiche using c# asp.net asp.net. I have clarification how to upload FileUpload1.Content file. I have used below code, but it will not help. Because it use only List XML paths. Please advise any sdk method is availabile to obtain this solution.

 

 

importEngine.RootPath = "\\";

importEngine.VolumeName = "GTSLFDEV2VOL";

importEngine.IgnoreErrorAndContinue = true;

//string filename = FileUpload1.PostedFile.FileName;//Path.GetFileName(FileUpload1.FileName);

//FileUpload1.SaveAs(Server.MapPath("~/bin/") + filename);

DocumentImporter DocImporter = new DocumentImporter();

ImportOperation importOp = importEngine.BeginProcess(FileUpload1.FileContent);

//wait util the operation is complete, whether or not it is successful

0 0

Answer

SELECTED ANSWER
replied on February 17, 2014

I'm not sure what you're really asking. You seem to already know that ImportEngine is the wrong tool to use because it only processes XML list files. And you are defining DocumentImporter (which would be the right one), but then you are not using it.

0 0

Replies

replied on February 19, 2014

DocumentImporter should be used, here's an example:

 

Dim App As New LFApplication
        Dim db As LFDatabase = App.ConnectToDatabase(rep, svr, uid, pwd)
        Try

            'Send document to LF
            Dim entryPath As String = "Repository\Folder\Folder"
            Dim NewDoc As New LFDocument
            Dim Vol As LFVolume = db.GetVolumeByName("VolumeName")
            Dim Temp As LFTemplate = db.GetTemplateByName("TemplateName")

            Dim Parent As LFFolder = db.GetEntryByPath(entryPath)
            NewDoc.Create(FileName, Parent, Vol, True)
            NewDoc.UnlockObject()

            Dim DocImporter As New DocumentImporter
            Dim doc As LFDocument = db.GetEntryByPath(entryPath & "\" & NewDoc.Name.ToString)

            NewDoc.Dispose()

            DocImporter.Document = doc
            DocImporter.PageAction = Import_Page_Action.IMPORT_PAGE_ACTION_OVERWRITE

           

            'import images OR electronic file

            DocImporter.ImportImagesFromFile("filepath\filename.tiff")
            'DocImporter.ImportElectronicFile("filepath\filename.pdf")

            'Assign Template
            Dim Fields As LFFieldData = doc.FieldData
            Fields.LockObject(Lock_Type.LOCK_TYPE_WRITE)
            Fields.Template = Temp

            Fields.FieldByIndex(1) = "value"
            Fields.FieldByIndex(2) = "value"
            Fields.FieldByIndex(3) = "value"
            Fields.FieldByIndex(4) = "value"
            Fields.Update()


            Fields.UnlockObject()

           

            doc.Dispose()
        Catch ex As Exception
            'Error

        Finally
            Dim Conn As LFConnection = db.CurrentConnection
            Conn.Terminate()
        End Try

 

3 0
replied on February 19, 2014

Dear Bradley,

 

Thanks for your answer.

 

I have small clarification. The customer requesting to upload or import AutoCAD drawings or ms word document , in this case did above code will support?.

 

Please advise.

 

Regards,

Ranjith

0 0
replied on February 20, 2014

Yes, but you'll need to import those files as an electronic document:

 

DocImporter.ImportElectronicFile("filepath\filename.fileextension")

rather than

DocImporter.ImportImagesFromFile("filepath\filename.tiff")

 

1 0
replied on May 18, 2016

Dear Bradley,

Thanks for your answer.

just that I have the following question regarding the Code

Dim entryPath As String = "Repository\Folder\Folder"

Dim Parent As LFFolder = db.GetEntryByPath(entryPath)

when passing the directory path to Laserfiche marks the following error message: Can not implicitly convert the object type, there is already explicit conversion (check if you need a conversion LFSO8LIB.LFFOLDER

Please appreciate your support of

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

Sign in to reply to this post.