|
The progress bar is slightly more complicated. We insert meta-tags
to ensure that it refreshes itself every couple of seconds. We create
a Progress object and set the ID to the Unique ID we were passed
in the URL. This synchronizes the Progress object with the matching
upload.
We want to close the progress window once the transfer has been
completed so we put in a simple piece of client side JavaScript
to do this. The rest of the form simply reports to the user the
information retrieved via the Progress object. The progress bar
itself is simply a table containing a colored cell of a particular
width.
<%@ Import Namespace="WebSupergoo.ABCUpload5"
%>
<%
Progress theProgress = new Progress(Request.QueryString["ProgressID"]);
string theID = theProgress.ID.ToString();
string theMins = ((int)theProgress.SecondsLeft / 60).ToString();
string theSecs = ((int)theProgress.SecondsLeft % 60).ToString();
string theMeta = "<meta http-equiv=\"refresh\"
content=\"2,progressbar.aspx?ProgressID=" + theID + "\">";
string thePercent = theProgress.PercentDone.ToString();
string theKbps = Math.Round(theProgress.BytesPerSecondCurrent /
1024, 1).ToString();
string theKbdone = Math.Round((double)theProgress.BytesDone / 1024,
1).ToString();
string theKbtotal = Math.Round((double)theProgress.BytesTotal /
1024, 1).ToString();
string theNote = theProgress.Note;
string theFileName = theProgress.FileName;
if (theProgress.Finished) theMeta = "";
%>
<HTML>
<HEAD>
<title>Progress...</title>
<meta http-equiv="expires" content="Tue, 01 Jan
1981 01:00:00 GMT">
<% = theMeta %>
<script language="javascript">
<!--
if (<% = thePercent %> >= 100) top.close();
//-->
</script>
</HEAD>
<body bgcolor="#cccccc">
<table border="0" width="100%">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><b>Uploading:</b></font></td>
</tr>
<tr bgcolor="#999999">
<td>
<table border="0" width="<% = thePercent %>%"
cellspacing="1" bgcolor="#0033ff">
<tr>
<td><font size="1"> </font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Estimated time left:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">
<% = theMins %> min
<% = theSecs %> secs
(<% = theKbdone %> KB of
<% = theKbtotal %> KB uploaded)
</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"> Transfer Rate:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theKbps %> KB/sec</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Information:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theNote %></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Uploading File:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theFileName %></font></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>
</body>
</HTML>
<%@ Import Namespace="WebSupergoo.ABCUpload5"
%>
<%
Dim theProgress As Progress = New Progress(Request.QueryString("ProgressID"))
Dim theID As String = theProgress.ID.ToString()
Dim theMins As String = CInt(theProgress.SecondsLeft / 60).ToString()
Dim theSecs As String = CInt(theProgress.SecondsLeft Mod 60).ToString()
Dim theMeta As String = "<meta http-equiv=""refresh""
content=""2,progressbar.aspx?ProgressID=" + theID
+ """>"
Dim thePercent As String = theProgress.PercentDone.ToString()
Dim theKbps As String = Math.Round(theProgress.BytesPerSecondCurrent
/ 1024,1).ToString()
Dim theKbdone As String = Math.Round(CType(theProgress.BytesDone
/ 1024, Double), 1).ToString()
Dim theKbtotal As String = Math.Round(CType(theProgress.BytesTotal
/ 1024, Double), 1).ToString()
Dim theNote As String = theProgress.Note
Dim theFileName As String = theProgress.FileName
If theProgress.Finished= True Then theMeta = ""
%>
<HTML>
<HEAD>
<title>Progress...</title>
<meta http-equiv="expires" content="Tue, 01 Jan
1981 01:00:00 GMT">
<% = theMeta %>
<script language="javascript">
<!--
if (<% = thePercent %> >= 100) top.close();
//-->
</script>
</HEAD>
<body bgcolor="#cccccc">
<table border="0" width="100%">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="2"><b>Uploading:</b></font></td>
</tr>
<tr bgcolor="#999999">
<td>
<table border="0" width="<% = thePercent %>%"
cellspacing="1" bgcolor="#0033ff">
<tr>
<td><font size="1"> </font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Estimated time left:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">
<% = theMins %> min
<% = theSecs %> secs
(<% = theKbdone %> KB of
<% = theKbtotal %> KB uploaded)
</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"> Transfer Rate:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theKbps %> KB/sec</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Information:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theNote %></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1">Uploading File:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><% = theFileName %></font></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>
</body>
</HTML>
|
|
|