This commit is contained in:
dev01 2023-10-26 18:13:34 +08:00
commit 8b70a69ecd
5 changed files with 117 additions and 0 deletions

View File

@ -20,6 +20,8 @@ namespace Backend.Controllers
private readonly IBackendRepository backendRepository; private readonly IBackendRepository backendRepository;
private string mapFileSaveAsPath = ""; private string mapFileSaveAsPath = "";
private string buildMapFileSaveAsPath = ""; private string buildMapFileSaveAsPath = "";
private string tempMapFileSaveAsPath = "";
private string tempBuildMapFileSaveAsPath = "";
public BuildInfoController(IBackendRepository backendRepository) public BuildInfoController(IBackendRepository backendRepository)
{ {
@ -27,6 +29,8 @@ namespace Backend.Controllers
mapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "floor_map"); mapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "floor_map");
buildMapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "build_map"); buildMapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "build_map");
tempMapFileSaveAsPath = Path.Combine("wwwroot", "upload", "build_map");
tempBuildMapFileSaveAsPath = Path.Combine("wwwroot", "upload", "build_map");
} }
public IActionResult Index() public IActionResult Index()
@ -175,6 +179,18 @@ namespace Backend.Controllers
{ {
post.Map3dFile.CopyTo(stream); post.Map3dFile.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempBuildMapFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Map3dFile.CopyTo(stream);
}
} }
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -289,6 +305,18 @@ namespace Backend.Controllers
{ {
post.Map3dFile.CopyTo(stream); post.Map3dFile.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempBuildMapFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Map3dFile.CopyTo(stream);
}
} }
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -550,6 +578,18 @@ namespace Backend.Controllers
{ {
post.MapFile.CopyTo(stream); post.MapFile.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempMapFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.MapFile.CopyTo(stream);
}
} }
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -593,6 +633,18 @@ namespace Backend.Controllers
{ {
post.MapFile.CopyTo(stream); post.MapFile.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempMapFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.MapFile.CopyTo(stream);
}
} }
apiResult.Code = "0000"; apiResult.Code = "0000";

View File

@ -17,6 +17,7 @@ namespace Backend.Controllers
private readonly IDeviceManageRepository deviceManageRepository; private readonly IDeviceManageRepository deviceManageRepository;
private string deviceKindFileSaveAsPath = ""; private string deviceKindFileSaveAsPath = "";
private string deviceKindFilePath = "upload/device_icon/"; private string deviceKindFilePath = "upload/device_icon/";
private string tempDeviceKindFileSaveAsPath = "";
public DeviceManageController(IBackendRepository backendRepository, IDeviceManageRepository deviceManageRepository) public DeviceManageController(IBackendRepository backendRepository, IDeviceManageRepository deviceManageRepository)
@ -25,6 +26,7 @@ namespace Backend.Controllers
this.deviceManageRepository = deviceManageRepository; this.deviceManageRepository = deviceManageRepository;
deviceKindFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "device_icon"); deviceKindFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "device_icon");
tempDeviceKindFileSaveAsPath = Path.Combine("wwwroot", "upload", "device_icon");
} }
public IActionResult Index() public IActionResult Index()
@ -1206,6 +1208,18 @@ namespace Backend.Controllers
{ {
post.Device_image_file.CopyTo(stream); post.Device_image_file.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempDeviceKindFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Device_image_file.CopyTo(stream);
}
} }
#region #region
@ -1306,6 +1320,18 @@ namespace Backend.Controllers
{ {
post.Device_image_file.CopyTo(stream); post.Device_image_file.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempDeviceKindFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Device_image_file.CopyTo(stream);
}
} }
#region #region
@ -1559,6 +1585,18 @@ namespace Backend.Controllers
{ {
post.Device_master_icon_file.CopyTo(stream); post.Device_master_icon_file.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempDeviceKindFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Device_master_icon_file.CopyTo(stream);
}
} }
#region #region
@ -1624,6 +1662,18 @@ namespace Backend.Controllers
{ {
post.Device_master_icon_file.CopyTo(stream); post.Device_master_icon_file.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempDeviceKindFileSaveAsPath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.Device_master_icon_file.CopyTo(stream);
}
} }
#region #region

View File

@ -14,10 +14,13 @@ namespace Backend.Controllers
{ {
private readonly IBackendRepository backendRepository; private readonly IBackendRepository backendRepository;
private string variableFilePath = ""; private string variableFilePath = "";
private string tempVariableFilePath = "";
public VariableController(IBackendRepository backendRepository) public VariableController(IBackendRepository backendRepository)
{ {
this.backendRepository = backendRepository; this.backendRepository = backendRepository;
variableFilePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img"); variableFilePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img");
tempVariableFilePath = Path.Combine("wwwroot", "img");
} }
@ -157,6 +160,18 @@ namespace Backend.Controllers
{ {
post.file.CopyTo(stream); post.file.CopyTo(stream);
} }
var frontendPath = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'directory' and system_key = 'frontend'");
fullPath = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), frontendPath, tempVariableFilePath);
if (!System.IO.Directory.Exists(fullPath))
System.IO.Directory.CreateDirectory(fullPath);
fullPath = Path.Combine(fullPath, fileName);
using (var stream = new FileStream(fullPath, FileMode.Create))
{
post.file.CopyTo(stream);
}
} }
if (variableInfo == null) if (variableInfo == null)