Exemple #1
0
        public async Task <ActionResult> DownloadSiteMap(long cookieToReturn)
        {
            SiteMaps sm       = new SiteMaps();
            string   filename = sm.GetSiteMapFileName();

            if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
            {
                throw new Error(this.__ResStr("sitemapNotFound", "Site map not found - File '{0}' cannot be located", filename));
            }
#if MVC6
            Response.Headers.Remove("Cookie");
            Response.Cookies.Append(Basics.CookieDone, cookieToReturn.ToString(), new Microsoft.AspNetCore.Http.CookieOptions {
                HttpOnly = false, Path = "/"
            });
#else
            HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString());
            Response.Cookies.Remove(Basics.CookieDone);
            Response.SetCookie(cookie);
#endif

            string contentType = "application/octet-stream";
#if MVC6
            return(new PhysicalFileResult(filename, contentType)
            {
                FileDownloadName = Path.GetFileName(filename)
            });
#else
            FilePathResult result = new FilePathResult(filename, contentType);
            result.FileDownloadName = Path.GetFileName(filename);
            return(result);
#endif
        }
        public async Task <ModuleAction> GetAction_DownloadSiteMapAsync()
        {
            if (!IsAuthorized("SiteMaps"))
            {
                return(null);
            }
            SiteMaps sm       = new SiteMaps();
            string   filename = sm.GetSiteMapFileName();

            if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
            {
                return(null);
            }
            return(new ModuleAction(this)
            {
                Url = Utility.UrlFor(typeof(PagesBrowseModuleController), nameof(PagesBrowseModuleController.DownloadSiteMap)),
                NeedsModuleContext = true,
                CookieAsDoneSignal = true,
                Image = await CustomIconAsync("Download.png"),
                LinkText = this.__ResStr("downloadLink", "Download Site Map"),
                MenuText = this.__ResStr("downloadMenu", "Download Site Map"),
                Tooltip = this.__ResStr("downloadTT", "Download the site map file"),
                Legend = this.__ResStr("downloadLegend", "Downloads the site map file"),
                Style = ModuleAction.ActionStyleEnum.Normal,
                Category = ModuleAction.ActionCategoryEnum.Read,
                Mode = ModuleAction.ActionModeEnum.Any,
                Location = ModuleAction.ActionLocationEnum.ModuleLinks,
            });
        }