From acb941737f722a270975d267ebfe48ac0050e7d9 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 26 Oct 2023 16:11:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E4=B8=8A=E5=82=B3=E6=96=87=E4=BB=B6=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildInfoController.cs | 52 +++++++++++++++++++ Backend/Controllers/DeviceManageController.cs | 50 ++++++++++++++++++ Backend/Controllers/VariableController.cs | 15 ++++++ .../7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg | 0 .../7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg | 0 5 files changed, 117 insertions(+) create mode 100644 Backend/wwwroot/upload/floor_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg create mode 100644 FrontendWebApi/wwwroot/upload/build_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg diff --git a/Backend/Controllers/BuildInfoController.cs b/Backend/Controllers/BuildInfoController.cs index 5b57556..26777a4 100644 --- a/Backend/Controllers/BuildInfoController.cs +++ b/Backend/Controllers/BuildInfoController.cs @@ -20,6 +20,8 @@ namespace Backend.Controllers private readonly IBackendRepository backendRepository; private string mapFileSaveAsPath = ""; private string buildMapFileSaveAsPath = ""; + private string tempMapFileSaveAsPath = ""; + private string tempBuildMapFileSaveAsPath = ""; public BuildInfoController(IBackendRepository backendRepository) { @@ -27,6 +29,8 @@ namespace Backend.Controllers mapFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "floor_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() @@ -175,6 +179,18 @@ namespace Backend.Controllers { post.Map3dFile.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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"; @@ -289,6 +305,18 @@ namespace Backend.Controllers { post.Map3dFile.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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"; @@ -550,6 +578,18 @@ namespace Backend.Controllers { post.MapFile.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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"; @@ -593,6 +633,18 @@ namespace Backend.Controllers { post.MapFile.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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"; diff --git a/Backend/Controllers/DeviceManageController.cs b/Backend/Controllers/DeviceManageController.cs index f7fe421..7ca51bb 100644 --- a/Backend/Controllers/DeviceManageController.cs +++ b/Backend/Controllers/DeviceManageController.cs @@ -17,6 +17,7 @@ namespace Backend.Controllers private readonly IDeviceManageRepository deviceManageRepository; private string deviceKindFileSaveAsPath = ""; private string deviceKindFilePath = "upload/device_icon/"; + private string tempDeviceKindFileSaveAsPath = ""; public DeviceManageController(IBackendRepository backendRepository, IDeviceManageRepository deviceManageRepository) @@ -25,6 +26,7 @@ namespace Backend.Controllers this.deviceManageRepository = deviceManageRepository; deviceKindFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "device_icon"); + tempDeviceKindFileSaveAsPath = Path.Combine("wwwroot", "upload", "device_icon"); } public IActionResult Index() @@ -1206,6 +1208,18 @@ namespace Backend.Controllers { post.Device_image_file.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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 新增至派送資料表 @@ -1306,6 +1320,18 @@ namespace Backend.Controllers { post.Device_image_file.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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 新增至派送資料表 @@ -1559,6 +1585,18 @@ namespace Backend.Controllers { post.Device_master_icon_file.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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 新增至派送資料表 @@ -1624,6 +1662,18 @@ namespace Backend.Controllers { post.Device_master_icon_file.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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 新增至派送資料表 diff --git a/Backend/Controllers/VariableController.cs b/Backend/Controllers/VariableController.cs index 7c2d97e..6ad419b 100644 --- a/Backend/Controllers/VariableController.cs +++ b/Backend/Controllers/VariableController.cs @@ -14,10 +14,13 @@ namespace Backend.Controllers { private readonly IBackendRepository backendRepository; private string variableFilePath = ""; + private string tempVariableFilePath = ""; + public VariableController(IBackendRepository backendRepository) { this.backendRepository = backendRepository; variableFilePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "img"); + tempVariableFilePath = Path.Combine("wwwroot", "img"); } @@ -157,6 +160,18 @@ namespace Backend.Controllers { post.file.CopyTo(stream); } + + var frontendPath = await backendRepository.GetOneAsync("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) diff --git a/Backend/wwwroot/upload/floor_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg b/Backend/wwwroot/upload/floor_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg new file mode 100644 index 0000000..e69de29 diff --git a/FrontendWebApi/wwwroot/upload/build_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg b/FrontendWebApi/wwwroot/upload/build_map/7e7816ec-0ed9-4554-8a56-00a7e4b77587.svg new file mode 100644 index 0000000..e69de29