42 lines
1.4 KiB
VB.net
42 lines
1.4 KiB
VB.net
Imports System.Web
|
|
Imports System.Web.Services
|
|
Imports SISBusiness.Module
|
|
Imports DevExpress.ExpressApp.FileAttachments
|
|
Imports DevExpress.Persistent.BaseImpl
|
|
Imports DevExpress.Data.Filtering
|
|
Imports System.IO
|
|
Imports DevExpress.Web.Internal
|
|
|
|
Public Class GetAttachments
|
|
Implements System.Web.IHttpHandler
|
|
Private _Session As DevExpress.Xpo.Session
|
|
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
Dim _Oid As String
|
|
Dim _ConnectionString As String
|
|
Dim _Attachment As FileData
|
|
|
|
_Oid = context.Request.QueryString("id")
|
|
_ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString
|
|
|
|
_Session = New DevExpress.Xpo.Session
|
|
_Session.ConnectionString = _ConnectionString
|
|
_Session.Connect()
|
|
|
|
If _Session.IsConnected Then
|
|
_Attachment = _Session.FindObject(Of FileData)(CriteriaOperator.Parse("Oid=?", _Oid))
|
|
|
|
If _Attachment IsNot Nothing Then
|
|
Dim _Stream As New MemoryStream
|
|
_Attachment.SaveToStream(_Stream)
|
|
HttpUtils.WriteFileToResponse(Nothing, _Stream, _Attachment.FileName, True, "")
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
End Class |