Provides all status information about upload process such as uploaded bytes, transfer rate etc.

Namespace:  EasyAlgo.EAUpload
Assembly:  EasyAlgo.EAUpload (in EasyAlgo.EAUpload.dll)
Version: 1.3.1.0

Syntax

C#
public class UploadStatus
Visual Basic (Declaration)
Public Class UploadStatus

Remarks

You cannot create an instance of this class with the new keyword. EAUpload automatically creates the instance of this class and associates its with EasyAlgo.EAUpload..::.Upload object. You can obtain its by referencing the Upload..::.Status property.

Examples

The following code example demonstrates how to get a status information and display its on the web page.
(The following code is a part of example that is included in distribution package.)
CopyC#
// UploadStatusInfo.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using EasyAlgo.EAUpload;

namespace EAUploadExamples
{
    public class UploadStatusInfo : System.Web.UI.Page
    {
        public UploadStatus _status = null;

        private void Page_Load(object sender, System.EventArgs e)
        {
            // We need to declare that the page should not be cached.
            Response.CacheControl = "No-cache";
            Response.Expires = -1;

            // Retrieve an unique identifier of Upload object from the query string
            string UploadId = Request.QueryString["UploadId"];

            // Get Upload class instance for the specific upload process
            Upload _upload = UploadsManager.GetUpload(UploadId);

            _status = _upload.Status;            

        }

        // Returns a meta-data for page refresh.
        public string GetRefreshMeta()
        {
            return "<meta http-equiv=\"Refresh\" content=\"2;URL=UploadStatusInfo.aspx?UploadId=" + Request.QueryString["UploadID"] + "\">";            
        }


        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            // 
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            // 
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {    
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion
    }
}

// --------------------------------------------

// UploadStatusInfo.aspx

<%@ Page language="c#" Codebehind="UploadStatusInfo.aspx.cs" AutoEventWireup="false" Inherits="EAUploadExamples.UploadStatusInfo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>Uploading - <% = _status.PercentsDone.ToString() + "%" %></title>
        <% = GetRefreshMeta() %>
        <link rel="stylesheet" href="ExamplesStyle.css">
        <script language="javascript" src="JSCore.js"></script>
        <script type="text/javascript" >
            function CheckOnSuccessfullyUpload(UploadState)
            {
                if (UploadState == "Complete")
                {
                    window.close();
                }

                if (IsStopCommandSupported() == false)
                {
                    // Just hide "Cancel" button if browser doesn't support javascript "stop" command.
                    document.getElementById("cancelButton").style.display = "none";
                }
            }        
        </script>
    </HEAD>    
    <body onload="CheckForSuccessfullyUpload('<% = _status.State.ToString() %>');">
        <table>
            <tr>
                <td>
                    <div id="container" style="width: 500px; border: 1px solid #0000ff; line-height: 20px; background-color: #d4d0c8;">
                        <div id="progress" style="BACKGROUND: #009900; HEIGHT: 10px; width: <% = _status.PercentsDone.ToString() + "%" %>"></div>
                    </div>
                </td>
                <td style="padding-left: 5px;">
                    <div style="width: 15px; line-height: 20px;"><% = _status.PercentsDone.ToString() %>%</div>
                </td>
            </tr>
        </table>
        <span style="font-weight: bold;">Uploaded <% = (Math.Round((double)_status.UploadedBytes / 1024)).ToString() %> KB of <% = (Math.Round((double)_status.TotalBytes / 1024)).ToString() %> KB</span>
        <br><br>
        <a id="cancelButton" onclick="window.opener.cancelUpload()"><img src="images/cancel_button.gif" border="0" /></a>
        <br><br>
        Full status info:
        <br/>
        Time elapsed: <% = _status.ElapsedTime.ToString() %> sec
        <br/>
        Remaining time: <% = _status.RemainingTime.ToString() %> sec
        <br/>
        Percents done: <% = _status.PercentsDone.ToString() %> %
        <br/>
        Uploaded bytes: <% = _status.UploadedBytes.ToString() %> bytes
        <br/>
        Total bytes: <% = _status.TotalBytes.ToString() %> bytes
        <br/>
        Uploaded files count: <% = _status.UploadedFilesCount.ToString() %>
        <br/>
        Upload speed (bytes per second): <% = _status.BytesPerSecond.ToString() %> bytes/sec
        <br/>
        Upload speed avarage (bytes per second): <% = _status.BytesPerSecondAvg.ToString() %> bytes/sec
        <br/>
        Curent uploading file: <% = _status.CurrentFileName %>
        <br/>
        Uploaded bytes of uploading file: <% = _status.CurrentFileUploadedBytes.ToString() %> bytes
        <br/>
    </body>
</HTML>
CopyVB.NET
' UploadStatusInfo.aspx.vb


Imports System
Imports System.Web
Imports System.Web.UI

Imports EasyAlgo.EAUpload

Public Class UploadStatusInfo
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Public _status As UploadStatus = Nothing

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' We need to declare that the page should not be cached.
        Response.CacheControl = "No-cache"
        Response.Expires = -1

