Hello,
Been working through the demos and documentation on this control. I have it working but I am struggling to get my head around how to set the values of the indicators. Here is my code:
I want a very simple indicator - 1 progress bar indicating the total file size of the file being uploaded, the value to be the number of bytes currently being processed and the percentage. I'd also like the estimated upload time and speed (in KB/s) to be displayed.
I'm just about there but the time, speed and bytes value is incorrect. I think because of the total I am setting (i.e. 100).
Thanks,
Michael
Been working through the demos and documentation on this control. I have it working but I am struggling to get my head around how to set the values of the indicators. Here is my code:
private void UpdateProgressContext(UploadedFile file) |
{ |
const int total = 100; |
RadProgressContext progress = RadProgressContext.Current; |
DateTime startTime = DateTime.Now; |
for (int i = 0; i < total; i++) |
{ |
progress.PrimaryTotal = FileHelper.GetFileSize(file.ContentLength); |
progress.PrimaryValue = i; //TODO: file size |
progress.PrimaryPercent = i; |
progress.CurrentOperationText = file.GetName(); |
TimeSpan elapsed = DateTime.Now.Subtract(startTime); |
progress.TimeElapsed = string.Format("{0:D2}:{1:D2}:{2:D2} s", elapsed.Hours, elapsed.Minutes, elapsed.Seconds); |
double estimatedMillisecons = 24 * 60 * 60 * 1000; |
if (i != 0) |
{ |
estimatedMillisecons = total * elapsed.TotalMilliseconds / i; |
} |
TimeSpan estimated = TimeSpan.FromSeconds(1); |
if (estimatedMillisecons > 1) |
{ |
estimated = TimeSpan.FromMilliseconds(estimatedMillisecons); |
} |
progress.TimeEstimated = string.Format("{0:D2}:{1:D2}:{2:D2} s", estimated.Hours, estimated.Minutes, estimated.Seconds); |
double speed = 0.0d; |
if (elapsed.TotalSeconds > 0) |
{ |
speed = i / elapsed.TotalSeconds; |
} |
progress.Speed = string.Format("{0:0.00}", speed); |
if (!Response.IsClientConnected) |
{ |
//Cancel button was clicked or the browser was closed, so stop processing |
break; |
} |
//Stall the current thread for 0.1 seconds |
System.Threading.Thread.Sleep(100); |
} |
} |
I want a very simple indicator - 1 progress bar indicating the total file size of the file being uploaded, the value to be the number of bytes currently being processed and the percentage. I'd also like the estimated upload time and speed (in KB/s) to be displayed.
I'm just about there but the time, speed and bytes value is incorrect. I think because of the total I am setting (i.e. 100).
Thanks,
Michael