public ActionResult LicenseResetStatusCheck(string systemName) { // Reset state for current store. var result = LicenseChecker.ResetState(systemName); LicenseCheckerResult subShopResult = null; var model = new LicenseLabelModel { IsLicensable = true, LicenseUrl = Url.Action("LicensePlugin", new { systemName = systemName }), LicenseState = result.State, TruncatedLicenseKey = result.TruncatedLicenseKey, RemainingDemoUsageDays = result.RemainingDemoDays }; // Reset state for all other stores. if (result.Success) { var currentStoreId = Services.StoreContext.CurrentStore.Id; var allStores = Services.StoreService.GetAllStores(); foreach (var store in allStores.Where(x => x.Id != currentStoreId && x.Url.HasValue())) { subShopResult = LicenseChecker.ResetState(systemName, store.Url); if (!subShopResult.Success) { result = subShopResult; break; } } } // Notify about result. if (result.Success) { NotifySuccess(T("Admin.Common.TaskSuccessfullyProcessed")); } else { var message = HtmlUtils.ConvertPlainTextToHtml(result.ToString()); if (result.IsFailureWarning) { NotifyWarning(message); } else { NotifyError(message); } } return(PartialView("Partials/LicenseLabel", model)); }
private LicensingData PrepareLicenseLabelModel(LicenseLabelModel model, PluginDescriptor pluginDescriptor, string url = null) { if (IsLicensable(pluginDescriptor)) { // We always show license button to serve ability to delete a key. model.IsLicensable = true; model.LicenseUrl = Url.Action("LicensePlugin", new { systemName = pluginDescriptor.SystemName }); var cachedLicense = LicenseChecker.GetLicense(pluginDescriptor.SystemName, url); if (cachedLicense == null) { // Licensed plugin has not been used yet -> Check state. model.LicenseState = LicenseChecker.CheckState(pluginDescriptor.SystemName, url); // And try to get license data again. cachedLicense = LicenseChecker.GetLicense(pluginDescriptor.SystemName, url); } if (cachedLicense != null) { // Licensed plugin has been used. model.LicenseState = cachedLicense.State; model.TruncatedLicenseKey = cachedLicense.TruncatedLicenseKey; model.RemainingDemoUsageDays = cachedLicense.RemainingDemoDays; } else { // It's confusing to display a license state when there is no license data yet. model.HideLabel = true; } return(cachedLicense); } return(null); }