Beispiel #1
0
        public async Task <ActionResult <string> > Export(int id, [FromBody] SiteStructureViewModel data)
        {
            var result = await Helper.ExportTheme(id, data
                                                  , _lang, HttpContext.Request.Scheme, HttpContext.Request.Host.Value);

            return(GetResponse(result));
        }
Beispiel #2
0
        public async Task <ActionResult <SiteStructureViewModel> > Export(int id)
        {
            var siteStructures = new SiteStructureViewModel();
            await siteStructures.InitAsync(_lang);

            return(Ok(siteStructures));
        }
        public SiteStructure(ref string newlink)
        {
            viewModel   = new SiteStructureViewModel(newlink);
            DataContext = viewModel;
            InitializeComponent();

            viewModel.Closing += (s, e) => this.Close();
        }
        public async Task <RepositoryResponse <string> > Export(int id, [FromBody] SiteStructureViewModel data)
        {
            var getTheme = await ReadViewModel.Repository.GetSingleModelAsync(
                theme => theme.Id == id).ConfigureAwait(false);

            //path to temporary folder
            string tempPath   = $"wwwroot/Exports/Themes/{getTheme.Data.Name}/temp";
            string outputPath = $"Exports/Themes/{getTheme.Data.Name}";

            data.ThemeName      = getTheme.Data.Name;
            data.Specificulture = _lang;
            var result = data.ProcessSelectedExportDataAsync();

            if (result.IsSucceed)
            {
                string filename = $"schema";
                var    file     = new FileViewModel()
                {
                    Filename   = filename,
                    Extension  = ".json",
                    FileFolder = $"{tempPath}/Data",
                    Content    = JObject.FromObject(data).ToString()
                };

                // Delete Existing folder
                FileRepository.Instance.DeleteFolder(outputPath);
                // Copy current templates file
                FileRepository.Instance.CopyDirectory($"{getTheme.Data.TemplateFolder}", $"{tempPath}/Templates");
                // Copy current assets files
                FileRepository.Instance.CopyDirectory($"wwwroot/{getTheme.Data.AssetFolder}", $"{tempPath}/Assets");
                // Copy current uploads files
                FileRepository.Instance.CopyDirectory($"wwwroot/{getTheme.Data.UploadsFolder}", $"{tempPath}/Uploads");
                // Save Site Structures
                FileRepository.Instance.SaveFile(file);

                // Zip to [theme_name].zip ( wwwroot for web path)
                string filePath = FileRepository.Instance.ZipFolder($"{tempPath}", outputPath, $"{getTheme.Data.Name}-{Guid.NewGuid()}");



                // Delete temp folder
                FileRepository.Instance.DeleteWebFolder($"{outputPath}/Assets");
                FileRepository.Instance.DeleteWebFolder($"{outputPath}/Uploads");
                FileRepository.Instance.DeleteWebFolder($"{outputPath}/Templates");
                FileRepository.Instance.DeleteWebFolder($"{outputPath}/Data");

                return(new RepositoryResponse <string>()
                {
                    IsSucceed = !string.IsNullOrEmpty(outputPath),
                    Data = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/{filePath}"
                });
            }
            else
            {
                return(result);
            }
        }
Beispiel #5
0
        public async Task <RepositoryResponse <SiteStructureViewModel> > Export(int id)
        {
            var siteStructures = new SiteStructureViewModel();
            await siteStructures.InitAsync(_lang);

            return(new RepositoryResponse <SiteStructureViewModel>()
            {
                IsSucceed = true,
                Data = siteStructures
            });
        }
