Esempio n. 1
0
        /// <summary>
        /// Handles the ServerClick event of the btnUpload control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnUpload_ServerClick(object sender, EventArgs e)
        {
            FileStreamInfo[] fsi = FileUpCtrl1.Files;
            if (fsi != null && fsi.Length > 0)
            {
                FileUploaderContext.Current.SessionUid = new Guid(Request.Form["__MEDIACHASE_FORM_UNIQUEID2"]);
                Page.ClientScript.RegisterStartupScript(this.GetType(), FileUploaderContext.Current.SessionUid.ToString(), String.Format("ChangeProgressId('{0}');", FileUploaderContext.Current.SessionUid), true);

                if (UploadProgress.Enabled)
                {
                    UploadProgressInfo newUploadProgressInfo = new UploadProgressInfo(FileUploaderContext.Current.SessionUid, (Int32)fsi[0].Size);
                    UploadProgress.Provider.Update(newUploadProgressInfo);
                }
                FolderElement element = FolderElement.Create(this.ParentId, fsi[0].FileName, FileUpCtrl1.Provider.GetStream(fsi[0].StreamUid), FileUploaderContext.Current.SessionUid);

                Response.Redirect(this.Request.RawUrl + String.Format("&objectid={0}", element.PrimaryKeyId.Value));
            }
            //McHttpPostedFile file = mcHtmlInputFile.PostedFile;
            //if(file != null)
            //{
            //    FolderElement element = FolderElement.Create(this.ParentId, file.FileName, file.InputStream);

            //    Response.Redirect(this.Request.RawUrl + String.Format("&objectid={0}", element.PrimaryKeyId.Value));
            //}
        }
Esempio n. 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css");
            UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/Theme.css");

            UtilHelper.RegisterScript(Page, "~/Scripts/browser.js");

            cbClose.Text = LocRM.GetString("tClose");
            if (ID != null)
            {
                dClose.Visible = false;
                Guid progressUid       = new Guid(ID);
                UploadProgressInfo upi = UploadProgress.Provider.GetInfo(progressUid);

                int  Received      = 0;
                int  Total         = 0;
                bool PostCompleted = false;

                if (upi != null)
                {
                    Received      = upi.BytesReceived;
                    Total         = upi.BytesTotal;
                    PostCompleted = upi.Result == UploadResult.Succeeded;
                }
                lblTransferred.Text = (Received / 1024).ToString();
                if (Total > 0)
                {
                    percents            = (int)((float)Received / (float)Total * 100);
                    lblTransferred.Text = LocRM.GetString("tUploaded") + " " + (Received / 1024).ToString() + " Kb " + LocRM.GetString("tof") + " " + (Total / 1024).ToString() + " Kb";
                }
                else
                {
                    lblTransferred.Text = LocRM.GetString("tWait");
                    percents            = 0;
                }

                if (PostCompleted)
                {
                    if (Total != Received)
                    {
                        lblTransferred.Text = LocRM.GetString("tUplFail");
                        dClose.Visible      = true;
                    }
                    else
                    {
                        lblTransferred.Text = LocRM.GetString("tUplComplSucces");
                        dClose.Visible      = true;
                        if (cbClose.Checked)
                        {
                            dWinClose.Visible = true;
                        }
                    }
                }
                else
                {
                    body.Attributes.Add("onload", "setTimeout('refresh()', 2000)");
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            cbClose.Text = "Close this box when upload completes";
            if (ID != null)
            {
                dClose.Visible = false;

                Guid progressUid       = new Guid(ID);
                UploadProgressInfo upi = UploadProgress.Provider.GetInfo(progressUid);

                int  Received      = 0;
                int  Total         = 0;
                bool PostCompleted = false;

                if (upi != null)
                {
                    Received      = upi.BytesReceived;
                    Total         = upi.BytesTotal;
                    PostCompleted = upi.Result == UploadResult.Succeeded;
                }
                lblTransferred.Text = (Received / 1024).ToString();
                if (Total > 0)
                {
                    percents            = (int)((float)Received / (float)Total * 100);
                    lblTransferred.Text = "Uploaded " + (Received / 1024).ToString() + " Kb of " + (Total / 1024).ToString() + " Kb";
                }
                else
                {
                    lblTransferred.Text = "Wait for Uploading Starts";
                    percents            = 0;
                }

                if (PostCompleted)
                {
                    if (Total != Received)
                    {
                        lblTransferred.Text = "Uploading Failed";
                        dClose.Visible      = true;
                    }
                    else
                    {
                        lblTransferred.Text = "Uploading Completed Sucessfully";
                        dClose.Visible      = true;
                        if (cbClose.Checked)
                        {
                            dWinClose.Visible = true;
                        }
                    }
                }
                else
                {
                    body.Attributes.Add("onload", "setTimeout('refresh()', 2000)");
                }
            }
        }
Esempio n. 4
0
        public ArrayList GetProgressInfo(string FormId)
        {
            ArrayList          values      = new ArrayList();
            Guid               progressUid = new Guid(FormId);
            UploadProgressInfo upi         = UploadProgress.Provider.GetInfo(progressUid);

            if (upi == null)
            {
                values.Add("-1");
                values.Add(LocRM.GetString("tWaitForUploading"));
            }
            else
            {
                if (upi.Result == UploadResult.Succeeded)
                {
                    if (upi.BytesTotal != upi.BytesReceived)
                    {
                        values.Add("-2");
                        values.Add(LocRM.GetString("tUploadFailed"));
                    }
                    else
                    {
                        values.Add("-3");
                        values.Add(LocRM.GetString("tUploadSuccess"));
                    }
                }
                else
                {
                    // 0
                    values.Add(FormatBytes(upi.BytesReceived));
                    // 1
                    values.Add(FormatBytes(upi.BytesTotal));
                    // 2
                    values.Add(upi.EstimatedTime.ToString().Substring(0, 8));
                    // 3
                    values.Add((upi.TimeRemaining.ToString().Substring(0, 8)).StartsWith("-") ? "00:00:00" : upi.TimeRemaining.ToString().Substring(0, 8));

                    // 4
                    int percents = (int)((float)upi.BytesReceived / (float)upi.BytesTotal * 100);
                    values.Add(percents.ToString());

                    // 5
                    string sFName = upi.CurrentFileName;
                    if (sFName.LastIndexOf("\\") >= 0)
                    {
                        sFName = sFName.Substring(sFName.LastIndexOf("\\") + 1);
                    }
                    values.Add(LocRM.GetString("tInProgress") + " " + sFName);
                }
            }

            return(values);
        }