Beispiel #1
0
        public async Task <ActionResult> DownloadLog(long cookieToReturn)
        {
            using (LogDataProvider logDP = new LogDataProvider()) {
                string filename = logDP.GetLogFileName();
                if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
                {
                    throw new Error(this.__ResStr("logNotFound", "The scheduler log 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 = "Logfile.txt"
                });
#else
                FilePathResult result = new FilePathResult(filename, contentType);
                result.FileDownloadName = "SchedulerLog.txt";
                return(result);
#endif
            }
        }
Beispiel #2
0
        public async Task <ActionResult> DownloadZippedLog(long cookieToReturn)
        {
            using (LogDataProvider dataProvider = new LogDataProvider()) {
                string filename = dataProvider.GetLogFileName();
                if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
                {
                    throw new Error(this.__ResStr("logNotFound", "The scheduler log file '{0}' cannot be located", filename));
                }
#if MVC6
#else
                HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString());
                Response.Cookies.Remove(Basics.CookieDone);
                Response.SetCookie(cookie);
#endif
                string        zipName = "Logfile.zip";
                YetaWFZipFile zipFile = new YetaWFZipFile {
                    FileName = zipName,
                };
                zipFile.AddFile(filename, "SchedulerLog.txt");
                return(new ZippedFileResult(zipFile, cookieToReturn));
            }
        }