Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
		
						commit
						23bd391c5d
					
				@ -389,6 +389,17 @@ namespace Backend.Controllers
 | 
				
			|||||||
                                ORDER BY bm.priority, mv.system_priority ASC, sv.system_priority ASC, sv.created_at DESC ",
 | 
					                                ORDER BY bm.priority, mv.system_priority ASC, sv.system_priority ASC, sv.created_at DESC ",
 | 
				
			||||||
                new { building_tag = post.building_tag, MainList = post.MainList, main_system_type = main_system_type, sub_system_type = sub_system_type });
 | 
					                new { building_tag = post.building_tag, MainList = post.MainList, main_system_type = main_system_type, sub_system_type = sub_system_type });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (buildMenuTables.Any())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var data = buildMenuTables.Where(x => x.main_system_tag == "S" && x.sub_system_tag.Contains("CA")).ToList();
 | 
				
			||||||
 | 
					                    foreach (var d in data)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (d.sub_system_tag.Length == 3 && !(d.building_tag[0] == d.sub_system_tag[0]))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            buildMenuTables.Remove(d);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
                apiResult.Data = buildMenuTables;
 | 
					                apiResult.Data = buildMenuTables;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -556,6 +556,16 @@ namespace Backend.Controllers
 | 
				
			|||||||
                    apiResult.Msg = "新增成功";
 | 
					                    apiResult.Msg = "新增成功";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var sql = $@"SELECT di.id FROM device_item di 
 | 
				
			||||||
 | 
					                                                    WHERE di.deleted = 0 AND device_system_tag = @device_system_tag and device_name_tag = @device_name_tag and points = @points";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    var deviceItemId = await backendRepository.GetAllAsync<int>(sql,
 | 
				
			||||||
 | 
					                                            new { points = device_Item.points, device_system_tag = main_tag, device_name_tag = sub_tag });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (deviceItemId.Count() > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        foreach (var id in deviceItemId)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
 | 
					                            Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
@ -571,7 +581,9 @@ namespace Backend.Controllers
 | 
				
			|||||||
                                { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
					                                { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
 | 
				
			||||||
                            };
 | 
					                            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + device_Item.id + "'");
 | 
					                            await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + id + "'");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    apiResult.Code = "0000";
 | 
					                    apiResult.Code = "0000";
 | 
				
			||||||
                    apiResult.Msg = "修改成功";
 | 
					                    apiResult.Msg = "修改成功";
 | 
				
			||||||
