mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
fixed export file path.
This commit is contained in:
parent
f34f3da587
commit
b93b7f321e
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Npgsql;
|
||||
using System.Data.Common;
|
||||
using System.IO.Compression;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CarCareTracker.Controllers
|
||||
@ -67,7 +68,10 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
return Json(new OperationResponse { Success = false, Message = "Postgres connection not set up" });
|
||||
}
|
||||
var tempPath = $"temp/{Guid.NewGuid}.db";
|
||||
var tempFolder = $"temp/{Guid.NewGuid()}";
|
||||
var tempPath = $"{tempFolder}/cartracker.db";
|
||||
var fullFolderPath = _fileHelper.GetFullFilePath(tempFolder, false);
|
||||
Directory.CreateDirectory(fullFolderPath);
|
||||
var fullFileName = _fileHelper.GetFullFilePath(tempPath, false);
|
||||
try
|
||||
{
|
||||
@ -393,10 +397,13 @@ namespace CarCareTracker.Controllers
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
return Json(new OperationResponse { Success = true, Message = $"/{tempPath}" });
|
||||
var destFilePath = $"{fullFolderPath}.zip";
|
||||
ZipFile.CreateFromDirectory(fullFolderPath, destFilePath);
|
||||
return Json(new OperationResponse { Success = true, Message = $"/{tempFolder}.zip" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
return Json(new OperationResponse { Success = false, Message = StaticHelper.GenericErrorMessage });
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,9 @@
|
||||
</div>
|
||||
<script>
|
||||
function exportFromPostgres(){
|
||||
sloader.show();
|
||||
$.get('/Migration/Export', function (data) {
|
||||
sloader.hide();
|
||||
if (data.success) {
|
||||
window.location.href = data.message;
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user