feature/auto-update #6
@@ -332,15 +332,15 @@
|
|||||||
{
|
{
|
||||||
"Name" = "8:Microsoft Visual Studio"
|
"Name" = "8:Microsoft Visual Studio"
|
||||||
"ProductName" = "8:Car Manager 3"
|
"ProductName" = "8:Car Manager 3"
|
||||||
"ProductCode" = "8:{8FDFF7ED-D464-4F87-BA8F-BDC1000520E4}"
|
"ProductCode" = "8:{24769DBA-B806-4E47-9F4C-17BC8AD0528E}"
|
||||||
"PackageCode" = "8:{83DA7553-805F-4A70-921B-9A6FB0787780}"
|
"PackageCode" = "8:{741BAAEC-3EE7-46C4-94AB-575C677186BB}"
|
||||||
"UpgradeCode" = "8:{6FF57925-465E-4DB9-85DA-CE933191A3DD}"
|
"UpgradeCode" = "8:{6FF57925-465E-4DB9-85DA-CE933191A3DD}"
|
||||||
"AspNetVersion" = "8:2.0.50727.0"
|
"AspNetVersion" = "8:2.0.50727.0"
|
||||||
"RestartWWWService" = "11:FALSE"
|
"RestartWWWService" = "11:FALSE"
|
||||||
"RemovePreviousVersions" = "11:TRUE"
|
"RemovePreviousVersions" = "11:TRUE"
|
||||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||||
"InstallAllUsers" = "11:FALSE"
|
"InstallAllUsers" = "11:FALSE"
|
||||||
"ProductVersion" = "8:1.4.0"
|
"ProductVersion" = "8:1.4.1"
|
||||||
"Manufacturer" = "8:Jaro Digital"
|
"Manufacturer" = "8:Jaro Digital"
|
||||||
"ARPHELPTELEPHONE" = "8:"
|
"ARPHELPTELEPHONE" = "8:"
|
||||||
"ARPHELPLINK" = "8:"
|
"ARPHELPLINK" = "8:"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Global
|
|||||||
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{93CA258B-A645-41A8-A24F-59036ABC173F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Debug|Any CPU.ActiveCfg = Debug
|
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Debug|Any CPU.ActiveCfg = Debug
|
||||||
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.ActiveCfg = Release
|
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.ActiveCfg = Release
|
||||||
|
{47ED51EB-1DD0-B8F0-88C8-92C6E3E06030}.Release|Any CPU.Build.0 = Release
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.4.0</ApplicationVersion>
|
<ApplicationVersion>1.4.1</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<ApplicationIcon>CarMgm_Icon.ico</ApplicationIcon>
|
<ApplicationIcon>CarMgm_Icon.ico</ApplicationIcon>
|
||||||
<AssemblyTitle>Car Manager 3</AssemblyTitle>
|
<AssemblyTitle>Car Manager 3</AssemblyTitle>
|
||||||
<Product>Car Manager 3</Product>
|
<Product>Car Manager 3</Product>
|
||||||
<Version>1.4.0</Version>
|
<Version>1.4.1</Version>
|
||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace CarManagerV3
|
|||||||
{
|
{
|
||||||
if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease))
|
if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease))
|
||||||
{
|
{
|
||||||
UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(), Updater.GetLatestVersion());
|
UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(true), Updater.GetLatestVersion(Properties.Settings.Default.AllowPrerelease));
|
||||||
updatePrompt.ShowDialog();
|
updatePrompt.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,12 +571,12 @@ namespace CarManagerV3
|
|||||||
{
|
{
|
||||||
if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease))
|
if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease))
|
||||||
{
|
{
|
||||||
UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(), Updater.GetLatestVersion());
|
UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(true), Updater.GetLatestVersion(Properties.Settings.Default.AllowPrerelease));
|
||||||
updatePrompt.ShowDialog();
|
updatePrompt.ShowDialog();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show($"You are already using the latest version. ({Updater.GetCurrentVersion()})", "No Updates Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show($"You are already using the latest version. \nYour Version: {Updater.GetCurrentVersion(true)} \nLatest Version: {Updater.GetLatestVersion(Properties.Settings.Default.AllowPrerelease)}", "No Updates Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ namespace CarManagerV3.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
lblInstalledVersion.Text = lblInstalledVersion.Text.Replace("?.?.?", currentVersion);
|
lblInstalledVersion.Text = lblInstalledVersion.Text.Replace("?.?.?", currentVersion);
|
||||||
lblLatestVersion.Text = lblLatestVersion.Text.Replace("?.?.?", latestVersion);
|
lblLatestVersion.Text = lblLatestVersion.Text.Replace("?.?.?", latestVersion);
|
||||||
|
if (Updater.IsLatestVersionPrerelease())
|
||||||
|
{
|
||||||
|
lblLatestVersion.Text += " (Pre-release)";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,15 +32,6 @@ namespace CarManagerV3.Forms
|
|||||||
|
|
||||||
private void btnInstallUpdate_Click(object sender, EventArgs e)
|
private void btnInstallUpdate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
var msgbox = new PleaseWait();
|
|
||||||
msgbox.Show();
|
|
||||||
Application.DoEvents();
|
|
||||||
StateManager.UpdateCar(car);
|
|
||||||
Image fooimg = ImageManager.GetImage(car);
|
|
||||||
msgbox.Close();
|
|
||||||
this.Close();
|
|
||||||
*/
|
|
||||||
PleaseWait loadForm = new PleaseWait("Downloading the newest version...");
|
PleaseWait loadForm = new PleaseWait("Downloading the newest version...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -58,7 +53,7 @@ namespace CarManagerV3.Forms
|
|||||||
|
|
||||||
private void btnReadChangelog_Click(object sender, EventArgs e)
|
private void btnReadChangelog_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Updater.openReleasePage();
|
Updater.OpenReleasePage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -22,8 +23,9 @@ namespace CarManagerV3.Manager
|
|||||||
private static readonly int CacheDurationMinutes = 60;
|
private static readonly int CacheDurationMinutes = 60;
|
||||||
private static bool cacheIncludesPrerelease = false;
|
private static bool cacheIncludesPrerelease = false;
|
||||||
private static readonly string debugVersion = null;//"1.2.0";
|
private static readonly string debugVersion = null;//"1.2.0";
|
||||||
|
private static bool isLatestVersionPrerelease = false;
|
||||||
|
|
||||||
public static string GetCurrentVersion()
|
public static string GetCurrentVersion(bool cutTrailingZeros = false)
|
||||||
{
|
{
|
||||||
//DEBUG::
|
//DEBUG::
|
||||||
if (debugVersion != null)
|
if (debugVersion != null)
|
||||||
@@ -33,7 +35,17 @@ namespace CarManagerV3.Manager
|
|||||||
|
|
||||||
var asm = Assembly.GetEntryAssembly()!;
|
var asm = Assembly.GetEntryAssembly()!;
|
||||||
Version v = asm.GetName().Version ?? new Version(0, 0, 0, 0);
|
Version v = asm.GetName().Version ?? new Version(0, 0, 0, 0);
|
||||||
return v.ToString();
|
string VersionString = v.ToString();
|
||||||
|
if(cutTrailingZeros)
|
||||||
|
{
|
||||||
|
// Remove trailing .0 parts
|
||||||
|
while (VersionString.EndsWith(".0"))
|
||||||
|
{
|
||||||
|
VersionString = VersionString.Substring(0, VersionString.Length - 2);
|
||||||
|
}
|
||||||
|
return VersionString;
|
||||||
|
}
|
||||||
|
return VersionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsCacheValid(bool includePreRelease = false)
|
private static bool IsCacheValid(bool includePreRelease = false)
|
||||||
@@ -72,6 +84,7 @@ namespace CarManagerV3.Manager
|
|||||||
var content = response.Content.ReadAsStringAsync().Result;
|
var content = response.Content.ReadAsStringAsync().Result;
|
||||||
dynamic release = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
|
dynamic release = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
|
||||||
latestVersion = release.tag_name;
|
latestVersion = release.tag_name;
|
||||||
|
isLatestVersionPrerelease = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If pre-release is requested, check for the latest pre-release version
|
// If pre-release is requested, check for the latest pre-release version
|
||||||
@@ -79,21 +92,31 @@ namespace CarManagerV3.Manager
|
|||||||
{
|
{
|
||||||
using (var client = new System.Net.Http.HttpClient())
|
using (var client = new System.Net.Http.HttpClient())
|
||||||
{
|
{
|
||||||
|
UrlEncoder encoder = System.Text.Encodings.Web.UrlEncoder.Default;
|
||||||
var response = client.GetAsync(PreReleaseEndpoint).Result;
|
var response = client.GetAsync(PreReleaseEndpoint).Result;
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
|
||||||
var content = response.Content.ReadAsStringAsync().Result;
|
var content = response.Content.ReadAsStringAsync().Result;
|
||||||
dynamic releases = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
|
dynamic releases = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
|
||||||
|
//System.Diagnostics.Debug.WriteLine("Fetched pre-release versions, count: " + releases.Count);
|
||||||
if (releases.Count > 0)
|
if (releases.Count > 0)
|
||||||
{
|
{
|
||||||
var preReleaseVersion = releases[0].tag_name;
|
var preReleaseVersion = releases[0].tag_name.ToString();
|
||||||
|
//System.Diagnostics.Debug.WriteLine("Latest unstable version: " + preReleaseVersion);
|
||||||
|
|
||||||
// Compare versions and return the newer one
|
// Compare versions and return the newer one
|
||||||
if (IsNewerVersion(preReleaseVersion, latestVersion))
|
if (IsNewerVersion(preReleaseVersion, latestVersion))
|
||||||
{
|
{
|
||||||
latestVersion = preReleaseVersion;
|
latestVersion = preReleaseVersion;
|
||||||
|
isLatestVersionPrerelease = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("Failed to fetch pre-release versions, status code: " + response.StatusCode + " at: " + PreReleaseEndpoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetCache(latestVersion, includePreRelease);
|
SetCache(latestVersion, includePreRelease);
|
||||||
@@ -180,7 +203,7 @@ namespace CarManagerV3.Manager
|
|||||||
return IsNewerVersion(latestVersion, currentVersion);
|
return IsNewerVersion(latestVersion, currentVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openReleasePage(string version = null)
|
public static void OpenReleasePage(string version = null)
|
||||||
{
|
{
|
||||||
if (version == null)
|
if (version == null)
|
||||||
{
|
{
|
||||||
@@ -193,5 +216,11 @@ namespace CarManagerV3.Manager
|
|||||||
UseShellExecute = true
|
UseShellExecute = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsLatestVersionPrerelease()
|
||||||
|
{
|
||||||
|
// Ensure we have the latest version info in cache
|
||||||
|
return isLatestVersionPrerelease;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user