Skip to content

Commit e5bb312

Browse files
committed
Installer
1 parent 4428e46 commit e5bb312

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

DataCommander.Providers/MainForm.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public MainForm()
157157

158158
_timer = new System.Windows.Forms.Timer(components)
159159
{
160-
Interval = 10000, // 10 seconds
160+
Interval = 5000, // 10 seconds
161161
};
162162
_timer.Tick += Timer_Tick;
163163
_timer.Start();
@@ -195,16 +195,26 @@ private void Timer_Tick(object sender, EventArgs e)
195195
{
196196
}
197197

198-
if (remoteVersion != null && localVersion != remoteVersion)
199-
{
200-
_toolStripStatusLabel.ForeColor = Color.Red;
201-
_toolStripStatusLabel.Text = $"New version is available. Local version: {localVersion}, remote version: {remoteVersion}";
202-
}
198+
//if (remoteVersion != null && localVersion != remoteVersion)
199+
_timer.Stop();
200+
this.Invoke(() => Download(remoteVersion));
203201
}
204202

205203
UpdateTotalMemory();
206204
}
207205

206+
private void Download(string remoteVersion)
207+
{
208+
var text = $"New version {remoteVersion} is avaliable. Do you want to install it?";
209+
210+
if (MessageBox.Show(text, "Data Commander", MessageBoxButtons.YesNo) == DialogResult.Yes)
211+
{
212+
var uri = new Uri("https://github.com/csbernath/DataCommander/releases/download/2018-04-13/DataCommander.7z");
213+
Installer.Download(uri, "Setup.exe");
214+
Close();
215+
}
216+
}
217+
208218
/// <summary>
209219
/// Clean up any resources being used.
210220
/// </summary>

Foundation.NetStandard-2.0/Setup/Installer.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.IO.Compression;
55
using System.Net;
6-
using System.Threading.Tasks;
76

87
namespace Foundation.Setup
98
{
@@ -15,19 +14,19 @@ public static string DownloadString(string address)
1514
return webClient.DownloadString(address);
1615
}
1716

18-
public static async Task Download(Uri address, string setupExeFileName)
17+
public static void Download(Uri address, string setupExeFileName)
1918
{
2019
var guid = Guid.NewGuid();
2120
var directory = Path.Combine(Path.GetTempPath(), $"Foundation.Setup.{guid}");
22-
var zipFilenName = $"{guid}.zip";
21+
Directory.CreateDirectory(directory);
22+
var zipFileName = Path.Combine(directory, $"{guid}.zip");
2323

2424
using (var webClient = new WebClient())
25-
await webClient.DownloadFileTaskAsync(address, zipFilenName);
25+
webClient.DownloadFile(address, zipFileName);
2626

27-
var sourceArchiveFileName = Path.Combine(directory, zipFilenName);
28-
ZipFile.ExtractToDirectory(sourceArchiveFileName, directory);
27+
ZipFile.ExtractToDirectory(zipFileName, directory);
2928

30-
File.Delete(sourceArchiveFileName);
29+
File.Delete(zipFileName);
3130

3231
var processStartInfo = new ProcessStartInfo();
3332
processStartInfo.WorkingDirectory = directory;

0 commit comments

Comments
 (0)