Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
fixed installer argument and init flow
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi committed Jan 30, 2019
1 parent b8e1356 commit 479dbc4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SpeckleInstaller.iss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Root: HKCU; Subkey: "SOFTWARE\McNeel\Rhinoceros\6.0\Plug-ins\512d9705-6f92-49ca-


[Icons]
Name: "{group}\Check for updates"; Filename: "{#SpeckleFolder}\{#UpdaterFilename} -showprogress"
Name: "{group}\Check for updates"; Filename: "{#SpeckleFolder}\{#UpdaterFilename}"; Parameters: "-showprogress"
Name: "{userappdata}\Microsoft\Windows\Start Menu\Programs\Startup\Speckle"; Filename: "{#SpeckleFolder}\{#UpdaterFilename}"; Tasks: updates
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
;Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Expand Down
38 changes: 24 additions & 14 deletions SpeckleUpdater/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,48 @@ public partial class MainWindow : Window

public MainWindow(bool showProgress)
{
_showProgress = showProgress;
InitializeComponent();
try
{
_showProgress = showProgress;
InitializeComponent();
if(!_showProgress)
if (!_showProgress)
{
Hide();
}

CheckForUpdates();
}
catch (Exception ex)
{
File.WriteAllText(Path.Combine(folder, "error_log.txt"), ex.ToString());
System.Threading.Thread.Sleep(2000);
Close();
}

System.Threading.Thread.Sleep(5000);

}


private async void CheckForUpdates()
{
var release = await Api.GetLatestRelease();

if (release == null)
{
UpdateMessage.Text = $"You already have the latest {Globals.AppName}! {release.Name}";
OkBtn.Visibility = Visibility.Visible;
//Close();
UpdateMessage.Text = $"You already have the latest {Globals.AppName}! {release.Name}";
OkBtn.Visibility = Visibility.Visible;
if (!_showProgress)
{
Close();
}
}

else if (!UpdateAvailable(release))
{
UpdateMessage.Text = $"You already have the latest {Globals.AppName}! {release.Name}";
OkBtn.Visibility = Visibility.Visible;
//Close();
UpdateMessage.Text = $"You already have the latest {Globals.AppName}! {release.Name}";
OkBtn.Visibility = Visibility.Visible;
if (!_showProgress)
{
Close();
}
}

//get latest version
Expand All @@ -70,7 +79,7 @@ private async void CheckForUpdates()
OkBtn.Visibility = Visibility.Visible;
}

if (ProcessIsRunning("dynamo") || ProcessIsRunning("rhino") || ProcessIsRunning("revit") || _showProgress)
if (IsProcessRunning("dynamo") || IsProcessRunning("rhino") || IsProcessRunning("revit") || _showProgress)
{
Show();
YesBtn.Visibility = Visibility.Visible;
Expand All @@ -81,6 +90,7 @@ private async void CheckForUpdates()
{
//silent install
Process.Start(_path, "/SP- /VERYSILENT /SUPPRESSMSGBOXES");
Close();
}
}
}
Expand All @@ -98,7 +108,7 @@ private bool UpdateAvailable(Release release)
return true;
}

private bool ProcessIsRunning(string name)
private bool IsProcessRunning(string name)
{
var processes = Process.GetProcesses();
foreach (var p in processes)
Expand Down

0 comments on commit 479dbc4

Please sign in to comment.