Hu,
To test it I created a SQL table with three fields; DocID, DocName, and Image. DocID is an int, DocName is nvarchar(255), and Image is a SQL image type.
The code snippet below is for a workflow SDK script activity. It exports a document from LF as a tif image and stores it directly in a SQL table defined above.
(NOTE: You have to add a script reference to Laserfiche.DocumentServices to expose the export functions)
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess
Imports Laserfiche.DocumentServices
Imports System.IO
Namespace WorkflowActivity.Scripting.SDKScript
'''<summary>
'''Provides one or more methods that can be run when the workflow scripting activity is performed.
'''</summary>
Public Class Script1
Inherits RAScriptClass91
'''<summary>
'''This method is run when the activity is performed.
'''</summary>
Protected Overrides Sub Execute()
'Retrieve a reference to the bound entry...
Dim docInfo as DocumentInfo = DirectCast(Me.BoundEntryInfo, DocumentInfo)
'Initialize an instance of DocumentExporter...
Dim exporter As New DocumentExporter()
'Initialize the byte array, memory stream, and reader...
Dim image() As Byte
Dim stream As MemoryStream = New MemoryStream()
Dim reader As BinaryReader = New BinaryReader(stream)
'Set the exported image format to tif...
exporter.PageFormat = DocumentPageFormat.Tiff
'Export the image to the memory stream...
exporter.ExportPages(docInfo, docInfo.AllPages, stream)
'Read the image stream into the byte array...
image = reader.ReadBytes(stream.Length)
'Connect to the SQL database...
Dim connectionString As String = "Data Source=SAMANTHA-PC\SQLEXPRESS; Initial Catalog=LfTest; Integrated Security=True"
Using connection As SqlConnection = New SqlConnection(connectionString)
'Build the INSERT statement...
Dim command As SqlCommand = New SqlCommand("INSERT INTO ExportedImages (DocID, DocName, Image) Values(@DocID, @DocName, @Image)", connection)
'Set the parameters...
command.Parameters.Add("@DocID", SqlDbType.Int).Value = docInfo.Id
command.Parameters.Add("@DocName", SqlDbType.NVarChar, 255).Value = docInfo.Name
command.Parameters.Add("@Image", SqlDbType.Image, image.Length).Value = image
'Open the connection, execute the command, then close the connection...
connection.Open()
command.ExecuteNonQuery()
connection.Close
End Using
'Cleanup...
reader.Close()
stream.Close()
image = Nothing
stream.Dispose
reader.Dispose
docInfo.Dispose
exporter = Nothing
End Sub
End Class
End Namespace