Skip to content
Permalink
Browse files

- Improved toolkit version validation

  • Loading branch information
cozy1 committed Feb 2, 2020
1 parent 4dfa389 commit 5c76cd1f586caddd3b0ad8607615c51bbb6ca725
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("f9511285")]
[assembly: AssemblyConfiguration("2020-01-20T21:07:37")]
[assembly: AssemblyInformationalVersion("4dfa389c")]
[assembly: AssemblyConfiguration("2020-02-02T18:04:33")]
@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("f9511285")]
[assembly: AssemblyConfiguration("2020-01-20T21:07:37")]
[assembly: AssemblyInformationalVersion("4dfa389c")]
[assembly: AssemblyConfiguration("2020-02-02T18:04:33")]
@@ -6,6 +6,7 @@
using RocksmithToolkitLib.Extensions;
using System.Diagnostics;
using System.Globalization;
using System.Drawing;


namespace RocksmithToolkitLib
@@ -79,10 +80,9 @@ public static string RSTKUpdaterVersion()

return String.Format("{0}-{1}", assemblyVersion, assemblyInformationVersion).Trim();
}

public static bool IsRSTKLibValid()
public static bool IsRSTKLibValid(double shelfLifeDays = 180)
{
// return false;
var assembly = Assembly.LoadFile(typeof(RocksmithToolkitLib.ToolkitVersion).Assembly.Location);
var assemblyConfiguration = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false).Cast<AssemblyConfigurationAttribute>().FirstOrDefault().Configuration.ToString() ?? "";

@@ -94,8 +94,9 @@ public static bool IsRSTKLibValid()
// working with UTC to avoid regional DateTime issues
DateTime dtuAssemblyConfig = DateTime.Parse(assemblyConfiguration, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
var dtuNow = DateTime.UtcNow;
var dtuRemaining = dtuAssemblyConfig.AddDays(shelfLifeDays) - dtuNow;

if (dtuNow > dtuAssemblyConfig.AddDays(180))
if (dtuRemaining.Days < 0)
return false;

return true;
@@ -108,8 +109,14 @@ public static class Startup
public static void Start()
{
if (!ToolkitVersion.IsRSTKLibValid())
throw new ApplicationException("This version of RocksmithToolkitLib.dll has expired. " + Environment.NewLine +
"Please download and install the latest toolkit library. " + Environment.NewLine);
{
// throw new ApplicationException("This version of RocksmithToolkitLib.dll has expired. " + Environment.NewLine +
// "Please download and install the latest toolkit library. " + Environment.NewLine);

var diaMsg = "This version of RocksmithToolkitLib.dll is no longer supported." + Environment.NewLine +
"Please download and install the latest version of the toolkit.";
BetterDialog2.ShowDialog(diaMsg, "Time To Update ...", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Warning.Handle), "WARNING ...", 0, 150);
}
}
}

@@ -29,5 +29,5 @@
//
// THESE VALUES ARE PROGRAMMATICALLY GENERATED - DO NOT EDIT
[assembly: AssemblyVersion("2.9.2.1")]
[assembly: AssemblyInformationalVersion("f9511285")]
[assembly: AssemblyConfiguration("2020-01-20T21:07:37")]
[assembly: AssemblyInformationalVersion("4dfa389c")]
[assembly: AssemblyConfiguration("2020-02-02T18:04:33")]
@@ -1,3 +1,3 @@
2.9.2.1
f9511285
2020-01-20T21:07:37
4dfa389c
2020-02-02T18:04:33

0 comments on commit 5c76cd1

Please sign in to comment.
You can’t perform that action at this time.