Closed Jevs242 closed 1 year ago
Merging #2260 (5140d9e) into master (fa1473b) will increase coverage by
0.00%
. The diff coverage is100.00%
.:exclamation: Current head 5140d9e differs from pull request most recent head dfa7606. Consider uploading reports for the commit dfa7606 to get more accurate results
@@ Coverage Diff @@
## master #2260 +/- ##
=======================================
Coverage 91.43% 91.43%
=======================================
Files 134 134
Lines 20158 20162 +4
Branches 2807 2809 +2
=======================================
+ Hits 18432 18436 +4
Misses 1237 1237
Partials 489 489
Impacted Files | Coverage Δ | |
---|---|---|
...ions/Databases/DownloadUniProtDatabaseFunctions.cs | 100.00% <100.00%> (ø) |
I think there may be a better way to use the HttpClient than what we implemented in the past. It would be nice to have a progress bar, a way to cancel the download, and a guarantee that the UI doesn't lock up during the download
The top answer in this stack overflow question looks like it could be a better way to do it.
I did a research about how to make a progress bar and I need the information in contentLength to know how many is the dowload size but the uniprot page when I download any proteome the ContentLength gives me null.
Instead of a progress bar, maybe we can just report total bytes downloaded and update that frequently so the user knows there is some action.
private void startDownload()
{
Thread thread = new Thread(() => {
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("http://joshua-ferrara.com/luahelper/lua.syn"), @"C:\LUAHelper\Syntax Files\lua.syn");
});
thread.Start();
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.BeginInvoke((MethodInvoker) delegate {
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
label2.Text = "Downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive;
progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
});
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
this.BeginInvoke((MethodInvoker) delegate {
label2.Text = "Completed";
});
}
maybe a cancel button too?
I changed the url format in StringBuilder htmlQueryString and increased the client wait time because some xml files were taking too long and that was causing an error.