From b2134643457de22181264353b828cb7c4e83c9f0 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 4 Jan 2023 16:24:11 +0800 Subject: [PATCH 1/2] fix problem --- FrontendWebApi/ApiControllers/UserController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs index 8da4553..7605e3d 100644 --- a/FrontendWebApi/ApiControllers/UserController.cs +++ b/FrontendWebApi/ApiControllers/UserController.cs @@ -923,7 +923,7 @@ namespace FrontendWebApi.ApiControllers try { - await backendRepository.ExecuteSql("update userinfo deleted = 1 where deleted = 0"); + await backendRepository.ExecuteSql("update userinfo set deleted = 1 where deleted = 0"); if (post != null) { From 2533649edaee51abc726624aae8fab4951f5cc8f Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 4 Jan 2023 18:38:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_accountManagement.html | 38 +++++++++++-------- Frontend/index.html | 12 ++---- Frontend/login.html | 2 +- .../ApiControllers/LoginController.cs | 24 ++++++++++++ .../ApiControllers/UtilityController.cs | 23 ----------- .../NiagaraDataSynchronizeRepository.cs | 18 ++++++--- Repository/Models/BackgroundServiceTask.cs | 5 +++ 7 files changed, 69 insertions(+), 53 deletions(-) diff --git a/Frontend/_accountManagement.html b/Frontend/_accountManagement.html index 0f1636a..f568305 100644 --- a/Frontend/_accountManagement.html +++ b/Frontend/_accountManagement.html @@ -44,7 +44,7 @@
-
+ @@ -127,7 +127,7 @@
- +
@@ -253,15 +253,7 @@ \ No newline at end of file diff --git a/Frontend/index.html b/Frontend/index.html index 4fd61ae..c8d2537 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -2782,14 +2782,10 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li } function getLogo() { - $.ajax({ - method: "post", - url: 'api/GetLogo', - async: false, - success: function (rel) { - $('[name=webLogo]').attr('src', 'img/' + rel); - } - }) + url = baseApiUrl + '/api/GetLogo', + ytAjax = new YourTeam.Ajax(url, null, function (res) { + $('[name=webLogo]').attr('src', 'img/' + res.data); + }, null, "POST").send(); } diff --git a/Frontend/login.html b/Frontend/login.html index 4c2e349..2faca2f 100644 --- a/Frontend/login.html +++ b/Frontend/login.html @@ -248,7 +248,7 @@ function getLogo() { $.ajax({ method: "post", - url: 'api/GetLogo', + url: baseApiUrl + '/api/GetLogo', async: false, success: function (rel) { $('[name=webLogo]').attr('src', 'img/' + rel); diff --git a/FrontendWebApi/ApiControllers/LoginController.cs b/FrontendWebApi/ApiControllers/LoginController.cs index 151f5db..b93e427 100644 --- a/FrontendWebApi/ApiControllers/LoginController.cs +++ b/FrontendWebApi/ApiControllers/LoginController.cs @@ -10,6 +10,7 @@ using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; +using Serilog.Core; using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; @@ -136,5 +137,28 @@ namespace FrontendWebApi.ApiControllers return Ok(apiResult); } + + [HttpPost] + [Route("api/GetLogo")] + public async Task> GetLogo() + { + ApiResult apiResult = new ApiResult(); + + try + { + var sqlString = $@"select system_value from variable where system_type = 'logo'"; + var data = await backendRepository.GetOneAsync(sqlString); + apiResult.Code = "0000"; + apiResult.Data = data; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + logger.LogError("【Login/Index】" + exception.Message); + } + + return apiResult; + } } } diff --git a/FrontendWebApi/ApiControllers/UtilityController.cs b/FrontendWebApi/ApiControllers/UtilityController.cs index b94d5be..c0da082 100644 --- a/FrontendWebApi/ApiControllers/UtilityController.cs +++ b/FrontendWebApi/ApiControllers/UtilityController.cs @@ -155,28 +155,5 @@ namespace FrontendWebApi.ApiControllers return apiResult; } - - [HttpPost] - [Route("api/GetLogo")] - public async Task> GetLogo() - { - ApiResult apiResult = new ApiResult(); - - try - { - var sqlString = $@"select system_type from variable where system_type = 'logo'"; - var data = await backendRepository.GetOneAsync(sqlString); - apiResult.Code = "0000"; - apiResult.Data = data; - } - catch (Exception exception) - { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - - return apiResult; - } } } diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 804cc30..c2f2f41 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Threading.Tasks; using System.Transactions; using Repository.Models; +using System.Data.SqlTypes; namespace Repository.BackendRepository.Implement { @@ -262,11 +263,18 @@ namespace Repository.BackendRepository.Implement foreach (var data in result2) { - sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag, - device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent, - created_by, created_at) - VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + - "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());"); + var sqlString = new StringBuilder(); + sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "'"); + var dk = (await conn.QueryAsync(sqlString.ToString())).ToList(); + + if (dk.Count == 0) + { + sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag, + device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent, + created_by, created_at) + VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + + "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());"); + } } if (sb.Length > 0) diff --git a/Repository/Models/BackgroundServiceTask.cs b/Repository/Models/BackgroundServiceTask.cs index c7d92a7..3bc756e 100644 --- a/Repository/Models/BackgroundServiceTask.cs +++ b/Repository/Models/BackgroundServiceTask.cs @@ -102,4 +102,9 @@ namespace Repository.Models public string device_system_tag { get; set; } public string device_name_tag { get; set; } } + + public class device_kind + { + public string device_kind_guid { get; set; } + } }