Exemple #1
0
        public ActionResult ImportVariables(string theme, int storeId, FormCollection form)
        {
            if (!_themeRegistry.ThemeManifestExists(theme))
            {
                return(RedirectToAction("List", new { storeId }));
            }

            try
            {
                var file = Request.Files["importxmlfile"];
                if (file != null && file.ContentLength > 0)
                {
                    int importedCount = 0;
                    importedCount = _themeVarService.ImportVariables(theme, storeId, file.InputStream.AsString());

                    try
                    {
                        Services.CustomerActivity.InsertActivity("ImportThemeVars", T("ActivityLog.ResetThemeVars"), importedCount, theme);
                    }
                    catch { }

                    NotifySuccess(T("Admin.Configuration.Themes.Notifications.ImportSuccess", importedCount));
                }
                else
                {
                    NotifyError(T("Admin.Configuration.Themes.Notifications.UploadFile"));
                }
            }
            catch (Exception ex)
            {
                NotifyError(ex);
            }

            return(RedirectToAction("Configure", new { theme, storeId }));
        }
Exemple #2
0
        public ActionResult ImportVariables(string theme, int storeId, FormCollection form)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageThemes))
            {
                return(AccessDeniedView());
            }

            if (!_themeRegistry.ThemeManifestExists(theme))
            {
                return(RedirectToAction("List", new { storeId = storeId }));
            }

            try
            {
                var file = Request.Files["importxmlfile"];
                if (file != null && file.ContentLength > 0)
                {
                    int importedCount = 0;
                    using (var sr = new StreamReader(file.InputStream, Encoding.UTF8))
                    {
                        string content = sr.ReadToEnd();
                        importedCount = _themeVarService.ImportVariables(theme, storeId, content);
                    }

                    // activity log
                    try
                    {
                        _services.CustomerActivity.InsertActivity("ImportThemeVars", T("ActivityLog.ResetThemeVars"), importedCount, theme);
                    }
                    catch { }

                    NotifySuccess(T("Admin.Configuration.Themes.Notifications.ImportSuccess", importedCount));
                }
                else
                {
                    NotifyError(T("Admin.Configuration.Themes.Notifications.UploadFile"));
                }
            }
            catch (Exception ex)
            {
                NotifyError(ex);
            }

            return(RedirectToAction("Configure", new { theme = theme, storeId = storeId }));
        }