Skip to content

Commit

Permalink
extract static class LicenseProvider for License info supplying
Browse files Browse the repository at this point in the history
  • Loading branch information
trueboroda committed Dec 4, 2019
1 parent c0ad394 commit d8c3cd4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Modularity;
using VirtoCommerce.Platform.Web.Converters.Modularity;
using VirtoCommerce.Platform.Web.Licensing;
using VirtoCommerce.Platform.Web.Model.Diagnostics;

namespace VirtoCommerce.Platform.Web.Controllers.Api
Expand All @@ -24,7 +25,7 @@ public DiagnosticsController(IModuleCatalog moduleCatalog)
public IHttpActionResult GetSystemInfo()
{
var platformVersion = PlatformVersion.CurrentVersion.ToString();
var license = HomeController.LoadLicense(); //need to be refactored into platform v.3
var license = LicenseProvider.LoadLicense(); //need to be refactored into platform v.3

var installedModules = _moduleCatalog.Modules.OfType<ManifestModuleInfo>().Where(x => x.IsInstalled).OrderBy(x => x.Id)
.Select(x => x.ToWebModel())
Expand Down
21 changes: 1 addition & 20 deletions VirtoCommerce.Platform.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Reflection;
using System.Web.Hosting;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand All @@ -27,7 +26,7 @@ public ActionResult Index()
var version = PlatformVersion.CurrentVersion.ToString();
var demoCredentials = ConfigurationHelper.GetAppSettingsValue("VirtoCommerce:DemoCredentials");
var resetTimeStr = ConfigurationHelper.GetAppSettingsValue("VirtoCommerce:DemoResetTime");
var license = LoadLicense();
var license = LicenseProvider.LoadLicense();
var licenseString = JsonConvert.SerializeObject(license, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Expand Down Expand Up @@ -60,24 +59,6 @@ public ActionResult Index()
});
}

public static License LoadLicense()
{
License license = null;

var licenseFilePath = HostingEnvironment.MapPath(Startup.VirtualRoot + "/App_Data/VirtoCommerce.lic");
if (System.IO.File.Exists(licenseFilePath))
{
var rawLicense = System.IO.File.ReadAllText(licenseFilePath);
license = License.Parse(rawLicense);

if (license != null)
{
license.RawLicense = null;
}
}

return license;
}

private string GetFavIcon()
{
Expand Down
24 changes: 24 additions & 0 deletions VirtoCommerce.Platform.Web/Licensing/LicenseProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Web.Hosting;

namespace VirtoCommerce.Platform.Web.Licensing
{
public static class LicenseProvider
{
public static License LoadLicense()
{
License license = null;
var licenseFilePath = HostingEnvironment.MapPath(Startup.VirtualRoot + "/App_Data/VirtoCommerce.lic");
if (System.IO.File.Exists(licenseFilePath))
{
var rawLicense = System.IO.File.ReadAllText(licenseFilePath);
license = License.Parse(rawLicense);

if (license != null)
{
license.RawLicense = null;
}
}
return license;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"blades": {
"system-info": {
"title": "Platform Information"
"title": "Platform information"
},
"asset-list": {
"title": "Asset management",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@
<Compile Include="Controllers\Api\ProfilesController.cs" />
<Compile Include="Controllers\Api\AssetEntryController.cs" />
<Compile Include="Controllers\ExternalLoginController.cs" />
<Compile Include="Licensing\LicenseProvider.cs" />
<Compile Include="Model\Diagnostics\SystemInfo.cs" />
<Compile Include="Model\Security\ExternalLoginProviderInfo.cs" />
<Compile Include="Model\Security\ResetPasswordTokenInfo.cs" />
Expand Down

0 comments on commit d8c3cd4

Please sign in to comment.