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 Microsoft.AspNetCore.Mvc;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarCareTracker.Controllers
|
namespace CarCareTracker.Controllers
|
||||||
@ -67,7 +68,10 @@ namespace CarCareTracker.Controllers
|
|||||||
{
|
{
|
||||||
return Json(new OperationResponse { Success = false, Message = "Postgres connection not set up" });
|
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);
|
var fullFileName = _fileHelper.GetFullFilePath(tempPath, false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -393,10 +397,13 @@ namespace CarCareTracker.Controllers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endregion
|
#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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_logger.LogError(ex.Message);
|
||||||
return Json(new OperationResponse { Success = false, Message = StaticHelper.GenericErrorMessage });
|
return Json(new OperationResponse { Success = false, Message = StaticHelper.GenericErrorMessage });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function exportFromPostgres(){
|
function exportFromPostgres(){
|
||||||
|
sloader.show();
|
||||||
$.get('/Migration/Export', function (data) {
|
$.get('/Migration/Export', function (data) {
|
||||||
|
sloader.hide();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
window.location.href = data.message;
|
window.location.href = data.message;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user