Merge pull request #2889 from larsbrubaker/design_tools

Check for update every day
This commit is contained in:
Lars Brubaker 2018-01-13 13:35:17 -08:00 committed by GitHub
commit 5778ef9608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 29 deletions

View file

@ -104,7 +104,7 @@ namespace MatterHackers.MatterControl.AboutPage
UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, releaseCode);
}
UpdateControlData.Instance.CheckForUpdateUserRequested();
UpdateControlData.Instance.CheckForUpdate();
};
currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList);

View file

@ -33,6 +33,7 @@ using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Timers;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
@ -53,10 +54,6 @@ namespace MatterHackers.MatterControl
public int DownloadPercent { get { return downloadPercent; } }
public enum UpdateRequestType { UserRequested, Automatic, FirstTimeEver };
private UpdateRequestType updateRequestType;
public enum UpdateStatusStates { MayBeAvailable, CheckingForUpdate, UpdateAvailable, UpdateDownloading, ReadyToInstall, UpToDate, UnableToConnectToServer, UpdateRequired };
private bool WaitingToCompleteTransaction()
@ -112,7 +109,8 @@ namespace MatterHackers.MatterControl
}
}
static bool haveShowUpdateRequired = false;
private static bool haveShowUpdateRequired = false;
private void SetUpdateStatus(UpdateStatusStates updateStatus)
{
if (this.updateStatus != updateStatus)
@ -178,16 +176,10 @@ namespace MatterHackers.MatterControl
return updateStatus == UpdateStatusStates.UpdateAvailable && ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.UpdateRequired) == "True";
}
private set {}
private set { }
}
public void CheckForUpdateUserRequested()
{
updateRequestType = UpdateRequestType.UserRequested;
CheckForUpdate();
}
private void CheckForUpdate()
public void CheckForUpdate()
{
if (!WaitingToCompleteTransaction())
{
@ -222,7 +214,8 @@ namespace MatterHackers.MatterControl
else
{
SetUpdateStatus(UpdateStatusStates.UpdateAvailable);
if (updateRequestType == UpdateRequestType.FirstTimeEver)
bool firstUpdateRequest = ApplicationSettings.Instance.GetClientToken() == null;
if (firstUpdateRequest)
{
UiThread.RunOnIdle(() =>
{
@ -329,7 +322,7 @@ namespace MatterHackers.MatterControl
{
this.downloadPercent = (int)(e.BytesReceived * 100 / downloadSize);
}
UiThread.RunOnIdle(() => UpdateStatusChanged.CallEvents(this, e) );
UiThread.RunOnIdle(() => UpdateStatusChanged.CallEvents(this, e));
}
private void DownloadCompleted(object sender, AsyncCompletedEventArgs e)
@ -366,14 +359,6 @@ namespace MatterHackers.MatterControl
if (ApplicationSettings.Instance.GetClientToken() != null
|| OemSettings.Instance.CheckForUpdatesOnFirstRun)
{
if (ApplicationSettings.Instance.GetClientToken() == null)
{
updateRequestType = UpdateRequestType.FirstTimeEver;
}
else
{
updateRequestType = UpdateRequestType.Automatic;
}
//If we have already requested an update once, check on load
CheckForUpdate();
}
@ -387,6 +372,16 @@ namespace MatterHackers.MatterControl
SetUpdateStatus(UpdateStatusStates.UpdateAvailable);
}
}
// Now that we are running, check for an update every 24 hours.
var aTimer = new System.Timers.Timer(24 * 60 * 60 * 1000); //one day in milliseconds
aTimer.Elapsed += new ElapsedEventHandler(CheckForUpdateDaily);
aTimer.Start();
}
private void CheckForUpdateDaily(object source, ElapsedEventArgs e)
{
CheckForUpdate();
}
public void OnUpdateStatusChanged(EventArgs e)
@ -456,4 +451,4 @@ namespace MatterHackers.MatterControl
return false;
}
}
}
}

View file

@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl
};
checkUpdateLink.Click += (s, e) =>
{
UpdateControlData.Instance.CheckForUpdateUserRequested();
UpdateControlData.Instance.CheckForUpdate();
};
this.AddChild(checkUpdateLink);

View file

@ -297,7 +297,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
{
UiThread.RunOnIdle(() =>
{
UpdateControlData.Instance.CheckForUpdateUserRequested();
UpdateControlData.Instance.CheckForUpdate();
DialogWindow.Show<CheckForUpdatesPage>();
});
};

View file

@ -126,7 +126,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
UiThread.RunOnIdle(() =>
{
UpdateControlData.Instance.CheckForUpdateUserRequested();
UpdateControlData.Instance.CheckForUpdate();
DialogWindow.Show<CheckForUpdatesPage>();
});
});

@ -1 +1 @@
Subproject commit 33844d2fce5ae02bd7abe24009bda6ac292a5e6f
Subproject commit d1ec47c70e3b85634fed4742266de42409c6cfee