Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
		
						commit
						53b5373604
					
				@ -383,7 +383,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                apiResult.Code = "5000";
 | 
					                apiResult.Code = "5000";
 | 
				
			||||||
                return BadRequest(apiResult);
 | 
					                return BadRequest(apiResult);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (post.building_guid == null)
 | 
					            if (post.building_tag == null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                apiResult.Code = "9997";
 | 
					                apiResult.Code = "9997";
 | 
				
			||||||
                return Ok(apiResult);
 | 
					                return Ok(apiResult);
 | 
				
			||||||
@ -396,13 +396,13 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                var disastersql = "";
 | 
					                var disastersql = "";
 | 
				
			||||||
                var layer3sql = "";
 | 
					                var layer3sql = "";
 | 
				
			||||||
                var sWhere = "";
 | 
					                var sWhere = "";
 | 
				
			||||||
                if (!String.IsNullOrEmpty(post.main_system_guid))
 | 
					                if (!String.IsNullOrEmpty(post.main_system_tag))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    main_system_guidsql = $" and d.main_system_guid = '{post.main_system_guid}'";
 | 
					                    main_system_guidsql = $" and d.device_system_tag = '{post.main_system_tag}'";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!String.IsNullOrEmpty(post.sub_system_guid))
 | 
					                if (!String.IsNullOrEmpty(post.sub_system_tag))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    sub_system_guidsql = $" and d.sub_system_guid = '{post.sub_system_guid}'";
 | 
					                    sub_system_guidsql = $" and d.device_name_tag = '{post.sub_system_tag}'";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!String.IsNullOrEmpty(post.device_system_category_layer3))
 | 
					                if (!String.IsNullOrEmpty(post.device_system_category_layer3))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -417,13 +417,13 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1")
 | 
					                if (!String.IsNullOrEmpty(post.show_cctv) && post.show_cctv == "1")
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var str_arr = new List<string>();
 | 
					                    var str_arr = new List<string>();
 | 
				
			||||||
                    if (!String.IsNullOrEmpty(post.main_system_guid))
 | 
					                    if (!String.IsNullOrEmpty(post.main_system_tag))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        str_arr.Add($@"d.main_system_guid = '{post.main_system_guid}'");
 | 
					                        str_arr.Add($@"d.device_system_tag = '{post.main_system_tag}'");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (!String.IsNullOrEmpty(post.sub_system_guid))
 | 
					                    if (!String.IsNullOrEmpty(post.sub_system_tag))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        str_arr.Add($@"d.sub_system_guid = '{post.sub_system_guid}'");
 | 
					                        str_arr.Add($@"d.device_name_tag = '{post.sub_system_tag}'");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (!String.IsNullOrEmpty(post.device_system_category_layer3))
 | 
					                    if (!String.IsNullOrEmpty(post.device_system_category_layer3))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
@ -495,12 +495,12 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                                                            and d.device_name_tag = dk.device_name_tag
 | 
					                                                            and d.device_name_tag = dk.device_name_tag
 | 
				
			||||||
                                    left join device_master dm ON d.device_building_tag = dm.device_building_tag 
 | 
					                                    left join device_master dm ON d.device_building_tag = dm.device_building_tag 
 | 
				
			||||||
                                                              AND d.device_name_tag = dm.device_name_tag
 | 
					                                                              AND d.device_name_tag = dm.device_name_tag
 | 
				
			||||||
                                    left join device_item di ON d.sub_system_guid = di.sub_system_guid 
 | 
					                                    left join device_item di ON d.device_name_tag = di.device_name_tag 
 | 
				
			||||||
                                                              AND di.deleted = 0 
 | 
					                                                              AND di.deleted = 0 
 | 
				
			||||||
                                                              AND di.is_show_riserDiagram = 1
 | 
					                                                              AND di.is_show_riserDiagram = 1
 | 
				
			||||||
                                    {disasterjoinsql}
 | 
					                                    {disasterjoinsql}
 | 
				
			||||||
                                    LEFT JOIN building_menu bm ON d.building_guid = bm.building_guid AND d.main_system_guid = bm.main_system_guid AND d.sub_system_guid = bm.sub_system_guid
 | 
					                                    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.building_guid = '{post.building_guid}' {sWhere}
 | 
					                                    where d.deleted = 0 and d.device_building_tag = '{post.building_tag}' {sWhere}
 | 
				
			||||||
                                    order by d.priority ASC, d.device_number ASC";
 | 
					                                    order by d.priority ASC, d.device_number ASC";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql);
 | 
					                var devicelist = await backendRepository.GetAllAsync<DeviceFloor>(sql);
 | 
				
			||||||
