Skip to content

Commit 0fd95df

Browse files
committed
download of new version
1 parent 4cb3fea commit 0fd95df

File tree

9 files changed

+202
-30
lines changed

9 files changed

+202
-30
lines changed

GUI/doTimeTable/Form1.cs

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,19 @@ private async void AutoUpdateThread()
563563

564564
public void EnableInstallMenuItem()
565565
{
566-
this.installNewVersionToolStripMenuItem.Visible = true;
567-
this.installNewVersionToolStripMenuItem.Enabled = true;
568-
if (CheckDownloadedNewVersion())
566+
if (!this.installNewVersionToolStripMenuItem.Visible) {
567+
this.installNewVersionToolStripMenuItem.Visible = true;
568+
}
569+
if (!this.installNewVersionToolStripMenuItem.Enabled)
569570
{
570-
string log_output = "found verified installer";
571-
logWindow.Write_to_log_fromThread(log_output);
572-
this.installNewVersionToolStripMenuItem.Text = LocRM.GetString("String180");
573-
newVersionDownloaded = true;
571+
this.installNewVersionToolStripMenuItem.Enabled = true;
572+
if (CheckDownloadedNewVersion())
573+
{
574+
string log_output = "found verified installer";
575+
logWindow.Write_to_log_fromThread(log_output);
576+
this.installNewVersionToolStripMenuItem.Text = LocRM.GetString("String180");
577+
newVersionDownloaded = true;
578+
}
574579
}
575580
}
576581

@@ -2413,6 +2418,18 @@ private bool CheckDownloadedNewVersion()
24132418
return r;
24142419
}
24152420

2421+
private void SetDownloadProgress( int value )
2422+
{
2423+
Object[] values = { value };
2424+
Progress.currentProgress.SetProgress2_fromThread(values);
2425+
}
2426+
2427+
private void SetDownloadText(string text)
2428+
{
2429+
Object[] values = { text };
2430+
doTimeTable.Progress.currentProgress.ShowText_fromThread(values);
2431+
}
2432+
24162433
private async void DownloadNewVersion()
24172434
{
24182435
string log_output;
@@ -2423,6 +2440,9 @@ private async void DownloadNewVersion()
24232440
{
24242441
if (httpClient != null)
24252442
{
2443+
Progress.currentProgress.Show();
2444+
Progress.currentProgress.ActivateMe(Progress.Type.DOWNLOAD);
2445+
24262446
string localNewVersion = "";
24272447
#if DEBUG
24282448
Version lv = new Version(version);
@@ -2441,9 +2461,9 @@ private async void DownloadNewVersion()
24412461
newVersion = crypto.newVersion;
24422462
}
24432463

2444-
string installerName = "doTimeTableSetup.msi";
2464+
//string installerName = "doTimeTableSetup.msi";
24452465
string newInstallerName = "doTimeTableSetup-" + newVersion + ".msi";
2446-
string downloadURL = "https://raw.githubusercontent.com/oheil/doTimeTable/v" + newVersion + "/src/" + installerName;
2466+
string downloadURL = "https://github.com/oheil/doTimeTable/releases/download/v" + newVersion + "/" + newInstallerName;
24472467
if (System.IO.File.Exists(downloadPath + Path.DirectorySeparatorChar + newInstallerName))
24482468
{
24492469
try
@@ -2482,14 +2502,26 @@ private async void DownloadNewVersion()
24822502
CheckDownloadedNewVersion();
24832503
}
24842504
#endif
2505+
SetDownloadProgress(10);
2506+
SetDownloadText(LocRM.GetString("String186") + " " + newInstallerName);
2507+
log_output = "Downloading " + newInstallerName;
2508+
Form1.logWindow.Write_to_log(ref log_output);
24852509
if (!System.IO.File.Exists(downloadPath + Path.DirectorySeparatorChar + newInstallerName))
24862510
{
24872511
try
24882512
{
24892513
HttpResponseMessage response = await httpClient.GetAsync(new Uri(downloadURL));
2490-
using (var fs = new FileStream(downloadPath + Path.DirectorySeparatorChar + newInstallerName, FileMode.Create))
2514+
if (response.IsSuccessStatusCode)
2515+
{
2516+
using (var fs = new FileStream(downloadPath + Path.DirectorySeparatorChar + newInstallerName, FileMode.Create))
2517+
{
2518+
await response.Content.CopyToAsync(fs);
2519+
}
2520+
}
2521+
else
24912522
{
2492-
await response.Content.CopyToAsync(fs);
2523+
log_output = "Download " + newInstallerName + " failed";
2524+
Form1.logWindow.Write_to_log(ref log_output);
24932525
}
24942526
}
24952527
catch (Exception ex)
@@ -2498,14 +2530,26 @@ private async void DownloadNewVersion()
24982530
Form1.logWindow.Write_to_log(ref log_output);
24992531
}
25002532
}
2533+
SetDownloadProgress(70);
2534+
SetDownloadText(LocRM.GetString("String186") + " " + newInstallerName + ".sha256");
2535+
log_output = "Downloading " + newInstallerName + ".sha256";
2536+
Form1.logWindow.Write_to_log(ref log_output);
25012537
if (!System.IO.File.Exists(downloadPath + Path.DirectorySeparatorChar + newInstallerName + ".sha256"))
25022538
{
25032539
try
25042540
{
25052541
HttpResponseMessage response = await httpClient.GetAsync(new Uri(downloadURL + ".sha256"));
2506-
using (var fs = new FileStream(downloadPath + Path.DirectorySeparatorChar + newInstallerName + ".sha256", FileMode.Create))
2542+
if (response.IsSuccessStatusCode)
25072543
{
2508-
await response.Content.CopyToAsync(fs);
2544+
using (var fs = new FileStream(downloadPath + Path.DirectorySeparatorChar + newInstallerName + ".sha256", FileMode.Create))
2545+
{
2546+
await response.Content.CopyToAsync(fs);
2547+
}
2548+
}
2549+
else
2550+
{
2551+
log_output = "Download " + newInstallerName + ".sha256" + " failed";
2552+
Form1.logWindow.Write_to_log(ref log_output);
25092553
}
25102554
}
25112555
catch (Exception ex)
@@ -2514,6 +2558,10 @@ private async void DownloadNewVersion()
25142558
Form1.logWindow.Write_to_log(ref log_output);
25152559
}
25162560
}
2561+
SetDownloadProgress(80);
2562+
SetDownloadText(LocRM.GetString("String189"));
2563+
log_output = "Verifying " + newInstallerName;
2564+
Form1.logWindow.Write_to_log(ref log_output);
25172565
if (CheckDownloadedNewVersion() && System.IO.File.Exists(downloadPath + Path.DirectorySeparatorChar + newInstallerName))
25182566
{
25192567
log_output = "downloaded and verified installer: " + downloadPath + Path.DirectorySeparatorChar + newInstallerName;
@@ -2526,12 +2574,15 @@ private async void DownloadNewVersion()
25262574
log_output = "error: installer could not be downloaded or verified";
25272575
Form1.logWindow.Write_to_log(ref log_output);
25282576
}
2577+
SetDownloadProgress(100);
25292578
}
25302579
else
25312580
{
25322581
log_output = "error: new version unknown";
25332582
Form1.logWindow.Write_to_log(ref log_output);
25342583
}
2584+
2585+
Progress.currentProgress.Julia_ready_fromThread();
25352586
}
25362587
}
25372588
else

