mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-09-24 03:36:34 +00:00
formatting code
This commit is contained in:
@@ -29,6 +29,5 @@ namespace ZitiDesktopEdge.Utility {
|
||||
string releaseName = json.Property("name").Value.ToString();
|
||||
return VersionUtil.NormalizeVersion(new Version(releaseVersion));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,12 +626,12 @@ namespace ZitiUpdateService {
|
||||
return;
|
||||
}
|
||||
semaphore.Wait();
|
||||
|
||||
|
||||
try {
|
||||
Logger.Debug("checking for update");
|
||||
String publishedDate;
|
||||
int avail;
|
||||
|
||||
|
||||
check.IsUpdateAvailable(assemblyVersion, out avail, out publishedDate);
|
||||
if (avail >= 0) {
|
||||
Logger.Debug("update check complete. no update available");
|
||||
@@ -651,9 +651,7 @@ namespace ZitiUpdateService {
|
||||
|
||||
if (check.AlreadyDownloaded(updateFolder, filename)) {
|
||||
Logger.Trace("package has already been downloaded to {0}", fileDestination);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Logger.Info("copying update package begins");
|
||||
check.CopyUpdatePackage(updateFolder, filename);
|
||||
Logger.Info("copying update package complete");
|
||||
@@ -662,8 +660,7 @@ namespace ZitiUpdateService {
|
||||
if (sender == null && e == null) {
|
||||
Logger.Info("package is in {0} - moving to install phase", fileDestination);
|
||||
|
||||
if (!check.HashIsValid(updateFolder, filename))
|
||||
{
|
||||
if (!check.HashIsValid(updateFolder, filename)) {
|
||||
Logger.Warn("The file was downloaded but the hash is not valid. The file will be removed: {0}", fileDestination);
|
||||
File.Delete(fileDestination);
|
||||
semaphore.Release();
|
||||
@@ -677,27 +674,27 @@ namespace ZitiUpdateService {
|
||||
Checkers.ZDEInstallerInfo info = check.GetZDEInstallerInfo(fileDestination);
|
||||
|
||||
if (info.IsCritical && _installationReminder == null) {
|
||||
// Timer for installation reminder
|
||||
var installationReminderInterval = ConfigurationManager.AppSettings.Get("InstallationReminder");
|
||||
var instInt = TimeSpan.Zero;
|
||||
if (!TimeSpan.TryParse(installationReminderInterval, out instInt)) {
|
||||
// if InstallationReminder value is not configured, set it to 1 hour
|
||||
instInt = new TimeSpan(1, 0, 0);
|
||||
}
|
||||
TimerState state = new TimerState();
|
||||
state.zdeInstallerInfo = info;
|
||||
System.Threading.TimerCallback callback = new System.Threading.TimerCallback(TriggerUpdateEvent);
|
||||
// waits for the time updated in instInt field and then triggers at every interval
|
||||
_installationReminder = new CustomTimer(callback, state, instInt, instInt);
|
||||
state._timer = _installationReminder;
|
||||
Logger.Info("Installation reminder for ZDE version {0} is set to {1}", info.Version, instInt);
|
||||
}
|
||||
// Timer for installation reminder
|
||||
var installationReminderInterval = ConfigurationManager.AppSettings.Get("InstallationReminder");
|
||||
var instInt = TimeSpan.Zero;
|
||||
if (!TimeSpan.TryParse(installationReminderInterval, out instInt)) {
|
||||
// if InstallationReminder value is not configured, set it to 1 hour
|
||||
instInt = new TimeSpan(1, 0, 0);
|
||||
}
|
||||
TimerState state = new TimerState();
|
||||
state.zdeInstallerInfo = info;
|
||||
System.Threading.TimerCallback callback = new System.Threading.TimerCallback(TriggerUpdateEvent);
|
||||
// waits for the time updated in instInt field and then triggers at every interval
|
||||
_installationReminder = new CustomTimer(callback, state, instInt, instInt);
|
||||
state._timer = _installationReminder;
|
||||
Logger.Info("Installation reminder for ZDE version {0} is set to {1}", info.Version, instInt);
|
||||
}
|
||||
|
||||
if (_installationReminder != null) {
|
||||
info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds
|
||||
info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds);
|
||||
Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime);
|
||||
}
|
||||
if (_installationReminder != null) {
|
||||
info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds
|
||||
info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds);
|
||||
Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime);
|
||||
}
|
||||
if (info.Version != null) {
|
||||
NotifyInstallationUpdates(info, 0, "");
|
||||
}
|
||||
@@ -708,7 +705,7 @@ namespace ZitiUpdateService {
|
||||
string fileDestination = Path.Combine(updateFolder, filename);
|
||||
Checkers.ZDEInstallerInfo info = check.GetZDEInstallerInfo(fileDestination);
|
||||
if (info.Version != null) {
|
||||
NotifyInstallationUpdates(info, -1, "Error Occured");
|
||||
NotifyInstallationUpdates(info, -1, "Error Occurred");
|
||||
}
|
||||
} finally {
|
||||
Logger.Error(ex, "Unexpected error has occurred");
|
||||
@@ -718,7 +715,7 @@ namespace ZitiUpdateService {
|
||||
}
|
||||
|
||||
private void installZDE(string fileDestination) {
|
||||
try {
|
||||
try {
|
||||
StopZiti();
|
||||
StopUI().Wait();
|
||||
|
||||
|
||||
@@ -108,18 +108,18 @@ namespace ZitiUpdateService.Checkers {
|
||||
return nextVersion;
|
||||
}
|
||||
|
||||
override public ZDEInstallerInfo GetZDEInstallerInfo(string fileDestination) {
|
||||
ZDEInstallerInfo info = new ZDEInstallerInfo();
|
||||
try {
|
||||
override public ZDEInstallerInfo GetZDEInstallerInfo(string fileDestination) {
|
||||
ZDEInstallerInfo info = new ZDEInstallerInfo();
|
||||
try {
|
||||
|
||||
info.CreationTime = getCreationTime(publishedDateTime, fileDestination);
|
||||
info.Version = nextVersion;
|
||||
info.CreationTime = getCreationTime(publishedDateTime, fileDestination);
|
||||
info.Version = nextVersion;
|
||||
|
||||
Logger.Trace("File is created at {0}, comparing with current time: {1} ", info.CreationTime.ToString(), info.CreationTime.Date.AddDays(7).CompareTo(DateTime.Now));
|
||||
if (info.CreationTime.Date.AddDays(7).CompareTo(DateTime.Now) <= 0) {
|
||||
info.IsCritical = true;
|
||||
Logger.Info("ZDEInstaller is marked as critical, because the user has not installed the new installer for a week");
|
||||
} else {
|
||||
Logger.Trace("File is created at {0}, comparing with current time: {1} ", info.CreationTime.ToString(), info.CreationTime.Date.AddDays(7).CompareTo(DateTime.Now));
|
||||
if (info.CreationTime.Date.AddDays(7).CompareTo(DateTime.Now) <= 0) {
|
||||
info.IsCritical = true;
|
||||
Logger.Info("ZDEInstaller is marked as critical, because the user has not installed the new installer for a week");
|
||||
} else {
|
||||
string assemblyVersionStr = Assembly.GetExecutingAssembly().GetName().Version.ToString(); //fetch from ziti?
|
||||
Version assemblyVersion = new Version(assemblyVersionStr);
|
||||
|
||||
@@ -136,34 +136,34 @@ namespace ZitiUpdateService.Checkers {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not fetch the installer information due to - {0}", e.Message);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not fetch the installer information due to - {0}", e.Message);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private string convertISOToDateTimeString(string publishedDateISO) {
|
||||
try {
|
||||
DateTime publishedDate = DateTime.Parse(publishedDateISO, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
return publishedDate.ToString();
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not convert published date of the installer - input string : {0} due to {1}. Fetching download time instead.", publishedDateISO, e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private string convertISOToDateTimeString(string publishedDateISO) {
|
||||
try {
|
||||
DateTime publishedDate = DateTime.Parse(publishedDateISO, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
return publishedDate.ToString();
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not convert published date of the installer - input string : {0} due to {1}. Fetching download time instead.", publishedDateISO, e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime getCreationTime(string publishedDateStr, string fileDestination) {
|
||||
DateTime publishedDate;
|
||||
private DateTime getCreationTime(string publishedDateStr, string fileDestination) {
|
||||
DateTime publishedDate;
|
||||
|
||||
try {
|
||||
DateTime.TryParse(publishedDateStr, out publishedDate);
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not convert published date of the installer - input string : {0} due to {1}. Fetching download time instead.", publishedDateStr, e.Message);
|
||||
publishedDate = File.GetCreationTime(fileDestination);
|
||||
try {
|
||||
DateTime.TryParse(publishedDateStr, out publishedDate);
|
||||
} catch (Exception e) {
|
||||
Logger.Error("Could not convert published date of the installer - input string : {0} due to {1}. Fetching download time instead.", publishedDateStr, e.Message);
|
||||
publishedDate = File.GetCreationTime(fileDestination);
|
||||
|
||||
}
|
||||
return publishedDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
return publishedDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user