Ask a Question related to ASP.NET General, Design and Development.
-
Joel Cade #1
Progress Bars and Remoting
I'd just like a sanity check on my thinking. I'm attempting to create
a progress bar for a file upload to an ASPX page. I'm adding an HTTP
Module, which would then call into a "Progress Handler", a remoting
object created as a singleton object, which would keep track of all
file uploads by an id. Does this make sense?
I haven't seen this implementation of a progress bar mentioned
anywhere. Am I missing something? Thanks for the input!!
Joel Cade, MCSD
Brinster, Inc.
Here's the paired down code:
-- The HTTP Module ---
Imports System.Web
Public Class progressModule
Implements IHttpModule
Dim oHandler As ProgressHandler.ProgressHandler
Dim context As HttpContext
Dim currentId As String
Public Sub Init(ByVal application As Web.HttpApplication)
Implements IHttpModule.Init
AddHandler application.BeginRequest, AddressOf
Me.Application_BeginRequest
AddHandler application.EndRequest, AddressOf
Me.Application_EndRequest
End Sub
Public Sub Dispose() Implements IHttpModule.Dispose
End Sub
Private Sub Application_BeginRequest(ByVal source As Object, ByVal
e As EventArgs)
Dim application As HttpApplication = CType(source,
HttpApplication)
context = application.Context
oHandler = Activator.GetObject(GetType(ProgressHandler.Progre ssHandler),
"")
currentId = Guid.NewGuid.ToString
Dim timer As New Timers.Timer(500)
AddHandler timer.Elapsed, AddressOf OnTimerTick
End Sub
Private Sub Application_EndRequest(ByVal source As Object, ByVal e
As EventArgs)
Dim application As HttpApplication = CType(source,
HttpApplication)
Dim context As HttpContext = application.Context
End Sub
Private Sub OnTimerTick(ByVal source As Object, ByVal e As
Timers.ElapsedEventArgs)
oHandler.UpdateValues(currentId,
context.Request.ContentLength, context.Request.TotalBytes)
End Sub
End Class
--- The Handler (Remoted) ---
Imports System.Runtime.Remoting
Public Class ProgressHandler
Inherits MarshalByRefObject
Dim dtProgressValues As DataTable
Public Sub New()
dtProgressValues = New DataTable()
dtProgressValues.Columns.Add("Id", GetType(String),
vbNullString)
dtProgressValues.Columns.Add("BytesTotal", GetType(Integer),
0)
dtProgressValues.Columns.Add("BytesFinished",
GetType(Integer), 0)
dtProgressValues.PrimaryKey(0) = dtProgressValues.Columns(0)
End Sub
Public Sub UpdateValues(ByVal Id As String, ByVal BytesTotal As
Integer, ByVal BytesFinished As Integer)
Dim dRow As DataRow
dRow = dtProgressValues.Rows.Find(Id)
If dRow Is Nothing Then
dRow = dtProgressValues.NewRow
dRow(0) = Id
dRow(1) = BytesTotal
dRow(2) = BytesFinished
dtProgressValues.Rows.Add(dRow)
Else
dRow(1) = BytesTotal
dRow(2) = BytesFinished
End If
End Sub
Public Function GetBytesTotal(ByVal Id As String) As Integer
Dim dRow As DataRow
dRow = dtProgressValues.Rows.Find(Id)
If dRow Is Nothing Then
Return 0
Else
Return dRow("BytesTotal")
End If
End Function
Public Function GetBytesFinished(ByVal Id As String) As Integer
Dim dRow As DataRow
dRow = dtProgressValues.Rows.Find(Id)
If dRow Is Nothing Then
Return 0
Else
Return dRow("BytesFinished")
End If
End Function
End Class
Joel Cade Guest
-
progress bar and remoting
i have an application that uses remoting to access a .cfc to pull some data from a sql table and generate a .pdf before returning. the process... -
Menu Bars
Hi im very new to Flash MX PRO 2004, and im making a flash website... so far i have little done... i have some animated text and a music player....... -
Command bars
IS there a way you can create a command bar (or menu) in which you can set the code for items that can be selected? Example: mnuFile - Clear... -
Nav bars
On 7/6/2003 7:47 AM, "Beatkeeper72" webforumsuser@macromedia.com wrote: Did you use Save or Save As to save a copy of your working file, or just... -
Importing Nav Bars
Econ: Yes there is. Now, file this information away and never ask it again! 8) There are much better ways to make nav bars than to use the FW...



Reply With Quote