@ -652,7 +664,7 @@ namespace Backend.Controllers
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                string sWhere = @$"deleted = @Deleted AND id = @id";
 | 
					                string sWhere = @$"deleted = @Deleted AND id = @id";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                object param = new { Deleted = 0, id = id};
 | 
					                object param = new { Deleted = 0, id = id };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var device_Item = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param);
 | 
					                var device_Item = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -663,7 +675,9 @@ namespace Backend.Controllers
 | 
				
			|||||||
                    return apiResult;
 | 
					                    return apiResult;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                await backendRepository.DeleteOne(id.ToString(), "device_item", "id");
 | 
					                string sql = $@"update device_item set deleted = 1 where device_system_tag = '{device_Item.device_system_tag}' and device_name_tag = '{device_Item.device_name_tag}' and deleted = 0
 | 
				
			||||||
 | 
					                                and points = '{device_Item.points}'";
 | 
				
			||||||
 | 
					                await backendRepository.ExecuteSql(sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
                apiResult.Msg = "刪除成功";
 | 
					                apiResult.Msg = "刪除成功";
 | 
				
			||||||
 | 
				
			|||||||
@ -520,7 +520,7 @@ namespace Backend.Controllers
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        buildingGuid = $" AND ap.building_tag = '{post.SelectedBuild}'";
 | 
					                        buildingGuid = $" AND ap.building_tag = '{post.SelectedBuild}'";
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    var sqlString = @$" SELECT ap.AuthCode, ap.MainName, ap.SubName FROM auth_page ap
 | 
					                    var sqlString = @$" SELECT ap.AuthCode, ap.MainName, ap.SubName, ap.ShowView FROM auth_page ap
 | 
				
			||||||
                                    WHERE ap.AuthType='{post.SelectedAuthType}' 
 | 
					                                    WHERE ap.AuthType='{post.SelectedAuthType}' 
 | 
				
			||||||
                                    {buildingGuid}
 | 
					                                    {buildingGuid}
 | 
				
			||||||
                                    AND ap.AuthCode NOT IN ( 
 | 
					                                    AND ap.AuthCode NOT IN ( 
 | 
				
			||||||
@ -531,6 +531,23 @@ namespace Backend.Controllers
 | 
				
			|||||||
	                                    AND ap.AuthType='{post.SelectedAuthType}'
 | 
						                                    AND ap.AuthType='{post.SelectedAuthType}'
 | 
				
			||||||
                                     )";
 | 
					                                     )";
 | 
				
			||||||
                    authPage = await backendRepository.GetAllAsync<AuthPage>(sqlString);
 | 
					                    authPage = await backendRepository.GetAllAsync<AuthPage>(sqlString);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (authPage.Any())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        var sub_system = await backendRepository.GetAllAsync<VariableInfo>($@"select * from variable where system_type = 'device_system_category_layer3' and system_value LIKE '%CA'
 | 
				
			||||||
 | 
					                                                                                            and LENGTH(system_value) = 3 and system_value != '{post.SelectedBuild[0]}CA'");
 | 
				
			||||||
 | 
					                        if (sub_system.Any())
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            foreach (var d in sub_system)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                var ap = authPage.Where(x => x.ShowView.Equals(d.id.ToString())).FirstOrDefault();
 | 
				
			||||||
 | 
					                                if (authPage != null)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    authPage.Remove(ap);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
                apiResult.Data = authPage;
 | 
					                apiResult.Data = authPage;
 | 
				
			||||||
 | 
				
			|||||||
@ -121,6 +121,7 @@ namespace Backend.Models
 | 
				
			|||||||
        public string AuthCode { get; set; }
 | 
					        public string AuthCode { get; set; }
 | 
				
			||||||
        public string MainName { get; set; }
 | 
					        public string MainName { get; set; }
 | 
				
			||||||
        public string SubName { get; set; }
 | 
					        public string SubName { get; set; }
 | 
				
			||||||
 | 
					        public string ShowView { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class PostSaveRoleAuth
 | 
					    public class PostSaveRoleAuth
 | 
				
			||||||
 | 
				
			|||||||
@ -235,24 +235,23 @@ namespace Backend.Services.Implement
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        result.Add(row);
 | 
					                        result.Add(row);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (tagName.Split('_').Length == 6) 
 | 
					                    else if (tagName.Split('_').Length == 7) 
 | 
				
			||||||
                    { //巨蛋 tag 5 段版本
 | 
					                    { //巨蛋 tag 5 段版本
 | 
				
			||||||
                        ImpNiaItem row = new ImpNiaItem();
 | 
					                        ImpNiaItem row = new ImpNiaItem();
 | 
				
			||||||
                        if (tagName.Split('_')[1] == "S") //for security system
 | 
					                        if (tagName.Split('_')[2] == "S" || tagName.Split('_')[2] == "B" || tagName.Split('_')[2] == "CWB") //for security system and parking system
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            row.device_building_tag = tagName.Split('_')[0];
 | 
					                            row.device_building_tag = tagName.Split('_')[1];
 | 
				
			||||||
                            row.device_system_tag = tagName.Split('_')[1];
 | 
					                            row.device_system_tag = tagName.Split('_')[2];
 | 
				
			||||||
                            row.device_floor_tag = tagName.Split('_')[2];
 | 
					                            row.device_floor_tag = tagName.Split('_')[3];
 | 
				
			||||||
                            row.device_name_tag = tagName.Split('_')[3];
 | 
					                            row.device_name_tag = tagName.Split('_')[4];
 | 
				
			||||||
                            row.device_point_name = tagName.Split('_')[5];
 | 
					                            row.device_point_name = tagName.Split('_')[6];
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else //for normal
 | 
					                        else //for normal
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            row.device_building_tag = tagName.Split('_')[0];
 | 
					                            row.device_building_tag = tagName.Split('_')[1];
 | 
				
			||||||
                            //row.device_system_tag = tagName.Split('_')[1];
 | 
					                            row.device_floor_tag = tagName.Split('_')[3];
 | 
				
			||||||
                            row.device_floor_tag = tagName.Split('_')[2];
 | 
					                            row.device_name_tag = tagName.Split('_')[2];
 | 
				
			||||||
                            row.device_name_tag = tagName.Split('_')[1];
 | 
					                            row.device_point_name = tagName.Split('_')[6];
 | 
				
			||||||
                            row.device_point_name = tagName.Split('_')[5];
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        row.parent_path = stationName;
 | 
					                        row.parent_path = stationName;
 | 
				
			||||||
@ -288,7 +287,7 @@ namespace Backend.Services.Implement
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
 | 
					                else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (n.name.Split('/')[3] == "S" || n.name.Split('/')[3] == "CWB") //for security system and CWB system
 | 
					                    if (n.name.Split('/')[2] == "S" || n.name.Split('/')[2] == "B" || n.name.Split('/')[2] == "CWB") //for security system and CWB system
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        result.Add(new ImpNiaItem {
 | 
					                        result.Add(new ImpNiaItem {
 | 
				
			||||||
                            device_building_tag = n.name.Split('/')[1],
 | 
					                            device_building_tag = n.name.Split('/')[1],
 | 
				
			||||||
 | 
				
			|||||||
@ -22,9 +22,9 @@
 | 
				
			|||||||
      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
					      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
				
			||||||
      //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
 | 
					      //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
 | 
				
			||||||
      //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
 | 
					      //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
 | 
				
			||||||
      //"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
 | 
					      "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
 | 
				
			||||||
      //"Database": "2U+9jYGy0dCbMzLaguBXow==", //tpe_dome_mall
 | 
					      //"Database": "2U+9jYGy0dCbMzLaguBXow==", //tpe_dome_mall
 | 
				
			||||||
      "Database": "FbHCCU4CapG9UryANXC1W+iMe403Bd82RnA7bCNVbL0=", //ibms_dome_cinema,
 | 
					      //"Database": "FbHCCU4CapG9UryANXC1W+iMe403Bd82RnA7bCNVbL0=", //ibms_dome_cinema,
 | 
				
			||||||
      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
					      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
				
			||||||
      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
					      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
				
			|||||||
@ -585,7 +585,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                                    left join floor f on d.device_floor_tag = f.full_name and f.deleted = 0
 | 
					                                    left join floor f on d.device_floor_tag = f.full_name and f.deleted = 0
 | 
				
			||||||
                                    {disasterjoinsql}
 | 
					                                    {disasterjoinsql}
 | 
				
			||||||
                                    LEFT JOIN building_menu bm ON d.device_building_tag = bm.building_tag AND d.device_system_tag = bm.main_system_tag AND d.device_name_tag = bm.sub_system_tag
 | 
					                                    LEFT JOIN building_menu bm ON d.device_building_tag = bm.building_tag AND d.device_system_tag = bm.main_system_tag AND d.device_name_tag = bm.sub_system_tag
 | 
				
			||||||
                                    where d.deleted = 0 and d.device_building_tag = '{post.building_tag}' {sWhere}
 | 
					                                    where d.deleted = 0 and d.is_link = 1 and d.device_building_tag = '{post.building_tag}' {sWhere} 
 | 
				
			||||||
                                    order by d.priority ASC, left(device_serial_tag, LENGTH(device_serial_tag) - 1) ASC";
 | 
					                                    order by d.priority ASC, left(device_serial_tag, LENGTH(device_serial_tag) - 1) ASC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql);
 | 
					                var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql);
 | 
				
			||||||
 | 
				
			|||||||
@ -283,7 +283,7 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                            sb.Append($@" update import_niagara_item a join dic_system b 
 | 
					                            sb.Append($@" update import_niagara_item a join dic_system b 
 | 
				
			||||||
				                                on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.s2_code COLLATE utf8mb4_0900_ai_ci
 | 
									                                on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.s2_code COLLATE utf8mb4_0900_ai_ci
 | 
				
			||||||
                                        set device_system_tag = b.s1_code 
 | 
					                                        set device_system_tag = b.s1_code 
 | 
				
			||||||
                                        where (device_system_tag <> 'S' and device_system_tag <> 'CWB');");
 | 
					                                        where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
 | 
					                        sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
 | 
				
			||||||
@ -315,7 +315,6 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
            using (IDbConnection conn = GetDbConnection())
 | 
					            using (IDbConnection conn = GetDbConnection())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                conn.Open();
 | 
					                conn.Open();
 | 
				
			||||||
                using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
					 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    List<NiagaraTags> result;
 | 
					                    List<NiagaraTags> result;
 | 
				
			||||||
@ -374,8 +373,11 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                                        data.device_system_tag + "', 1, now(), now() );");
 | 
					                                        data.device_system_tag + "', 1, now(), now() );");
 | 
				
			||||||
                                count += 1;
 | 
					                                count += 1;
 | 
				
			||||||
                                if (count >= 100)
 | 
					                                if (count >= 100)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                                    {
 | 
					                                    {
 | 
				
			||||||
                                        await conn.ExecuteAsync(sb.ToString());
 | 
					                                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                    sb.Clear();
 | 
					                                    sb.Clear();
 | 
				
			||||||
                                    count = 0;
 | 
					                                    count = 0;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@ -398,8 +400,11 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                                            "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
 | 
					                                            "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
 | 
				
			||||||
                                count += 1;
 | 
					                                count += 1;
 | 
				
			||||||
                                if (count >= 100)
 | 
					                                if (count >= 100)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                                    {
 | 
					                                    {
 | 
				
			||||||
                                        await conn.ExecuteAsync(sb2.ToString());
 | 
					                                        await conn.ExecuteAsync(sb2.ToString());
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                    sb2.Clear();
 | 
					                                    sb2.Clear();
 | 
				
			||||||
                                    count = 0;
 | 
					                                    count = 0;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@ -407,9 +412,12 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (sb.Length > 0)
 | 
					                        if (sb.Length > 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                await conn.ExecuteAsync(sb.ToString()); 
 | 
					                                await conn.ExecuteAsync(sb.ToString()); 
 | 
				
			||||||
                                await conn.ExecuteAsync(sb2.ToString()); 
 | 
					                                await conn.ExecuteAsync(sb2.ToString()); 
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            sb.Clear();
 | 
					                            sb.Clear();
 | 
				
			||||||
                            sb2.Clear();
 | 
					                            sb2.Clear();
 | 
				
			||||||
@ -456,8 +464,11 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                                    "','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
 | 
					                                    "','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
 | 
				
			||||||
                                count += 1;
 | 
					                                count += 1;
 | 
				
			||||||
                                if (count >= 100)
 | 
					                                if (count >= 100)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                                    {
 | 
					                                    {
 | 
				
			||||||
                                        await conn.ExecuteAsync(sb.ToString());
 | 
					                                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                    sb.Clear();
 | 
					                                    sb.Clear();
 | 
				
			||||||
                                    count = 0;
 | 
					                                    count = 0;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
@ -465,13 +476,32 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if (sb.Length > 0)
 | 
					                        if (sb.Length > 0)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                await conn.ExecuteAsync(sb.ToString()); 
 | 
					                                await conn.ExecuteAsync(sb.ToString()); 
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                            sb.Clear(); 
 | 
					                            sb.Clear(); 
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    #endregion
 | 
					                    #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    //device有,niagara有,is_link 更新成 1
 | 
				
			||||||
 | 
					                    sb.Append($@" SET SQL_SAFE_UPDATES = 0;
 | 
				
			||||||
 | 
					                        UPDATE device d
 | 
				
			||||||
 | 
					                        JOIN (
 | 
				
			||||||
 | 
							                        SELECT niagara_tags
 | 
				
			||||||
 | 
							                        FROM import_niagara_tag
 | 
				
			||||||
 | 
							                        LIMIT 100000
 | 
				
			||||||
 | 
					                        ) i ON d.device_number = i.niagara_tags 
 | 
				
			||||||
 | 
					                        SET d.is_link = 1");
 | 
				
			||||||
 | 
					                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    sb.Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //device有,niagara沒有,is_link 更新成 0
 | 
					                    //device有,niagara沒有,is_link 更新成 0
 | 
				
			||||||
                    sb.Append($@" SET SQL_SAFE_UPDATES = 0;
 | 
					                    sb.Append($@" SET SQL_SAFE_UPDATES = 0;
 | 
				
			||||||
                        UPDATE device d
 | 
					                        UPDATE device d
 | 
				
			||||||
@ -482,7 +512,10 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                        ) i ON d.device_number = i.niagara_tags 
 | 
					                        ) i ON d.device_number = i.niagara_tags 
 | 
				
			||||||
                        SET d.is_link = 0
 | 
					                        SET d.is_link = 0
 | 
				
			||||||
                        WHERE d.is_link = 1 and i.niagara_tags is null;");
 | 
					                        WHERE d.is_link = 1 and i.niagara_tags is null;");
 | 
				
			||||||
 | 
					                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
                        await conn.ExecuteAsync(sb.ToString());
 | 
					                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    sb.Clear();
 | 
					                    sb.Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -496,8 +529,12 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                            ) i ON dn.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
 | 
					                            ) i ON dn.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
 | 
				
			||||||
                            SET dn.is_link = 0 
 | 
					                            SET dn.is_link = 0 
 | 
				
			||||||
                            WHERE dn.is_link = 1 and i.niagara_tags is null;");
 | 
					                            WHERE dn.is_link = 1 and i.niagara_tags is null;");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
                        await conn.ExecuteAsync(sb.ToString());
 | 
					                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                catch (Exception exception)
 | 
					                catch (Exception exception)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //throw exception;
 | 
					                    //throw exception;
 | 
				
			||||||
@ -507,8 +544,7 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    conn.Close();
 | 
					                    conn.Close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                {
 | 
					                
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -956,18 +992,34 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
            using (IDbConnection conn = GetDbConnection())
 | 
					            using (IDbConnection conn = GetDbConnection())
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                conn.Open();
 | 
					                conn.Open();
 | 
				
			||||||
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    StringBuilder sb = new StringBuilder();
 | 
					                    StringBuilder sb = new StringBuilder();
 | 
				
			||||||
                    //先全部關閉
 | 
					                    //先全部關閉
 | 
				
			||||||
                        //sb.Append("update device_item set is_show_history=0;");
 | 
					                    sb.Append("update device_item set is_show_history=0;");
 | 
				
			||||||
                        sb.Append("update device_item set is_show_history = 0 " +
 | 
					                    using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
                            "WHERE(device_system_tag, device_name_tag, points, full_name, is_show_history) NOT IN " +
 | 
					                    {
 | 
				
			||||||
                            "(select  distinct  device_system_tag, device_name_tag, device_point_name, full_name, is_history From import_niagara_item where is_history = 1);");
 | 
					 | 
				
			||||||
                        await conn.ExecuteAsync(sb.ToString());
 | 
					                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    sb.Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    sb.Append($@"SET SQL_SAFE_UPDATES = 0;
 | 
				
			||||||
 | 
					                                update device_item di 
 | 
				
			||||||
 | 
					                                JOIN (
 | 
				
			||||||
 | 
					                                    select distinct device_system_tag, device_name_tag, device_point_name, full_name, device_building_tag from import_niagara_item where is_history = 1 limit 100000
 | 
				
			||||||
 | 
					                                ) niagara
 | 
				
			||||||
 | 
					                                ON di.device_system_tag = niagara.device_system_tag
 | 
				
			||||||
 | 
					                                    AND di.device_name_tag = niagara.device_name_tag
 | 
				
			||||||
 | 
					                                    AND di.points = niagara.device_point_name
 | 
				
			||||||
 | 
					                                    AND di.full_name = niagara.full_name
 | 
				
			||||||
 | 
					                                    AND di.device_building_tag = niagara.device_building_tag
 | 
				
			||||||
 | 
					                                set di.is_show_history = 1");
 | 
				
			||||||
 | 
					                    using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        await conn.ExecuteAsync(sb.ToString());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                catch (Exception exception)
 | 
					                catch (Exception exception)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    throw exception;
 | 
					                    throw exception;
 | 
				
			||||||
@ -976,7 +1028,7 @@ namespace Repository.BackendRepository.Implement
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    conn.Close();
 | 
					                    conn.Close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                }
 | 
					                
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user