Beispiel #6
0
        public async Task <RepositoryResponse <string> > Export(int id, [FromBody] SiteStructureViewModel data)
        {
            var getTemplate = await ReadViewModel.Repository.GetSingleModelAsync(
                theme => theme.Id == id).ConfigureAwait(false);

            string exportPath = $"Exports/Themes/{getTemplate.Data.Name}";

            string filename = $"schema";
            var    file     = new FileViewModel()
            {
                Filename   = filename,
                Extension  = ".json",
                FileFolder = $"{exportPath}/Data",
                Content    = JObject.FromObject(data).ToString()
            };

            // Delete Existing folder
            FileRepository.Instance.DeleteFolder(exportPath);
            // Copy current templates file
            FileRepository.Instance.CopyDirectory($"{getTemplate.Data.TemplateFolder}", $"{exportPath}/Templates");
            // Copy current assets files
            FileRepository.Instance.CopyDirectory($"wwwroot/{getTemplate.Data.AssetFolder}", $"{exportPath}/Assets");
            // Copy current uploads files
            FileRepository.Instance.CopyDirectory($"wwwroot/{getTemplate.Data.UploadFolder}", $"{exportPath}/Uploads");
            // Save Site Structures
            FileRepository.Instance.SaveFile(file);

            // Zip to [theme_name].zip
            string filePath = FileRepository.Instance.ZipFolder($"{exportPath}", getTemplate.Data.Name);



            // Delete temp folder
            FileRepository.Instance.DeleteWebFolder($"{exportPath}/Assets");
            FileRepository.Instance.DeleteWebFolder($"{exportPath}/Uploads");
            FileRepository.Instance.DeleteWebFolder($"{exportPath}/Templates");
            FileRepository.Instance.DeleteWebFolder($"{exportPath}/Data");

            return(new RepositoryResponse <string>()
            {
                IsSucceed = !string.IsNullOrEmpty(exportPath),
                Data = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/{filePath}"
            });
        }
Beispiel #7
0
        public static async Task <RepositoryResponse <string> > ExportTheme(
            int id, SiteStructureViewModel data,
            string culture, string scheme, string host)
        {
            var getTheme = await ReadViewModel.Repository.GetSingleModelAsync(
                theme => theme.Id == id).ConfigureAwait(false);

            //path to temporary folder
            string tempPath   = $"{MixFolders.WebRootPath}/{MixFolders.ExportFolder}/Themes/{getTheme.Data.Name}/temp";
            string outputPath = $"{MixFolders.ExportFolder}/Themes/{getTheme.Data.Name}";

            data.ThemeName      = getTheme.Data.Name;
            data.Specificulture = culture;
            var result = data.ExportSelectedItemsAsync();

            if (result.IsSucceed)
            {
                string domain       = MixService.GetConfig <string>(MixAppSettingKeywords.Domain);
                string accessFolder = $"{MixFolders.SiteContentAssetsFolder}/{getTheme.Data.Name}/assets";
                string content      = JObject.FromObject(data).ToString()
                                      .Replace(accessFolder, "[ACCESS_FOLDER]")
                                      .Replace($"/{culture}/", "/[CULTURE]/")
                                      .Replace($"/{data.ThemeName}/", "/[THEME_NAME]/");
                if (!string.IsNullOrEmpty(domain))
                {
                    content = content.Replace(domain, string.Empty);
                }
                string filename = $"schema";
                var    file     = new FileViewModel()
                {
                    Filename   = filename,
                    Extension  = MixFileExtensions.Json,
                    FileFolder = $"{tempPath}/Data",
                    Content    = content
                };

                // Delete Existing folder
                MixFileRepository.Instance.DeleteWebFolder(outputPath);
                // Copy current templates file
                MixFileRepository.Instance.CopyDirectory($"{getTheme.Data.TemplateFolder}", $"{tempPath}/Templates");
                // Copy current assets files
                MixFileRepository.Instance.CopyDirectory($"{MixFolders.WebRootPath}/{getTheme.Data.AssetFolder}", $"{tempPath}/Assets");
                // Copy current uploads files
                MixFileRepository.Instance.CopyDirectory($"{MixFolders.WebRootPath}/{getTheme.Data.UploadsFolder}", $"{tempPath}/Uploads");
                // Save Site Structures
                MixFileRepository.Instance.SaveFile(file);

                // Zip to [theme_name].zip ( wwwroot for web path)
                string filePath = MixFileRepository.Instance.ZipFolder($"{tempPath}", outputPath, $"{getTheme.Data.Name}-{Guid.NewGuid()}");

                // Delete temp folder
                MixFileRepository.Instance.DeleteWebFolder($"{outputPath}/Assets");
                MixFileRepository.Instance.DeleteWebFolder($"{outputPath}/Uploads");
                MixFileRepository.Instance.DeleteWebFolder($"{outputPath}/Templates");
                MixFileRepository.Instance.DeleteWebFolder($"{outputPath}/Data");

                return(new RepositoryResponse <string>()
                {
                    IsSucceed = !string.IsNullOrEmpty(outputPath),
                    Data = $"{scheme}://{host}/{filePath}"
                });
            }
            else
            {
                return(result);
            }
        }
 public Task <RepositoryResponse <string> > Export(int id, [FromBody] SiteStructureViewModel data)
 {
     return(Lib.ViewModels.MixThemes.Helper.ExportTheme(id, data
                                                        , _lang, HttpContext.Request.Scheme, HttpContext.Request.Host.Value));
 }