/// <summary> /// Fills the fileToProcess object and add the download/upload speed to the list /// </summary> /// <param name="fileToProcess"></param> /// <param name="sw"></param> public void AddValuesToList(FileToProcess fileToProcess, Stopwatch sw) { FileInfo fileInfo = new FileInfo(fileToProcess.TempFile); fileToProcess.FileSize = fileInfo.Length; fileToProcess.TimeInMiliseconds = sw.ElapsedMilliseconds; fileToProcess.Speed = ((fileToProcess.FileSize) / (fileToProcess.TimeInMiliseconds / 1000)); totalSpeedList.Add(fileToProcess.Speed); }
/// <summary> /// Perform the upload of temp files to host /// </summary> /// <param name="fileToProcess"></param> public override void ExecuteAction(FileToProcess fileToProcess) { try { using (WebClient wClient = new WebClient()) { Stopwatch sw = Stopwatch.StartNew(); wClient.UploadFile(fileToProcess.FileToProcessUri, "POST", fileToProcess.TempFile); sw.Stop(); AddValuesToList(fileToProcess, sw); } } catch (Exception) { throw; } }
/// <summary> /// Delegates to concrete class the process of dowmload/upload /// </summary> /// <param name="file"></param> public abstract void ExecuteAction(FileToProcess file);