aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Installer/MainWindow.xaml.cs
diff options
context:
space:
mode:
authorEric Reed <ebr@mediabrowser3.com>2013-02-25 21:34:11 -0500
committerEric Reed <ebr@mediabrowser3.com>2013-02-25 21:34:11 -0500
commit1013717808c5744f10e97bd8b79132e29b915c1a (patch)
treec92eb255776a82d00ddae368e3f64bf1a1ce42ff /MediaBrowser.Installer/MainWindow.xaml.cs
parente43f66ef0764ae54b85986ccd7df50107a679c75 (diff)
Show version number on installer download
Diffstat (limited to 'MediaBrowser.Installer/MainWindow.xaml.cs')
-rw-r--r--MediaBrowser.Installer/MainWindow.xaml.cs38
1 files changed, 29 insertions, 9 deletions
diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs
index 00b314b54..6bd2834af 100644
--- a/MediaBrowser.Installer/MainWindow.xaml.cs
+++ b/MediaBrowser.Installer/MainWindow.xaml.cs
@@ -95,13 +95,17 @@ namespace MediaBrowser.Installer
/// <returns></returns>
protected async Task DoInstall()
{
- lblStatus.Content = "Downloading "+FriendlyName+"...";
+ lblStatus.Content = string.Format("Downloading {0}...", FriendlyName);
dlAnimation.StartAnimation();
prgProgress.Value = 0;
prgProgress.Visibility = Visibility.Visible;
+ // Determine Package version
+ var version = await GetPackageVersion().ConfigureAwait(false);
+ lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
+
// Download
- var archive = await DownloadPackage();
+ var archive = await DownloadPackage(version).ConfigureAwait(false);
dlAnimation.StopAnimation();
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;
@@ -141,18 +145,14 @@ namespace MediaBrowser.Installer
}
- /// <summary>
- /// Download our specified package to an archive in a temp location
- /// </summary>
- /// <returns>The fully qualified name of the downloaded package</returns>
- protected async Task<string> DownloadPackage()
+ protected async Task<PackageVersionInfo> GetPackageVersion()
{
using (var client = new WebClient())
{
try
{
// get the package information for the server
- var json = await client.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name="+PackageName);
+ var json = await client.DownloadStringTaskAsync("http://www.mb3admin.com/admin/service/package/retrieveAll?name=" + PackageName).ConfigureAwait(false);
var packages = JsonSerializer.DeserializeFromString<List<PackageInfo>>(json);
var version = packages[0].versions.Where(v => v.classification == PackageClass).OrderByDescending(v => v.version).FirstOrDefault(v => v.version <= PackageVersion);
@@ -161,11 +161,31 @@ namespace MediaBrowser.Installer
SystemClose("Could not locate download package. Aborting.");
return null;
}
+ }
+ catch (Exception e)
+ {
+ SystemClose(e.GetType().FullName + "\n\n" + e.Message);
+ }
+
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Download our specified package to an archive in a temp location
+ /// </summary>
+ /// <returns>The fully qualified name of the downloaded package</returns>
+ protected async Task<string> DownloadPackage(PackageVersionInfo version)
+ {
+ using (var client = new WebClient())
+ {
+ try
+ {
var archiveFile = Path.Combine(PrepareTempLocation(), version.targetFilename);
// setup download progress and download the package
client.DownloadProgressChanged += DownloadProgressChanged;
- await client.DownloadFileTaskAsync(version.sourceUrl, archiveFile);
+ await client.DownloadFileTaskAsync(version.sourceUrl, archiveFile).ConfigureAwait(false);
return archiveFile;
}
catch (Exception e)