Things for the changelog.

This commit is contained in:
Holger Börchers 2018-03-23 16:25:36 +01:00
parent 54979f9a69
commit 18195be91d
3 changed files with 23 additions and 14 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Katteker.Gui.Properties;
@ -95,8 +96,9 @@ namespace Katteker.Gui
private async void UpdateWindow_Load(object sender, EventArgs e)
{
var changelog = await ChangelogHelper.LoadChangelogAsync(Changelog, PublishPath).ConfigureAwait(false);
Invoke(new Action(() => changelogBrowser.DocumentText = changelog));
var changelogContent = await ChangelogHelper.LoadChangelogAsync(Changelog, PublishPath).ConfigureAwait(false);
changelogContent = changelogContent.ChangelogAsHtml(Path.GetExtension(Changelog));
Invoke(new Action(() => changelogBrowser.DocumentText = changelogContent));
if (_entry == null)
{
Invoke(new Action(() => { WriteTitle(Resources.No_update_available); }));

View File

@ -7,7 +7,7 @@ namespace Katteker
{
public static class ChangelogHelper
{
private static string GenerateChangelogAsHtml(string text, string extension)
public static string ChangelogAsHtml(this string text, string extension)
{
string result;
switch (extension)
@ -39,23 +39,30 @@ namespace Katteker
using (var response = await webReq.GetResponseAsync().ConfigureAwait(false))
using (var sr = new StreamReader(response.GetResponseStream()))
{
return GenerateChangelogAsHtml(await sr.ReadToEndAsync().ConfigureAwait(false),
Path.GetExtension(filename));
return await sr.ReadToEndAsync().ConfigureAwait(false);
}
}
catch (WebException)
catch (Exception)
{
var changelogFilename = Path.GetFileName(filename);
if (changelogFilename == null) return GenerateChangelogAsHtml("Changelog not found", ".txt");
var currentChangelogPath = Path.Combine(Environment.CurrentDirectory, changelogFilename);
if (File.Exists(currentChangelogPath))
try
{
return GenerateChangelogAsHtml(File.ReadAllText(currentChangelogPath), Path.GetExtension(filename));
var changelogFilename = Path.GetFileName(filename);
if (changelogFilename == null) return null;
var currentChangelogPath = Path.Combine(Environment.CurrentDirectory, changelogFilename);
if (File.Exists(currentChangelogPath))
{
return File.ReadAllText(currentChangelogPath);
}
}
catch (Exception)
{
// ignore;
}
}
}
return GenerateChangelogAsHtml("Changelog not found", ".txt");
return null;
}
}
}

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.0.3")]
[assembly: AssemblyFileVersion("1.0.3")]