mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-16 10:58:31 -05:00
More installer migration
This commit is contained in:
@@ -179,7 +179,6 @@
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.SqlServer.Compact.4.0.8854.1\lib\net40\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
@@ -188,6 +187,7 @@
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@@ -271,6 +271,8 @@
|
||||
<Compile Include="SplashWindow.xaml.cs">
|
||||
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Update\UpdateCheck.cs" />
|
||||
<Compile Include="Update\VersionFile.cs" />
|
||||
<Compile Include="VersionCheck.cs" />
|
||||
<Page Include="FeedErrorWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -7,7 +7,6 @@ using FeedCenter.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Deployment.Application;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -17,6 +16,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using FeedCenter.Update;
|
||||
|
||||
namespace FeedCenter
|
||||
{
|
||||
@@ -98,6 +98,10 @@ namespace FeedCenter
|
||||
// Initialize the feed display
|
||||
InitializeFeed();
|
||||
|
||||
// Check for update
|
||||
if (UpdateCheck.UpdateAvailable)
|
||||
newVersionLink.Visibility = Visibility.Visible;
|
||||
|
||||
Tracer.WriteLine("MainForm creation finished");
|
||||
}
|
||||
|
||||
@@ -539,11 +543,6 @@ namespace FeedCenter
|
||||
public Feed Feed;
|
||||
}
|
||||
|
||||
private class FeedReadWorkerOutput
|
||||
{
|
||||
public UpdateCheckInfo UpdateResult;
|
||||
}
|
||||
|
||||
private void SetProgressMode(bool value, int feedCount)
|
||||
{
|
||||
// Reset the progress bar if we need it
|
||||
@@ -607,9 +606,6 @@ namespace FeedCenter
|
||||
|
||||
private void HandleFeedReadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
// Get the state info
|
||||
var workerOutput = (FeedReadWorkerOutput) e.Result;
|
||||
|
||||
// Reset the database to current settings
|
||||
ResetDatabase();
|
||||
|
||||
@@ -625,10 +621,8 @@ namespace FeedCenter
|
||||
// Switch to normal mode
|
||||
SetProgressMode(false, 0);
|
||||
|
||||
// Check for update information
|
||||
var updateCheckInfo = workerOutput.UpdateResult;
|
||||
|
||||
if (updateCheckInfo != null && updateCheckInfo.UpdateAvailable)
|
||||
// Check for update
|
||||
if (UpdateCheck.UpdateAvailable)
|
||||
newVersionLink.Visibility = Visibility.Visible;
|
||||
|
||||
UpdateErrorLink();
|
||||
@@ -658,9 +652,6 @@ namespace FeedCenter
|
||||
// Get the input information
|
||||
var workerInput = (FeedReadWorkerInput) e.Argument;
|
||||
|
||||
// Create the output
|
||||
var workerOutput = new FeedReadWorkerOutput();
|
||||
|
||||
// Setup for progress
|
||||
var currentProgress = 0;
|
||||
|
||||
@@ -696,22 +687,10 @@ namespace FeedCenter
|
||||
worker.ReportProgress(currentProgress);
|
||||
|
||||
// See if we're due for a version check
|
||||
if (DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval && ApplicationDeployment.IsNetworkDeployed)
|
||||
if (DateTime.Now - Settings.Default.LastVersionCheck >= Settings.Default.VersionCheckInterval)
|
||||
{
|
||||
UpdateCheckInfo updateCheckInfo = null;
|
||||
|
||||
try
|
||||
{
|
||||
// Get the update information
|
||||
updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Tracer.WriteException(exception);
|
||||
}
|
||||
|
||||
// Store the update information in the output
|
||||
workerOutput.UpdateResult = updateCheckInfo;
|
||||
// Get the update information
|
||||
UpdateCheck.CheckForUpdate();
|
||||
|
||||
// Update the last check time
|
||||
Settings.Default.LastVersionCheck = DateTime.Now;
|
||||
@@ -723,9 +702,6 @@ namespace FeedCenter
|
||||
// Report progress
|
||||
worker.ReportProgress(currentProgress);
|
||||
|
||||
// Save the output
|
||||
e.Result = workerOutput;
|
||||
|
||||
// Sleep for a little bit so the user can see the update
|
||||
Thread.Sleep(Settings.Default.ProgressSleepInterval * 3);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Deployment.Application;
|
||||
using FeedCenter.Update;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
@@ -16,7 +16,7 @@ namespace FeedCenter.Options
|
||||
|
||||
applicationNameLabel.Text = Properties.Resources.ApplicationDisplayName;
|
||||
|
||||
string version = (ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "0");
|
||||
string version = UpdateCheck.CurrentVersion.ToString();
|
||||
versionLabel.Text = string.Format(Properties.Resources.Version, version);
|
||||
|
||||
companyLabel.Text = ((AssemblyCompanyAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
|
||||
|
||||
@@ -49,4 +49,4 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.2.*")]
|
||||
|
||||
9
Application/Properties/Resources.Designer.cs
generated
9
Application/Properties/Resources.Designer.cs
generated
@@ -1279,6 +1279,15 @@ namespace FeedCenter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Downloading update....
|
||||
/// </summary>
|
||||
public static string SplashDownloadingUpdate {
|
||||
get {
|
||||
return ResourceManager.GetString("SplashDownloadingUpdate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Installing update....
|
||||
/// </summary>
|
||||
|
||||
@@ -166,6 +166,9 @@
|
||||
<data name="SplashInstallingUpdate" xml:space="preserve">
|
||||
<value>Installing update...</value>
|
||||
</data>
|
||||
<data name="SplashDownloadingUpdate" xml:space="preserve">
|
||||
<value>Downloading update...</value>
|
||||
</data>
|
||||
<data name="SplashMaintainingDatabase" xml:space="preserve">
|
||||
<value>Maintaining database...</value>
|
||||
</data>
|
||||
|
||||
18
Application/Properties/Settings.Designer.cs
generated
18
Application/Properties/Settings.Designer.cs
generated
@@ -272,5 +272,23 @@ namespace FeedCenter.Properties {
|
||||
this["MultipleLineDisplay"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("FeedCenterSetup.xml")]
|
||||
public string VersionFile {
|
||||
get {
|
||||
return ((string)(this["VersionFile"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("http://server/FeedCenter/")]
|
||||
public string VersionLocation {
|
||||
get {
|
||||
return ((string)(this["VersionLocation"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,5 +65,11 @@
|
||||
<Setting Name="MultipleLineDisplay" Provider="Common.Settings.GenericSettingsProvider" Type="FeedCenter.Options.MultipleLineDisplay" Scope="User">
|
||||
<Value Profile="(Default)">Normal</Value>
|
||||
</Setting>
|
||||
<Setting Name="VersionFile" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">FeedCenterSetup.xml</Value>
|
||||
</Setting>
|
||||
<Setting Name="VersionLocation" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">http://server/FeedCenter/</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -1,12 +1,10 @@
|
||||
using Common.Debug;
|
||||
using FeedCenter.Data;
|
||||
using FeedCenter.Data;
|
||||
using FeedCenter.Properties;
|
||||
using FeedCenter.Update;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Deployment.Application;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace FeedCenter
|
||||
@@ -51,7 +49,7 @@ namespace FeedCenter
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
|
||||
// Get the version to display
|
||||
string version = (ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "0");
|
||||
string version = UpdateCheck.CurrentVersion.ToString();
|
||||
|
||||
// Show the version
|
||||
lblVersion.Content = string.Format(Properties.Resources.Version, version);
|
||||
@@ -183,16 +181,14 @@ namespace FeedCenter
|
||||
private void LoadProgressSteps()
|
||||
{
|
||||
// Load the progress steps
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashCheckingForUpdate, CheckUpdate));
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashInstallingUpdate, DownloadUpdate));
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashRestarting, RestartAfterUpdate));
|
||||
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseCreate, Properties.Resources.SplashCheckingForDatabase, CheckDatabase));
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseCreate, Properties.Resources.SplashCreatingDatabase, CreateDatabase));
|
||||
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseUpdate, Properties.Resources.SplashUpdatingDatabase, UpdateDatabase));
|
||||
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.DatabaseMaintenance, Properties.Resources.SplashMaintainingDatabase, MaintainDatabase));
|
||||
|
||||
_progressSteps.Add(new ProgressStep(ProgressKey.Update, Properties.Resources.SplashCheckingForUpdate, CheckUpdate));
|
||||
}
|
||||
|
||||
private static bool CheckUpdate()
|
||||
@@ -201,47 +197,8 @@ namespace FeedCenter
|
||||
if (!Settings.Default.CheckVersionAtStartup)
|
||||
return false;
|
||||
|
||||
// If the application isn't install then skip
|
||||
if (!ApplicationDeployment.IsNetworkDeployed)
|
||||
return false;
|
||||
|
||||
UpdateCheckInfo updateCheckInfo;
|
||||
|
||||
try
|
||||
{
|
||||
// Get detailed version information
|
||||
updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// Log the exception
|
||||
Tracer.WriteException(exception);
|
||||
|
||||
// No update at this time
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return if an update is available
|
||||
return updateCheckInfo.UpdateAvailable;
|
||||
}
|
||||
|
||||
private static bool DownloadUpdate()
|
||||
{
|
||||
// Download and installthe update
|
||||
ApplicationDeployment.CurrentDeployment.Update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool RestartAfterUpdate()
|
||||
{
|
||||
// We need to restart
|
||||
((App) Application.Current).Restart = true;
|
||||
|
||||
// Cancel the worker
|
||||
_backgroundWorker.CancelAsync();
|
||||
|
||||
return true;
|
||||
// Return if the check worked and an update is available
|
||||
return UpdateCheck.CheckForUpdate() && UpdateCheck.UpdateAvailable;
|
||||
}
|
||||
|
||||
private static bool CheckDatabase()
|
||||
|
||||
64
Application/Update/UpdateCheck.cs
Normal file
64
Application/Update/UpdateCheck.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Application/Update/VersionFile.cs
Normal file
49
Application/Update/VersionFile.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Common.Debug;
|
||||
using FeedCenter.Properties;
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FeedCenter.Update
|
||||
{
|
||||
public class VersionFile
|
||||
{
|
||||
public Version Version { get; set; }
|
||||
public string InstallFile { get; set; }
|
||||
public DateTime InstallCreated { get; set; }
|
||||
|
||||
public static VersionFile Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
var document = XDocument.Load(Settings.Default.VersionLocation + Settings.Default.VersionFile);
|
||||
|
||||
var versionInformationElement = document.Element("versionInformation");
|
||||
|
||||
if (versionInformationElement == null)
|
||||
return null;
|
||||
|
||||
var versionElement = versionInformationElement.Element("version");
|
||||
var installFileElement = versionInformationElement.Element("installFile");
|
||||
var installCreatedElement = versionInformationElement.Element("installCreated");
|
||||
|
||||
if (versionElement == null || installFileElement == null || installCreatedElement == null)
|
||||
return null;
|
||||
|
||||
var versionFile = new VersionFile
|
||||
{
|
||||
Version = Version.Parse(versionElement.Value),
|
||||
InstallFile = installFileElement.Value,
|
||||
InstallCreated = DateTime.Parse(installCreatedElement.Value)
|
||||
};
|
||||
|
||||
return versionFile;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Tracer.WriteException(exception);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,44 +2,23 @@
|
||||
using FeedCenter.Properties;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Deployment.Application;
|
||||
using System.Windows;
|
||||
using FeedCenter.Update;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
|
||||
namespace FeedCenter
|
||||
{
|
||||
internal static class VersionCheck
|
||||
{
|
||||
public static void DisplayUpdateInformation(bool showIfCurrent)
|
||||
public static async void DisplayUpdateInformation(bool showIfCurrent)
|
||||
{
|
||||
if (!ApplicationDeployment.IsNetworkDeployed)
|
||||
return;
|
||||
|
||||
UpdateCheckInfo updateCheckInfo = null;
|
||||
|
||||
try
|
||||
{
|
||||
updateCheckInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Tracer.WriteException(exception);
|
||||
}
|
||||
|
||||
DisplayUpdateInformation(updateCheckInfo, showIfCurrent);
|
||||
}
|
||||
|
||||
public static void DisplayUpdateInformation(UpdateCheckInfo updateCheckInfo, bool showIfCurrent)
|
||||
{
|
||||
// If we didn't get any information then do nothing
|
||||
if (updateCheckInfo == null)
|
||||
return;
|
||||
UpdateCheck.CheckForUpdate();
|
||||
|
||||
// Check for an update
|
||||
if (updateCheckInfo.UpdateAvailable)
|
||||
if (UpdateCheck.UpdateAvailable)
|
||||
{
|
||||
// Load the version string from the server
|
||||
Version serverVersion = updateCheckInfo.AvailableVersion;
|
||||
Version serverVersion = UpdateCheck.VersionFile.Version;
|
||||
|
||||
// Format the check title
|
||||
string updateCheckTitle = string.Format(Resources.UpdateCheckTitle, Resources.ApplicationDisplayName);
|
||||
@@ -52,7 +31,10 @@ namespace FeedCenter
|
||||
return;
|
||||
|
||||
// Get the update
|
||||
ApplicationDeployment.CurrentDeployment.Update();
|
||||
await UpdateCheck.DownloadUpdate();
|
||||
|
||||
// Install the update
|
||||
UpdateCheck.InstallUpdate();
|
||||
|
||||
// Set to restart
|
||||
((App) System.Windows.Application.Current).Restart = true;
|
||||
@@ -101,18 +83,16 @@ namespace FeedCenter
|
||||
_backgroundWorker = null;
|
||||
}
|
||||
|
||||
static void HandleBackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
|
||||
private static void HandleBackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
// If the application isn't installed then do nothing
|
||||
if (!ApplicationDeployment.IsNetworkDeployed)
|
||||
return;
|
||||
|
||||
e.Result = null;
|
||||
|
||||
try
|
||||
{
|
||||
UpdateCheck.CheckForUpdate();
|
||||
|
||||
// Get the update information and set it into the result
|
||||
e.Result = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);
|
||||
e.Result = UpdateCheck.UpdateAvailable;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -123,7 +103,7 @@ namespace FeedCenter
|
||||
private static void HandleBackgroundWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
// Display any update info
|
||||
DisplayUpdateInformation(e.Result as UpdateCheckInfo, false);
|
||||
DisplayUpdateInformation(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="LastVersionCheck" serializeAs="String">
|
||||
<value/>
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="StartWithWindows" serializeAs="String">
|
||||
<value>False</value>
|
||||
@@ -52,7 +52,7 @@
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="Browser" serializeAs="String">
|
||||
<value/>
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OpenAllSleepIntervalFirst" serializeAs="String">
|
||||
<value>1500</value>
|
||||
@@ -79,6 +79,12 @@
|
||||
<setting name="VersionCheckInterval" serializeAs="String">
|
||||
<value>01:00:00</value>
|
||||
</setting>
|
||||
<setting name="VersionFile" serializeAs="String">
|
||||
<value>FeedCenterSetup.xml</value>
|
||||
</setting>
|
||||
<setting name="VersionLocation" serializeAs="String">
|
||||
<value>http://server/FeedCenter/</value>
|
||||
</setting>
|
||||
</FeedCenter.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<startup>
|
||||
|
||||
Reference in New Issue
Block a user