Example #1
0
        public ActionResult LicenseResetStatusCheck(string systemName)
        {
            // Reset state for current store.
            var result = LicenseChecker.ResetState(systemName);

            var model = new PluginLicenseModel
            {
                IsLicensable           = true,
                LicenseUrl             = Url.Action("LicensePlugin", new { systemName = systemName }),
                LicenseState           = result.State,
                TruncatedLicenseKey    = result.TruncatedLicenseKey,
                RemainingDemoUsageDays = result.RemainingDemoDays
            };

            if (result.Success)
            {
                // Reset state for all other stores.
                var currentStoreId = Services.StoreContext.CurrentStore.Id;
                var allStores      = Services.StoreService.GetAllStores();

                foreach (var store in allStores.Where(x => x.Id != currentStoreId && x.Url.HasValue()))
                {
                    LicenseChecker.ResetState(systemName, store.Url);
                }

                NotifySuccess(T("Admin.Common.TaskSuccessfullyProcessed"));
            }
            else
            {
                NotifyError(result.ToString());
            }

            return(PartialView("Partials/LicenseLabel", model));
        }
        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));
        }