⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processprogress.cs

📁 PowUpload的C#源文件,用来做大文件上传的项目
💻 CS
字号:
namespace ElementIT.PowUpload
{
    using System;
    using System.Collections.Specialized;
    using System.Web;

    internal class ProcessProgress
    {
        internal BandwidthControl _bwc;
        private int _cnt;
        internal string _CurrentFileName;
        internal long _CurrentFileUploadedBytes;
        internal object _CustomData;
        internal DateTime _EndTime;
        internal UploadedFileCollection _Files;
        internal NameValueCollection _FormFields;
        internal HttpContext _HttpContext;
        private string _id;
        internal Exception _lastError;
        internal DateTime _LastTime;
        internal ProcessUpload _ProcessUpload;
        internal long _ReadSinseLastTime;
        private long[] _ReadSinseLastTimeArr;
        internal double _SecondsDone;
        internal DateTime _StartTime;
        internal UploadState _Status;
        internal TimeSpan _TimeSinseLastTime;
        internal long _TotalBytes;
        internal bool _UploadComplete;
        internal long _UploadedBytes;
        internal int _UploadedFilesCount;
        internal int _UploadModuleID;
        internal HttpWorkerRequest _WorkerRequest;

        internal ProcessProgress(int id)
        {
            this._id = null;
            this._ReadSinseLastTimeArr = null;
            this._Files = null;
            this._FormFields = null;
            this._bwc = null;
            this._WorkerRequest = null;
            this._HttpContext = null;
            this._lastError = null;
            this._ProcessUpload = null;
            this._CustomData = null;
            this._id = id.ToString();
            this.Reset();
        }

        internal ProcessProgress(string id)
        {
            this._id = null;
            this._ReadSinseLastTimeArr = null;
            this._Files = null;
            this._FormFields = null;
            this._bwc = null;
            this._WorkerRequest = null;
            this._HttpContext = null;
            this._lastError = null;
            this._ProcessUpload = null;
            this._CustomData = null;
            this._id = id;
            this.Reset();
        }

        internal void Dispose()
        {
            UploadModule.AddDebugInfo("ProcessProgress.Dispose(). Stack trace for current level: " + Environment.StackTrace, this._id);
            try
            {
                this._Files.Dispose();
            }
            catch
            {
            }
            try
            {
                if (((this._id != null) && (UploadModule.colProcessProgress != null)) && (UploadModule.colProcessProgress[this._id] != null))
                {
                    if (this == UploadModule.colProcessProgress[this._id])
                    {
                        UploadModule.AddDebugInfo("ProcessProgress.Dispose(): Instance equal to colProcessProgress[id]", this._id);
                        UploadModule.colProcessProgress[this._id] = null;
                        UploadModule.colProcessProgress.Remove(this._id);
                    }
                }
                else
                {
                    UploadModule.AddDebugInfo("ProcessProgress.Dispose(): colProcessProgress[id] is null", this._id);
                }
            }
            catch
            {
            }
        }

        ~ProcessProgress()
        {
            this.Dispose();
        }

        internal void Reset()
        {
            UploadModule.AddDebugInfo("ProcessProgress.Constructor()", this._id);
            this._CurrentFileName = "";
            this._CurrentFileUploadedBytes = 0;
            this._TotalBytes = 0;
            this._UploadedBytes = 0;
            this._SecondsDone = 0;
            this._ReadSinseLastTime = 0;
            this._StartTime = DateTime.Now;
            this._EndTime = DateTime.MinValue;
            this._LastTime = DateTime.Now;
            this._TimeSinseLastTime = DateTime.Now.Subtract(this._LastTime);
            this._UploadedFilesCount = 0;
            this._UploadComplete = false;
            this._Status = UploadState.Waiting;
            this._cnt = 0;
            this._UploadModuleID = -1;
            this._ReadSinseLastTimeArr = new long[20];
            this._Files = new UploadedFileCollection();
            this._FormFields = new NameValueCollection();
            this._bwc = null;
            this._WorkerRequest = null;
            this._HttpContext = null;
            this._lastError = null;
            this._ProcessUpload = null;
            this._CustomData = null;
        }

        internal void SetReadSinseLastTime(long countbytes)
        {
            this._ReadSinseLastTimeArr[this._cnt] = countbytes;
            int num = 0;
            this._cnt++;
            if (this._cnt > 0x13)
            {
                this._cnt = 0;
            }
            long num2 = 0;
            foreach (int num3 in this._ReadSinseLastTimeArr)
            {
                if (num3 != 0)
                {
                    num2 += num3;
                    num++;
                }
            }
            if (num != 0)
            {
                this._ReadSinseLastTime = num2 / ((long) num);
            }
            else
            {
                this._ReadSinseLastTime = 0;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -