Ejemplo n.º 1
0
        protected void btnPostFile_Click(object sender, EventArgs e)
        {
            int          files        = 0;
            UploadStatus uploadstatus = HttpUploadModule.GetUploadStatus();
            bool         flag         = uploadstatus.Reason == UploadTerminationReason.NotTerminated;

            if (flag)
            {
                foreach (UploadedFile file in uploadstatus.GetUploadedFiles())
                {
                    string clientFileName = file.ClientName;
                    bool   flag2          = file.ContentLength.Equals(0L);
                    if (flag2)
                    {
                        base.PromptDialog(string.Format("[{0}]文件大小为0字节,系统不支持文件大小为0字节的文件上传,请重新选择文件上传。", clientFileName));
                        return;
                    }
                    bool flag3 = !this.filelist.MaxFileSize.Equals(0.0) && file.ContentLength > this.filelist.MaxFileSize;
                    if (flag3)
                    {
                        base.PromptDialog(string.Format("[{0}]文件大小已超出规定的 {1}上限,上传失败。", clientFileName, this.filelist.MaxFileSize.FormatFileSize()));
                        return;
                    }
                    DocFileInfo fileInfo = FileService.AddFile(file.ServerPath, clientFileName, file.ContentLength, this.hidFileGroup.Value.ToDouble());
                    this.hidFileGroup.Value   = fileInfo.FileGroupId.ToString();
                    this.filelist.FileGroupId = fileInfo.FileGroupId;
                    this.UpdateBusinessFileGroup();
                    files = this.UpdateBusinessFiles();
                }
            }
            this.UpdateTempletFileFieldRI(files);
            base.CurMaster_OnQuery(null, null);
        }
Ejemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string uploadId             = Request.QueryString["UploadID"];
            string scriptText           = "";
            string scriptUploading      = "pb.setSize({0}, {1});";
            string scriptClearTimer     = "ClearTimer();";
            string scriptUploadComplete = "pb.UploadComplete();" + scriptClearTimer;
            string scriptUploadError    = "pb.UploadError();";

            string length = "";
            string read   = "";

            Openlab.Web.Upload.Progress progress = HttpUploadModule.GetProgress(uploadId, Application);
            if (progress != null)
            {
                // 如果正在接收数据,利用脚本来通知前端进度条
                //
                if (progress.State == UploadState.ReceivingData)
                {
                    length     = (progress.ContentLength / 1024).ToString();
                    read       = (progress.BytesRead / 1024).ToString();
                    scriptText = string.Format(scriptUploading, length, read);
                }
                else if (progress.State == UploadState.Complete)
                {
                    scriptText = scriptUploadComplete;
                }
                else
                {
                    scriptText = scriptUploadError;
                }
            }
            else
            {
                //scriptText = scriptUploadError;
            }
            Response.Clear();
            Response.Write(scriptText);
            Response.End();
        }
Ejemplo n.º 3
0
        private void Page_Load(object sender, EventArgs e)
        {
            UploadStatus status = HttpUploadModule.GetUploadStatus();

            Response.Clear();
            Response.ContentType = "application/javascript";
            Response.Write("//uploadstatus\n");
            if (status != null)
            {
                decimal percent = Math.Round((decimal)((100.0 / status.ContentLength) * status.Position), 0);
                switch (status.State)
                {
                case UploadState.ReceivingData:
                    Response.Write("document.getElementById(\"progressBar\").style.width=\"" + percent.ToString() + "%\"\n");
                    Response.Write("document.getElementById(\"datatext\").innerHTML='" + status.Position.ToString() + " / " + status.ContentLength.ToString() + " - " + percent.ToString() + "%'\n");
                    break;

                case UploadState.Complete:
                    if (percent < 100)
                    {
                        Response.Write("document.getElementById(\"datatext\").innerHTML='Upload Interrupted!!'\n");
                    }
                    else
                    {
                        Response.Write("document.getElementById(\"progressBar\").style.width=\"100%\"\n");
                        Response.Write("document.getElementById(\"datatext\").innerHTML='Upload Complete!!'\n");
                    }
                    Response.Write("setTimeout('self.close();', 2000);\n");
                    break;

                case UploadState.Error:
                    Response.Write("document.getElementById(\"datatext\").innerHTML='Upload Error!!'\n");
                    Response.Write("setTimeout('self.close();', 2000);\n");
                    break;
                }
            }
            Response.End();
        }