        ' Retrieve an unique identifier of Upload object from the query string
        Dim UploadId As String = Request.QueryString.Item("UploadId")

        ' Get Upload class instance for the specific upload process
        Dim _upload As Upload = UploadsManager.GetUpload(UploadId)
        _status = _upload.Status

    End Sub
    ' Returns a meta-data for page refresh.
    Public Function GetRefreshMeta() As String

        Return ("<meta http-equiv=""Refresh"" content=""2;URL=UploadStatusInfo.aspx?UploadId=" & Request.QueryString.Item("UploadId") & """>")

    End Function

End Class

' --------------------------------------------


' UploadStatusInfo.aspx


<%@ Page language="vb" Codebehind="UploadStatusInfo.aspx.vb" AutoEventWireup="false" Inherits="EAUploadExamples.UploadStatusInfo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>Uploading - <% = _status.PercentsDone & "%" %></title>
        <% = GetRefreshMeta %>
        <link rel="stylesheet" href="ExamplesStyle.css">
        <script language="javascript" src="JSCore.js"></script>
        <script type="text/javascript" >
            function CheckOnSuccessfullyUpload(UploadState)
            {
                if (UploadState == "Complete")
                {
                    window.close();
                }

                if (IsStopCommandSupported() == false)
                {
                    // Just hide "Cancel" button if browser doesn't support javascript "stop" command.
                    document.getElementById("cancelButton").style.display = "none";
                }
            }        
        </script>
    </HEAD>    
    <body onload="CheckForSuccessfullyUpload('<% = _status.State %>');">
        <table>
            <tr>
                <td>
                    <div id="container" style="width: 500px; border: 1px solid #0000ff; line-height: 20px; background-color: #d4d0c8;">
                        <div id="progress" style="BACKGROUND: #009900; HEIGHT: 10px; width: <% = _status.PercentsDone & "%" %>"></div>
                    </div>
                </td>
                <td style="padding-left: 5px;">
                    <div style="width: 15px; line-height: 20px;"><% = _status.PercentsDone %>%</div>
                </td>
            </tr>
        </table>
        <span style="font-weight: bold;">Uploaded <% = Int(_status.UploadedBytes / 1024) %> KB of <% = Int(_status.TotalBytes / 1024) %> KB</span>
        <br><br>
        <a id="cancelButton" onclick="window.opener.cancelUpload()"><img src="images/cancel_button.gif" border="0" /></a>
        <br><br>
        Full status info:
        <br/>
        Time elapsed: <% = _status.ElapsedTime %> sec
        <br/>
        Remaining time: <% = _status.RemainingTime %> sec
        <br/>
        Percents done: <% = _status.PercentsDone %> %
        <br/>
        Uploaded bytes: <% = _status.UploadedBytes %> bytes
        <br/>
        Total bytes: <% = _status.TotalBytes %> bytes
        <br/>
        Uploaded files count: <% = _status.UploadedFilesCount %>
        <br/>
        Upload speed (bytes per second): <% = _status.BytesPerSecond %> bytes/sec
        <br/>
        Upload speed avarage (bytes per second): <% = _status.BytesPerSecondAvg %> bytes/sec
        <br/>
        Curent uploading file: <% = _status.CurrentFileName %>
        <br/>
        Uploaded bytes of uploading file: <% = _status.CurrentFileUploadedBytes %> bytes
        <br/>
    </body>
</HTML>

Inheritance Hierarchy

System..::.Object
  EasyAlgo.EAUpload..::.UploadStatus

See Also