2021-02-17 18:41:30 +01:00
|
|
|
|
using System.Collections;
|
2018-05-22 10:11:50 +02:00
|
|
|
|
using Core.Main;
|
|
|
|
|
using Core.Helper;
|
|
|
|
|
|
|
|
|
|
namespace Monitor.Pages {
|
|
|
|
|
public class DownloadFileModel : _Internal.BasePageModelSecure {
|
|
|
|
|
|
|
|
|
|
public void OnGet() {
|
|
|
|
|
// Initialize Config
|
|
|
|
|
base.Init();
|
|
|
|
|
|
2021-02-17 18:41:30 +01:00
|
|
|
|
// Check we have a log in
|
|
|
|
|
if (base.IsLoggedIn(this.HttpContext))
|
|
|
|
|
{
|
|
|
|
|
InitializeDownload();
|
|
|
|
|
}
|
2018-05-22 10:11:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeDownload() {
|
|
|
|
|
string fileName = GetStringParameter("f", "");
|
|
|
|
|
if (System.IO.File.Exists(PTMagicBasePath + fileName)) {
|
|
|
|
|
if (!System.IO.Directory.Exists(PTMagicMonitorBasePath + "wwwroot" + System.IO.Path.DirectorySeparatorChar + "assets" + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar)) {
|
|
|
|
|
System.IO.Directory.CreateDirectory(PTMagicMonitorBasePath + "wwwroot" + System.IO.Path.DirectorySeparatorChar + "assets" + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string sourcefilePath = PTMagicBasePath + fileName;
|
|
|
|
|
string destinationFilePath = PTMagicMonitorBasePath + "wwwroot" + System.IO.Path.DirectorySeparatorChar + "assets" + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar + fileName + ".zip";
|
|
|
|
|
|
|
|
|
|
ZIPHelper.CreateZipFile(new ArrayList() { sourcefilePath }, destinationFilePath);
|
|
|
|
|
|
|
|
|
|
Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "assets/tmp/" + fileName + ".zip");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|