private void Control_PreRender(object sender, EventArgs args) { if (IsDesignTime) { return; } // Find the current upload context string postBackID = Page.Request.Params["postBackID"]; string barID = Page.Request.Params["barID"]; // Set the status to Cancelled if requested. if (Page.Request.Params["cancelled"] == "true") { UploadModule.CancelPostBack(postBackID); } IUploadProgressState progressState = new UploadProgressState(); UploadModule.BindProgressState(postBackID, barID, progressState); if (progressState.Status == UploadStatus.Unknown) { // Status is unknown, so try to find the last post back based on the lastPostBackID param. // If successful, use the status of the last post back. string lastPostBackID = Page.Request.Params["lastPostBackID"]; if (lastPostBackID != null && lastPostBackID.Length > 0 && Page.Request.Params["refresher"] == null) { UploadModule.BindProgressState(lastPostBackID, barID, progressState); if (progressState.FileBytesRead == 0 && progressState.ProcessingState == null) { progressState.Status = UploadStatus.Unknown; } } } Status = progressState.Status; ProgressInfo progress = null; progress = (ProgressInfo)progressState.ProcessingState; if (progress != null && Status == UploadStatus.Completed) { Status = UploadStatus.ProcessingCompleted; } Attributes["status"] = Status.ToString(); if (WhenStatus != null) { string[] matchingStatuses = WhenStatus.Split(' '); if (Array.IndexOf(matchingStatuses, Status.ToString()) == -1) { this.Visible = false; } } }
/// <summary> /// Fills in an <see cref="IUploadProgressState"/> object with the progress state for /// a given post-back ID and control UniqueID. /// </summary> /// <param name="postBackID"> /// The post-back ID for which the progress state should be retrieved. /// </param> /// <param name="controlUniqueID"> /// The UniqueID of the control for which the processing state should be retrieved, /// or null to retrieve progress state without processing state. /// </param> /// <param name="progressState"> /// A <see cref="IUploadProgressState"/> to be filled in with the progress state /// for the given post-back ID and control UniqueID. /// </param> /// <remarks>The progress state is cached for the length of the current request to /// ensure consistency across multiple calls during a single request and to reduce /// the number of calls made /// to the underlying <see cref="IUploadModule"/> implementation since some /// implementations might need to access the network to determine the /// progress state.</remarks> public static void BindProgressState(string postBackID, string controlUniqueID, IUploadProgressState progressState) { HttpContext ctx = HttpContext.Current; if (ctx == null) { InstalledModule.BindProgressState(postBackID, controlUniqueID, progressState); return; } string cacheKey = String.Format("NeatUpload_cachedProgressState_{0}-{1}", postBackID, controlUniqueID); UploadProgressState cachedProgressState = ctx.Items[cacheKey] as Internal.UI.UploadProgressState; if (cachedProgressState == null) { cachedProgressState = new UploadProgressState(); InstalledModule.BindProgressState(postBackID, controlUniqueID, cachedProgressState); ctx.Items[cacheKey] = cachedProgressState; } UploadProgressState.Copy(cachedProgressState, progressState); }
private void Control_PreRender(object sender, EventArgs args) { if (IsDesignTime) return; // Find the current upload context string postBackID = Page.Request.Params["postBackID"]; string barID = Page.Request.Params["barID"]; // Set the status to Cancelled if requested. if (Page.Request.Params["cancelled"] == "true") { UploadModule.CancelPostBack(postBackID); } IUploadProgressState progressState = new UploadProgressState(); UploadModule.BindProgressState(postBackID, barID, progressState); if (progressState.Status == UploadStatus.Unknown) { // Status is unknown, so try to find the last post back based on the lastPostBackID param. // If successful, use the status of the last post back. string lastPostBackID = Page.Request.Params["lastPostBackID"]; if (lastPostBackID != null && lastPostBackID.Length > 0 && Page.Request.Params["refresher"] == null) { UploadModule.BindProgressState(lastPostBackID, barID, progressState); if (progressState.FileBytesRead == 0 && progressState.ProcessingState == null) { progressState.Status = UploadStatus.Unknown; } } } Status = progressState.Status; ProgressInfo progress = null; progress = (ProgressInfo)progressState.ProcessingState; if (progress != null && Status == UploadStatus.Completed) { Status = UploadStatus.ProcessingCompleted; } Attributes["status"] = Status.ToString(); if (WhenStatus != null) { string[] matchingStatuses = WhenStatus.Split(' '); if (Array.IndexOf(matchingStatuses, Status.ToString()) == -1) { this.Visible = false; } } }
public MediaUploadProgressChangedEventArgs(UploadProgressState state, long numberOfBytesUploaded, long totalOfBytesToUpload) : base(numberOfBytesUploaded, totalOfBytesToUpload) { State = state; NumberOfBytesUploaded = numberOfBytesUploaded; TotalOfBytesToUpload = totalOfBytesToUpload; }
/// <summary> /// Fills in an <see cref="IUploadProgressState"/> object with the progress state for /// a given post-back ID and control UniqueID. /// </summary> /// <param name="postBackID"> /// The post-back ID for which the progress state should be retrieved. /// </param> /// <param name="controlUniqueID"> /// The UniqueID of the control for which the progress state should be retrieved. /// </param> /// <param name="progressState"> /// A <see cref="IUploadProgressState"/> to be filled in with the progress state /// for the given post-back ID and control UniqueID. /// </param> /// <remarks>The progress state is cached for the length of the current request to /// ensure consistency across multiple calls during a single request and to reduce /// the number of calls made /// to the underlying <see cref="IUploadModule"/> implementation since some /// implementations might need to access the network to determine the /// progress state.</remarks> public static void BindProgressState(string postBackID, string controlUniqueID, IUploadProgressState progressState) { HttpContext ctx = HttpContext.Current; if (ctx != null) { InstalledModule.BindProgressState(postBackID, controlUniqueID, progressState); return; } string cacheKey = String.Format("NeatUpload_cachedProgressState_{0}-{1}", postBackID, controlUniqueID); UploadProgressState cachedProgressState = ctx.Items[cacheKey] as Internal.UI.UploadProgressState; if (cachedProgressState == null) { cachedProgressState = new UploadProgressState(); InstalledModule.BindProgressState(postBackID, controlUniqueID, cachedProgressState); ctx.Items[cacheKey] = cachedProgressState; } UploadProgressState.Copy(cachedProgressState, progressState); }
public UploadStateChangedEventArgs(UploadProgressState state, long numberOfBytesUploaded, long totalOfBytesToUpload) { State = state; NumberOfBytesUploaded = numberOfBytesUploaded; TotalOfBytesToUpload = totalOfBytesToUpload; }