2013-08-16 02:20:54 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-08-31 01:42:30 +00:00
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
2013-08-16 02:20:54 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Host
|
|
|
|
|
{
|
|
|
|
|
public static class PlatformValidation
|
|
|
|
|
{
|
2014-12-17 07:12:26 +00:00
|
|
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(PlatformValidation));
|
2013-08-16 02:20:54 +00:00
|
|
|
|
|
2014-08-29 06:28:07 +00:00
|
|
|
|
private const string DOWNLOAD_LINK = "http://www.microsoft.com/en-us/download/details.aspx?id=42643";
|
|
|
|
|
|
2013-08-16 02:20:54 +00:00
|
|
|
|
public static bool IsValidate(IUserAlert userAlert)
|
|
|
|
|
{
|
2014-12-07 20:54:07 +00:00
|
|
|
|
if (OsInfo.IsNotWindows)
|
2013-08-16 02:20:54 +00:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsAssemblyAvailable("System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))
|
|
|
|
|
{
|
2014-08-29 06:28:07 +00:00
|
|
|
|
userAlert.Alert("It looks like you don't have the correct version of .NET Framework installed. You will now be directed the download page.");
|
2013-08-16 02:20:54 +00:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-08-29 06:28:07 +00:00
|
|
|
|
Process.Start(DOWNLOAD_LINK);
|
2013-08-16 02:20:54 +00:00
|
|
|
|
}
|
2014-05-31 22:11:33 +00:00
|
|
|
|
catch (Exception)
|
2013-08-16 02:20:54 +00:00
|
|
|
|
{
|
2014-08-29 06:28:07 +00:00
|
|
|
|
userAlert.Alert("Oops. Couldn't start your browser. Please visit http://www.microsoft.com/net to download the latest version of .NET Framework");
|
2013-08-16 02:20:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static bool IsAssemblyAvailable(string assemblyString)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Assembly.Load(assemblyString);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.Warn("Couldn't load {0}", e.Message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|