GUI/doTimeTable/Julia.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static void ThreadServerPipe()
182182
{
183183
outString = streamline.Replace("###USERMSG###", "");
184184
Object[] values = { outString };
185-
doTimeTable.Progress.currentProgress.ShowText_fromThread(values);
185+
doTimeTable.Progress.currentProgress.ShowWarningText_fromThread(values);
186186
}
187187
else
188188
{

GUI/doTimeTable/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ You should have received a copy of the GNU General Public License
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// übernehmen, indem Sie "*" eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("0.2.0.*")]
55+
[assembly: AssemblyVersion("0.2.1.*")]

GUI/doTimeTable/WinFormStrings.Designer.cs

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GUI/doTimeTable/WinFormStrings.de-DE.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,18 @@ Wählen Sie Abbrechen um die Applikation zu beenden.</value>
417417
<data name="String185" xml:space="preserve">
418418
<value>Soll das Log in das Clipboard kopiert werden?</value>
419419
</data>
420+
<data name="String186" xml:space="preserve">
421+
<value>Download</value>
422+
</data>
423+
<data name="String187" xml:space="preserve">
424+
<value>Download läuft</value>
425+
</data>
426+
<data name="String188" xml:space="preserve">
427+
<value>Laufender Download in %:</value>
428+
</data>
429+
<data name="String189" xml:space="preserve">
430+
<value>Downloads verfizieren</value>
431+
</data>
420432
<data name="String19" xml:space="preserve">
421433
<value>Selektieren Sie ein einzelnes Projekt</value>
422434
</data>

GUI/doTimeTable/WinFormStrings.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,18 @@ Choose Cancel to exit the application now.</value>
417417
<data name="String185" xml:space="preserve">
418418
<value>Copy log to clipboard?</value>
419419
</data>
420+
<data name="String186" xml:space="preserve">
421+
<value>Download</value>
422+
</data>
423+
<data name="String187" xml:space="preserve">
424+
<value>Download running</value>
425+
</data>
426+
<data name="String188" xml:space="preserve">
427+
<value>Current download in %:</value>
428+
</data>
429+
<data name="String189" xml:space="preserve">
430+
<value>Verifying downloads</value>
431+
</data>
420432
<data name="String19" xml:space="preserve">
421433
<value>Select a single project</value>
422434
</data>

GUI/doTimeTable/crypto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Version(Version version)
6868

6969
override public string ToString()
7070
{
71-
return versionArray[0].ToString() + "." + versionArray[1].ToString();
71+
return versionArray[0].ToString() + "." + versionArray[1].ToString() + "." + versionArray[2].ToString();
7272
}
7373

7474
public int MajorDiff(Version a, Version b)
@@ -127,7 +127,7 @@ public void GetNewVersion()
127127
if( registrationVersion != null)
128128
{
129129
bool newFound = false;
130-
Version baseVersion = new Version(registrationVersion);
130+
Version baseVersion = new Version(Form1.version);
131131
Version newVersion = new Version();
132132
foreach (string release in Form1.myself.versionsList)
133133
{

0 commit comments

Comments
 (0)