From ba03adc2b505ae1e0fa2c232e739440bb9688ce4 Mon Sep 17 00:00:00 2001 From: wanli Date: Tue, 3 Jan 2023 22:28:06 +0800 Subject: [PATCH] =?UTF-8?q?[Backend]=20=E9=87=9D=E5=B0=8D=E7=87=88?= =?UTF-8?q?=E5=85=B7=EF=BC=8C=E6=B8=85=E7=A9=BA=E8=B3=87=E6=96=99=E8=A1=A8?= =?UTF-8?q?=E3=80=81=E6=96=B0=E5=A2=9E=E8=87=B3device=5Fnode=E8=B3=87?= =?UTF-8?q?=E6=96=99=E8=A1=A8=EF=BC=8C=E6=9A=AB=E6=99=82=E8=A8=BB=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/DeviceImportController.cs | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/Backend/Controllers/DeviceImportController.cs b/Backend/Controllers/DeviceImportController.cs index 1f2218b..fb0beb2 100644 --- a/Backend/Controllers/DeviceImportController.cs +++ b/Backend/Controllers/DeviceImportController.cs @@ -761,13 +761,42 @@ namespace Backend.Controllers { if (post.Count > 0) { + //清空device_node資料表 + //await backendRepository.TruncateTable("device_node"); + + //int node_priority = 1; foreach(var idfc in post) { - Dictionary device = new Dictionary(); - device.Add("@device_coordinate_3d", idfc.device_coordinate_3d); - device.Add("@forge_dbid", idfc.forge_dbid); + //if(idfc.device_number.IndexOf("_LT_L1") > -1) + //{ + // //取得device_guid + // var sWhere = $@"where deleted = 0 and device_number = " + idfc.device_number; + // var device_guid = await backendRepository.GetOneAsync("device_node", sWhere, "device_guid"); - await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'"); + // //燈具 + // Dictionary device = new Dictionary(); + // device.Add("@device_node_guid", Guid.NewGuid()); + // device.Add("@deleted", 0); + // device.Add("@device_guid", device_guid); + // device.Add("@device_node_coordinate_3d", idfc.device_coordinate_3d); + // device.Add("@forge_dbid", idfc.forge_dbid); + // device.Add("@priority", node_priority); + // device.Add("@created_by", myUserInfo.Userinfo_guid); + // device.Add("@created_at", DateTime.Now); + + // node_priority++; + // await backendRepository.AddOneByCustomTableReturnId(device, "device_node", false); + //} + //else + //{ + Dictionary device = new Dictionary(); + device.Add("@device_coordinate_3d", idfc.device_coordinate_3d); + device.Add("@forge_dbid", idfc.forge_dbid); + await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'"); + //} + + + } } apiResult.Code = "0000";