Making it possible to debug if an update is required
This commit is contained in:
parent
3edecc336d
commit
64b6eb0f18
2 changed files with 30 additions and 9 deletions
|
|
@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void CheckVersionStatus()
|
||||
{
|
||||
string currentBuildToken = ApplicationSettings.Instance.get("CurrentBuildToken");
|
||||
string currentBuildToken = ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentBuildToken);
|
||||
string updateFileName = Path.Combine(updateFileLocation, string.Format("{0}.{1}", currentBuildToken, InstallerExtension));
|
||||
|
||||
string applicationBuildToken = VersionInfo.Instance.BuildToken;
|
||||
|
|
@ -183,7 +183,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void onVersionRequestSucceeded(object sender, EventArgs e)
|
||||
{
|
||||
string currentBuildToken = ApplicationSettings.Instance.get("CurrentBuildToken");
|
||||
string currentBuildToken = ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentBuildToken);
|
||||
string updateFileName = Path.Combine(updateFileLocation, string.Format("{0}.{1}", currentBuildToken, InstallerExtension));
|
||||
|
||||
string applicationBuildToken = VersionInfo.Instance.BuildToken;
|
||||
|
|
@ -267,7 +267,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (!WaitingToCompleteTransaction())
|
||||
{
|
||||
string downloadToken = ApplicationSettings.Instance.get("CurrentBuildToken");
|
||||
string downloadToken = ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentBuildToken);
|
||||
|
||||
if (downloadToken == null)
|
||||
{
|
||||
|
|
@ -280,7 +280,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
downloadAttempts++;
|
||||
SetUpdateStatus(UpdateStatusStates.UpdateDownloading);
|
||||
string downloadUri = $"{MatterControlApplication.MCWSBaseUri}/downloads/development/{ApplicationSettings.Instance.get("CurrentBuildToken")}";
|
||||
string downloadUri = $"{MatterControlApplication.MCWSBaseUri}/downloads/development/{ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentBuildToken)}";
|
||||
|
||||
//Make HEAD request to determine the size of the download (required by GAE)
|
||||
System.Net.WebRequest request = System.Net.WebRequest.Create(downloadUri);
|
||||
|
|
@ -388,13 +388,13 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public bool InstallUpdate()
|
||||
{
|
||||
string downloadToken = ApplicationSettings.Instance.get("CurrentBuildToken");
|
||||
string downloadToken = ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentBuildToken);
|
||||
|
||||
string updateFileName = Path.Combine(updateFileLocation, "{0}.{1}".FormatWith(downloadToken, InstallerExtension));
|
||||
#if __ANDROID__
|
||||
string friendlyFileName = Path.Combine(updateFileLocation, "MatterControlSetup.apk");
|
||||
#else
|
||||
string releaseVersion = ApplicationSettings.Instance.get("CurrentReleaseVersion");
|
||||
string releaseVersion = ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.CurrentReleaseVersion);
|
||||
string friendlyFileName = Path.Combine(updateFileLocation, "MatterControlSetup-{0}.{1}".FormatWith(releaseVersion, InstallerExtension));
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,28 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MatterHackers.MatterControl.VersionManagement
|
||||
{
|
||||
internal class LatestVersionRequest : WebRequestBase
|
||||
public class LatestVersionRequest : WebRequestBase
|
||||
{
|
||||
public static class VersionKey
|
||||
{
|
||||
public const string CurrentBuildToken = nameof(CurrentBuildToken);
|
||||
public const string CurrentBuildNumber = nameof(CurrentBuildNumber);
|
||||
public const string CurrentBuildUrl = nameof(CurrentBuildUrl);
|
||||
public const string CurrentReleaseVersion = nameof(CurrentReleaseVersion);
|
||||
public const string CurrentReleaseDate = nameof(CurrentReleaseDate);
|
||||
public const string UpdateRequired = nameof(UpdateRequired);
|
||||
}
|
||||
|
||||
public static string[] VersionKeys =
|
||||
{
|
||||
VersionKey.CurrentBuildToken,
|
||||
VersionKey.CurrentBuildNumber,
|
||||
VersionKey.CurrentBuildUrl,
|
||||
VersionKey.CurrentReleaseVersion,
|
||||
VersionKey.CurrentReleaseDate,
|
||||
VersionKey.UpdateRequired,
|
||||
};
|
||||
|
||||
public LatestVersionRequest()
|
||||
{
|
||||
string feedType = UserSettings.Instance.get("UpdateFeedType");
|
||||
|
|
@ -47,6 +67,8 @@ namespace MatterHackers.MatterControl.VersionManagement
|
|||
UserSettings.Instance.set("UpdateFeedType", feedType);
|
||||
}
|
||||
requestValues["ProjectToken"] = VersionInfo.Instance.ProjectToken;
|
||||
//requestValues["TestCode"] = "100"; // will cause response of update available and not required
|
||||
//requestValues["TestCode"] = "101"; // will cause response of update available and required
|
||||
requestValues["UpdateFeedType"] = feedType;
|
||||
uri = $"{MatterControlApplication.MCWSBaseUri}/api/1/get-current-release-version";
|
||||
}
|
||||
|
|
@ -83,8 +105,7 @@ namespace MatterHackers.MatterControl.VersionManagement
|
|||
|
||||
public override void ProcessSuccessResponse(JsonResponseDictionary responseValues)
|
||||
{
|
||||
List<string> responseKeys = new List<string> { "CurrentBuildToken", "CurrentBuildNumber", "CurrentBuildUrl", "CurrentReleaseVersion", "CurrentReleaseDate" };
|
||||
foreach (string key in responseKeys)
|
||||
foreach (string key in VersionKeys)
|
||||
{
|
||||
saveResponse(key, responseValues);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue