More installer migration

This commit is contained in:
2014-11-05 17:57:25 -05:00
parent a400048fe1
commit 17356d76bf
18 changed files with 332 additions and 146 deletions

View File

@@ -0,0 +1,64 @@
using FeedCenter.Properties;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
namespace FeedCenter.Update
{
public static class UpdateCheck
{
public static VersionFile VersionFile { get; private set; }
public static string LocalInstallFile { get; private set; }
public static bool UpdateAvailable { get; private set; }
public static Version CurrentVersion
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
}
public static bool CheckForUpdate()
{
VersionFile = VersionFile.Load();
if (VersionFile == null)
return false;
var serverVersion = VersionFile.Version;
var localVersion = CurrentVersion;
UpdateAvailable = serverVersion > localVersion;
return true;
}
internal static async Task<bool> DownloadUpdate()
{
if (VersionFile == null)
return false;
var remoteFile = Settings.Default.VersionLocation + VersionFile.InstallFile;
LocalInstallFile = Path.Combine(Path.GetTempPath(), VersionFile.InstallFile);
var webClient = new WebClient();
await webClient.DownloadFileTaskAsync(new Uri(remoteFile), LocalInstallFile);
return true;
}
internal static bool InstallUpdate()
{
if (VersionFile == null)
return false;
Process.Start(LocalInstallFile, "/passive");
return true;
}
}
}