Implement automatic updates.
This commit is contained in:
parent
61e7d4b89d
commit
cb560a92d7
22
zaaReloaded2/Properties/Settings.Designer.cs
generated
22
zaaReloaded2/Properties/Settings.Designer.cs
generated
@ -72,16 +72,7 @@ namespace zaaReloaded2.Properties {
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("http://zaa.nephrowiki.de/downloads")]
|
||||
public string UpdatesUrl {
|
||||
get {
|
||||
return ((string)(this["UpdatesUrl"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("versioninfo.txt")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("http://zaa.nephrowiki.de/versioninfo.txt")]
|
||||
public string VersionInfoFile {
|
||||
get {
|
||||
return ((string)(this["VersionInfoFile"]));
|
||||
@ -96,5 +87,16 @@ namespace zaaReloaded2.Properties {
|
||||
return ((string)(this["ExceptionPostUrl"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
public global::System.DateTime LastUpdateCheck {
|
||||
get {
|
||||
return ((global::System.DateTime)(this["LastUpdateCheck"]));
|
||||
}
|
||||
set {
|
||||
this["LastUpdateCheck"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,14 @@
|
||||
<Setting Name="Homepage" Type="System.Uri" Scope="Application">
|
||||
<Value Profile="(Default)">http://zaa.nephrowiki.de</Value>
|
||||
</Setting>
|
||||
<Setting Name="UpdatesUrl" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">http://zaa.nephrowiki.de/downloads</Value>
|
||||
</Setting>
|
||||
<Setting Name="VersionInfoFile" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">versioninfo.txt</Value>
|
||||
<Value Profile="(Default)">http://zaa.nephrowiki.de/versioninfo.txt</Value>
|
||||
</Setting>
|
||||
<Setting Name="ExceptionPostUrl" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">http://zaa.nephrowiki.de/postreport.php</Value>
|
||||
</Setting>
|
||||
<Setting Name="LastUpdateCheck" Type="System.DateTime" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -24,6 +24,8 @@ using System.IO;
|
||||
using Word = Microsoft.Office.Interop.Word;
|
||||
using Office = Microsoft.Office.Core;
|
||||
using Microsoft.Office.Tools.Word;
|
||||
using Bovender.Versioning;
|
||||
using Bovender.Mvvm.Messaging;
|
||||
|
||||
namespace zaaReloaded2
|
||||
{
|
||||
@ -48,6 +50,11 @@ namespace zaaReloaded2
|
||||
|
||||
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
|
||||
{
|
||||
if (_updaterVM != null && _updaterVM.IsUpdatePending)
|
||||
{
|
||||
if (_updaterVM.InstallUpdateCommand.CanExecute(null))
|
||||
_updaterVM.InstallUpdateCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
@ -75,10 +82,36 @@ namespace zaaReloaded2
|
||||
|
||||
#endregion
|
||||
|
||||
#region Updater
|
||||
|
||||
void CheckForUpdates()
|
||||
{
|
||||
if (DateTime.Today == Properties.Settings.Default.LastUpdateCheck.Date)
|
||||
return;
|
||||
|
||||
Properties.Settings.Default.LastUpdateCheck = DateTime.Today;
|
||||
Properties.Settings.Default.Save();
|
||||
|
||||
_updaterVM = new UpdaterViewModel(new Updater.Updater());
|
||||
if (!_updaterVM.CanCheckForUpdate) return;
|
||||
|
||||
_updaterVM.UpdateAvailableMessage.Sent += UpdateAvailableMessage_Sent;
|
||||
_updaterVM.CheckForUpdateCommand.Execute(null);
|
||||
}
|
||||
|
||||
void UpdateAvailableMessage_Sent(object sender, MessageArgs<ViewModelMessageContent> e)
|
||||
{
|
||||
UpdaterViewModel uvm = e.Content.ViewModel as UpdaterViewModel;
|
||||
uvm.DestinationFolder = System.IO.Path.GetTempPath();
|
||||
uvm.DownloadUpdateCommand.Execute(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
|
||||
private Ribbon _ribbon;
|
||||
Ribbon _ribbon;
|
||||
UpdaterViewModel _updaterVM;
|
||||
|
||||
#endregion
|
||||
|
||||
|
37
zaaReloaded2/Updater/Updater.cs
Executable file
37
zaaReloaded2/Updater/Updater.cs
Executable file
@ -0,0 +1,37 @@
|
||||
/* Updater.cs
|
||||
* part of zaaReloaded2
|
||||
*
|
||||
* Copyright 2015 Daniel Kraus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace zaaReloaded2.Updater
|
||||
{
|
||||
class Updater : Bovender.Versioning.Updater
|
||||
{
|
||||
protected override Bovender.Versioning.SemanticVersion GetCurrentVersion()
|
||||
{
|
||||
return Version.CurrentVersion();
|
||||
}
|
||||
|
||||
protected override Uri GetVersionInfoUri()
|
||||
{
|
||||
return new Uri(Properties.Settings.Default.VersionInfoFile);
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,9 @@
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="zaaReloaded2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="zaaReloaded2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<zaaReloaded2.Properties.Settings>
|
||||
@ -38,15 +41,19 @@
|
||||
<setting name="Homepage" serializeAs="String">
|
||||
<value>http://zaa.nephrowiki.de</value>
|
||||
</setting>
|
||||
<setting name="UpdatesUrl" serializeAs="String">
|
||||
<value>http://zaa.nephrowiki.de/downloads</value>
|
||||
</setting>
|
||||
<setting name="VersionInfoFile" serializeAs="String">
|
||||
<value>versioninfo.txt</value>
|
||||
<value>http://zaa.nephrowiki.de/versioninfo.txt</value>
|
||||
</setting>
|
||||
<setting name="ExceptionPostUrl" serializeAs="String">
|
||||
<value>http://zaa.nephrowiki.de/postreport.php</value>
|
||||
</setting>
|
||||
</zaaReloaded2.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<userSettings>
|
||||
<zaaReloaded2.Properties.Settings>
|
||||
<setting name="LastUpdateCheck" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</zaaReloaded2.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
@ -216,6 +216,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Updater\Updater.cs" />
|
||||
<Compile Include="ViewModels\AboutViewModel.cs" />
|
||||
<Compile Include="Views\AboutView.xaml.cs">
|
||||
<DependentUpon>AboutView.xaml</DependentUpon>
|
||||
|
Loading…
Reference in New Issue
Block a user