@ -521,9 +521,9 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //抓出該設備所需要的顯示的即時資料(平面圖)
 | 
					                //抓出該設備所需要的顯示的即時資料(平面圖)
 | 
				
			||||||
                var sql_tips = $@"SELECT di.* FROM device_item di WHERE di.deleted = 0 AND is_show = 1 AND sub_system_guid = @sub_system_guid";
 | 
					                var sql_tips = $@"SELECT di.* FROM device_item di WHERE di.deleted = 0 AND is_show = 1 AND device_name_tag = @sub_system_tag";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var device_item_floormap = await backendRepository.GetAllAsync<DeviceItem>(sql_tips, new { sub_system_guid = post.sub_system_guid });
 | 
					                var device_item_floormap = await backendRepository.GetAllAsync<DeviceItem>(sql_tips, new { sub_system_tag = post.sub_system_tag });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                foreach (var device in devicelist)
 | 
					                foreach (var device in devicelist)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										332
									
								
								FrontendWebApi/ApiControllers/GraphManage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										332
									
								
								FrontendWebApi/ApiControllers/GraphManage.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,332 @@
 | 
				
			|||||||
 | 
					using Microsoft.AspNetCore.Http;
 | 
				
			||||||
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
 | 
					using Microsoft.Extensions.Logging;
 | 
				
			||||||
 | 
					using Repository.BackendRepository.Implement;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using FrontendWebApi.Models;
 | 
				
			||||||
 | 
					using Repository.BackendRepository.Interface;
 | 
				
			||||||
 | 
					using Repository.FrontendRepository.Interface;
 | 
				
			||||||
 | 
					using static Repository.Models.GraphManage;
 | 
				
			||||||
 | 
					using NPOI.SS.UserModel;
 | 
				
			||||||
 | 
					using Microsoft.Extensions.Hosting;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FrontendWebApi.ApiControllers
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [Route("api/[controller]")]
 | 
				
			||||||
 | 
					    [ApiController]
 | 
				
			||||||
 | 
					    public class GraphManageController : MyBaseApiController<GraphManageController>
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly IBackendRepository backendRepository;
 | 
				
			||||||
 | 
					        private readonly IFrontendRepository frontendRepository;
 | 
				
			||||||
 | 
					        private string graph_manage_layer1 = "graph_manage_layer1";
 | 
				
			||||||
 | 
					        private string graph_manage_layer2 = "graph_manage_layer2";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private string graphManageFileSaveAsPath = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public GraphManageController(IBackendRepository backendRepository, IFrontendRepository frontendRepository)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.backendRepository = backendRepository;
 | 
				
			||||||
 | 
					            this.frontendRepository = frontendRepository;
 | 
				
			||||||
 | 
					            graphManageFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "graph_manage");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<List<Variable>>> MaiSysList()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
 | 
				
			||||||
 | 
					            List<Variable> main_system_list = new List<Variable>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sqlString = @$"SELECT *
 | 
				
			||||||
 | 
					                                    FROM variable 
 | 
				
			||||||
 | 
					                                    WHERE system_type = @graph_manage_layer1 AND deleted = 0
 | 
				
			||||||
 | 
					                                    ORDER BY system_priority, created_at desc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var param = new { @graph_manage_layer1 = graph_manage_layer1 };
 | 
				
			||||||
 | 
					                main_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = main_system_list;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<List<Variable>>> SubSysList(int main_system_id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
 | 
				
			||||||
 | 
					            List<Variable> sub_system_list = new List<Variable>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sqlString = @$"SELECT v2.*
 | 
				
			||||||
 | 
					                                    FROM variable v2
 | 
				
			||||||
 | 
					                                    JOIN variable v1 ON v2.system_parent_id = v1.id AND v1.system_type = @graph_manage_layer1 AND v1.deleted = 0
 | 
				
			||||||
 | 
					                                    WHERE v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 AND v1.id = @main_system_id
 | 
				
			||||||
 | 
					                                    ORDER BY v2.system_priority, v2.created_at desc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var param = new { @graph_manage_layer1 = graph_manage_layer1, @graph_manage_layer2 = graph_manage_layer2 };
 | 
				
			||||||
 | 
					                sub_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = sub_system_list;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<List<GraphList>>> GraManList(GraphInfo gi)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<List<GraphList>> apiResult = new ApiResult<List<GraphList>>();
 | 
				
			||||||
 | 
					            List<GraphList> graManList = new List<GraphList>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sqlString = @$"SELECT *
 | 
				
			||||||
 | 
					                                    FROM graph_manage gm
 | 
				
			||||||
 | 
					                                    JOIN variable v2 ON gm.sub_system_id = v2.id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
 | 
				
			||||||
 | 
					                                    WHERE v2.id in @sub_system_id AND gm.deleted = 0
 | 
				
			||||||
 | 
					                                    ORDER BY gm.priority, gm.created_at desc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_id = gi.sub_system_id };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                graManList = await backendRepository.GetAllAsync<GraphList>(sqlString, param);
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                if (gi.keyWord != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var wParam = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_id = gi.sub_system_id, @keyWord = gi.keyWord };
 | 
				
			||||||
 | 
					                    graManList = await backendRepository.GetAllAsync<GraphList>(@$"SELECT *
 | 
				
			||||||
 | 
					                                    FROM graph_manage gm
 | 
				
			||||||
 | 
					                                    JOIN variable v2 ON gm.sub_system_id = v2.id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
 | 
				
			||||||
 | 
					                                    WHERE v2.id in @sub_system_id AND gm.deleted = 0
 | 
				
			||||||
 | 
					                                            AND (code like '%@keyWord%' OR name like '%@keyWord%' OR oriOrgName like '%@keyWord%' OR donOrgName like '%@keyWord%')
 | 
				
			||||||
 | 
					                                    ORDER BY gm.priority, gm.created_at desc", wParam);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = graManList;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<string>> DelOneGraMan(GraphInfo gi)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<string> apiResult = new ApiResult<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sqlString = @$"UPDATE graph_manage SET deleted = 0 WHERE code = @code AND sub_system_id = @sub_system_id";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var param = new { @code = gi.code, @sub_system_id = gi.sub_system_id };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await backendRepository.ExecuteSql(sqlString, param);
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = "刪除成功";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<string>> EdtOneGraMan([FromForm] GraphInsInfo gii)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<string> apiResult = new ApiResult<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sWhere = @$"deleted = 0 AND code = @code AND sub_system_id = @sub_system_id";
 | 
				
			||||||
 | 
					                var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_id = gii.sub_system_id});
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                if (gm == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    apiResult.Code = "0001";
 | 
				
			||||||
 | 
					                    apiResult.Data = "無法找到圖資";
 | 
				
			||||||
 | 
					                    return apiResult;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Dictionary<string, object> graph_manage = new Dictionary<string, object>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //edit file
 | 
				
			||||||
 | 
					                if (gii.oriOrgName != null || gii.donOrgName != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (!System.IO.Directory.Exists(graphManageFileSaveAsPath))
 | 
				
			||||||
 | 
					                        System.IO.Directory.CreateDirectory(graphManageFileSaveAsPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (gm.oriSavName != null && gii.oriOrgName != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        var new_guid = Guid.NewGuid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //刪除原本檔案
 | 
				
			||||||
 | 
					                        FolderFunction folderFunction = new FolderFunction();
 | 
				
			||||||
 | 
					                        folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.oriSavName));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fileName = new_guid + "." + gii.oriOrgName.Split('.')[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fullPath = Path.Combine(graphManageFileSaveAsPath, fileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            gii.oriFile.CopyTo(stream);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriOrgName", gii.oriOrgName);
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriSavName", fileName);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (gm.donSavName != null && gii.donOrgName != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        var new_guid = Guid.NewGuid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        //刪除原本檔案
 | 
				
			||||||
 | 
					                        FolderFunction folderFunction = new FolderFunction();
 | 
				
			||||||
 | 
					                        folderFunction.DeleteFile(Path.Combine(graphManageFileSaveAsPath, gm.donSavName));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fileName = new_guid + "." + gii.donOrgName.Split('.')[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fullPath = Path.Combine(graphManageFileSaveAsPath, fileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            gii.donFile.CopyTo(stream);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriOrgName", gii.donOrgName);
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriSavName", fileName);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                graph_manage.Add("@name", gii.name);
 | 
				
			||||||
 | 
					                //graph_manage.Add("@priority", gii.priority);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await backendRepository.UpdateOneByCustomTable(graph_manage, "graph_manage", "code='" + gii.code + "'" + "sub_system_id ='" + gii.sub_system_id + "'");
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = "修改成功";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                string json = System.Text.Json.JsonSerializer.Serialize(gii);
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ApiResult<string>> SaveGraMan([FromForm] GraphInsInfo gii)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ApiResult<string> apiResult = new ApiResult<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var sWhere = @$"deleted = 0 AND code = @code AND sub_system_id = @sub_system_id";
 | 
				
			||||||
 | 
					                var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_id = gii.sub_system_id });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (gm != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    apiResult.Code = "0002";
 | 
				
			||||||
 | 
					                    apiResult.Data = "已有相同的編碼";
 | 
				
			||||||
 | 
					                    return apiResult;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Dictionary<string, object> graph_manage = new Dictionary<string, object>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //save file
 | 
				
			||||||
 | 
					                if (gii.oriOrgName != null || gii.donOrgName != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (!System.IO.Directory.Exists(graphManageFileSaveAsPath))
 | 
				
			||||||
 | 
					                        System.IO.Directory.CreateDirectory(graphManageFileSaveAsPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (gii.oriOrgName != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        var new_guid = Guid.NewGuid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fileName = new_guid + "." + gii.oriOrgName.Split('.')[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fullPath = Path.Combine(graphManageFileSaveAsPath, fileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            gii.oriFile.CopyTo(stream);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriOrgName", gii.oriOrgName);
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriSavName", fileName);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (gii.donOrgName != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        var new_guid = Guid.NewGuid();
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
 | 
					                        var fileName = new_guid + "." + gii.donOrgName.Split('.')[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        var fullPath = Path.Combine(graphManageFileSaveAsPath, fileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        using (var stream = new FileStream(fullPath, FileMode.Create))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            gii.donFile.CopyTo(stream);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriOrgName", gii.donOrgName);
 | 
				
			||||||
 | 
					                        graph_manage.Add("@oriSavName", fileName);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var newPriority = await backendRepository.GetCurrentPriority("graph_manage");
 | 
				
			||||||
 | 
					                graph_manage.Add("@name", gii.name);
 | 
				
			||||||
 | 
					                graph_manage.Add("@deleted", 0);
 | 
				
			||||||
 | 
					                graph_manage.Add("@priority", newPriority + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await backendRepository.AddOneByCustomTable(graph_manage, "graph_manage");
 | 
				
			||||||
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
 | 
					                apiResult.Data = "新增成功";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception exception)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
 | 
					                string json = System.Text.Json.JsonSerializer.Serialize(gii);
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
 | 
				
			||||||
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return apiResult;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -30,6 +30,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
        protected bool jwtlife = true;
 | 
					        protected bool jwtlife = true;
 | 
				
			||||||
        public string controllerName;
 | 
					        public string controllerName;
 | 
				
			||||||
        public string actionName;
 | 
					        public string actionName;
 | 
				
			||||||
 | 
					        public string main_system_type = "device_system_category_layer2";
 | 
				
			||||||
 | 
					        public string sub_system_type = "device_system_category_layer3";
 | 
				
			||||||
        public ErrorCode errorCode = new ErrorCode();
 | 
					        public ErrorCode errorCode = new ErrorCode();
 | 
				
			||||||
        [Authorize]
 | 
					        [Authorize]
 | 
				
			||||||
        public override void OnActionExecuting(ActionExecutingContext filterContext)
 | 
					        public override void OnActionExecuting(ActionExecutingContext filterContext)
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,10 @@
 | 
				
			|||||||
  <PropertyGroup>
 | 
					  <PropertyGroup>
 | 
				
			||||||
    <TargetFramework>netcoreapp3.1</TargetFramework>
 | 
					    <TargetFramework>netcoreapp3.1</TargetFramework>
 | 
				
			||||||
    <UserSecretsId>e7f9420f-8be4-4163-bb5a-13bbee6b0b36</UserSecretsId>
 | 
					    <UserSecretsId>e7f9420f-8be4-4163-bb5a-13bbee6b0b36</UserSecretsId>
 | 
				
			||||||
 | 
					    <!--VS編譯CORE3.1出現錯誤-->
 | 
				
			||||||
 | 
					    <!--Fixing Error NETSDK1152 after upgrading to .NET 6 https://www.poppastring.com/blog/fixing-error-netsdk1152-after-upgrading-to-net-6-->
 | 
				
			||||||
 | 
					    <!--.NET Core 6 Found multiple publish output files with the same relative path https://github.com/dotnet/sdk/issues/22716-->
 | 
				
			||||||
 | 
					    <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
				
			|||||||
@ -62,9 +62,9 @@ namespace FrontendWebApi.Models
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public class GetSubPost
 | 
					    public class GetSubPost
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public string main_system_guid { get; set; }
 | 
					        public string main_system_tag { get; set; }
 | 
				
			||||||
        public string sub_system_guid { get; set; }
 | 
					        public string sub_system_tag { get; set; }
 | 
				
			||||||
        public string building_guid { get; set; }
 | 
					        public string building_tag { get; set; }
 | 
				
			||||||
        public string device_system_value { get; set; }
 | 
					        public string device_system_value { get; set; }
 | 
				
			||||||
        public string device_system_category_layer3 { get; set; }
 | 
					        public string device_system_category_layer3 { get; set; }
 | 
				
			||||||
        public string show_cctv { get; set; }
 | 
					        public string show_cctv { get; set; }
 | 
				
			||||||
 | 
				
			|||||||
@ -48,6 +48,7 @@ namespace FrontendWebApi.Models
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public class Variable : Actor
 | 
					    public class Variable : Actor
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        public int id { get; set; }
 | 
				
			||||||
        public string System_type { get; set; }
 | 
					        public string System_type { get; set; }
 | 
				
			||||||
        public string System_key { get; set; }
 | 
					        public string System_key { get; set; }
 | 
				
			||||||
        public string system_value { get; set; }
 | 
					        public string system_value { get; set; }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										41
									
								
								Repository/Models/GraphManage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Repository/Models/GraphManage.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					using Microsoft.AspNetCore.Http;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Security;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Repository.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class GraphManage
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public class GraphList
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public string code { get; set; }
 | 
				
			||||||
 | 
					            public int sub_system_id { get; set; } 
 | 
				
			||||||
 | 
					            public string name { get; set; }
 | 
				
			||||||
 | 
					            public string oriOrgName { get; set; }
 | 
				
			||||||
 | 
					            public string oriSavName { get; set; }
 | 
				
			||||||
 | 
					            public string donOrgName { get; set; }
 | 
				
			||||||
 | 
					            public string donSavName { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public class GraphInsInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public string code { get; set; }
 | 
				
			||||||
 | 
					            public int sub_system_id { get; set; }
 | 
				
			||||||
 | 
					            public string name { get; set; }
 | 
				
			||||||
 | 
					            public string oriOrgName { get; set; }
 | 
				
			||||||
 | 
					            public string oriSavName { get; set; }
 | 
				
			||||||
 | 
					            public string donOrgName { get; set; }
 | 
				
			||||||
 | 
					            public string donSavName { get; set; }
 | 
				
			||||||
 | 
					            public int priority { get; set; }
 | 
				
			||||||
 | 
					            public IFormFile oriFile { get; set; }
 | 
				
			||||||
 | 
					            public IFormFile donFile { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public class GraphInfo
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public string code { get; set; }
 | 
				
			||||||
 | 
					            public List<int> sub_system_id { get; set; }
 | 
				
			||||||
 | 
					            public string keyWord { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -167,10 +167,8 @@ namespace tpDomeWinAPP
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                webRequestSvc svc = new webRequestSvc();
 | 
					                webRequestSvc svc = new webRequestSvc();
 | 
				
			||||||
                string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";
 | 
					                string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint ";
 | 
				
			||||||
                //ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql);//原本的
 | 
					                ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql);
 | 
				
			||||||
                ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
 | 
					                //ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);            
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                dataGridView1.DataSource = ds;
 | 
					                dataGridView1.DataSource = ds;
 | 
				
			||||||
                dataGridView1.Columns[0].Visible = false;
 | 
					                dataGridView1.Columns[0].Visible = false;
 | 
				
			||||||
                dataGridView1.Columns[1].Width = 400;
 | 
					                dataGridView1.Columns[1].Width = 400;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user