This commit is contained in:
dev01 2023-05-16 12:15:45 +08:00
commit 7c90015daf
10 changed files with 75 additions and 58 deletions

View File

@ -2,7 +2,9 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Repository.BackendRepository.Implement;
using Repository.BackendRepository.Interface; using Repository.BackendRepository.Interface;
using Serilog.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -14,16 +16,18 @@ namespace Backend.Controllers
{ {
private readonly ILogger<LoginController> logger; private readonly ILogger<LoginController> logger;
private readonly IUserInfoRepository userInfoRepository; private readonly IUserInfoRepository userInfoRepository;
private readonly IBackendRepository backendRepository;
public LoginController(ILogger<LoginController> logger, public LoginController(ILogger<LoginController> logger, IUserInfoRepository userInfoRepository, IBackendRepository backendRepository)
IUserInfoRepository userInfoRepository)
{ {
this.logger = logger; this.logger = logger;
this.userInfoRepository = userInfoRepository; this.userInfoRepository = userInfoRepository;
this.backendRepository = backendRepository;
} }
public IActionResult Index() public IActionResult Index()
{ {
ViewBag.ProjectName = backendRepository.GetOneAsync<string>("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result;
return View(); return View();
} }
@ -92,6 +96,7 @@ namespace Backend.Controllers
/// <returns></returns> /// <returns></returns>
public IActionResult ForgotPassword() public IActionResult ForgotPassword()
{ {
ViewBag.ProjectName = backendRepository.GetOneAsync<string>("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result;
return View("~/Views/Login/ForgotPassword.cshtml"); return View("~/Views/Login/ForgotPassword.cshtml");
} }
@ -147,5 +152,33 @@ namespace Backend.Controllers
return RedirectToAction("Index", "Login"); return RedirectToAction("Index", "Login");
} }
/// <summary>
/// 獲取專案名稱(東別)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("Variable/ProjectName")]
public async Task<ApiResult<Variable>> ProjectName()
{
ApiResult<Variable> apiResult = new ApiResult<Variable>();
try
{
var variable = await backendRepository.GetOneAsync<Variable>("select * from variable where deleted = 0 and system_type = 'project_name';");
apiResult.Data = variable;
apiResult.Code = "0000";
apiResult.Msg = "成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
logger.LogError("【LogginController/ProjectName】" + exception.Message);
}
return apiResult;
}
} }
} }

View File

@ -76,6 +76,7 @@ namespace Backend.Controllers
ViewBag.myUserInfo = myUserInfo; ViewBag.myUserInfo = myUserInfo;
ViewBag.role = showview.Result; ViewBag.role = showview.Result;
ViewBag.ProjectName = backendRepository.GetOneAsync<string>("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result;
#region #region
var content = JsonConvert.SerializeObject(filterContext.ActionArguments); var content = JsonConvert.SerializeObject(filterContext.ActionArguments);
var parameter = content.CompareTo("{}") == 0 ? null : content; var parameter = content.CompareTo("{}") == 0 ? null : content;

View File

@ -75,6 +75,7 @@ namespace Backend.Controllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -92,7 +93,9 @@ namespace Backend.Controllers
bool result = false; bool result = false;
ApiResult<bool> apiResult = new ApiResult<bool>(); ApiResult<bool> apiResult = new ApiResult<bool>();
string tag_quantity = backEndConfig.Getobixtag_quantity(); var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = await backendRepository.GetAllAsync<Backend.Models.KeyValue>(sqlObix);
string tag_quantity = variableObix.Where(x => x.Name == "tag_quantity").Select(x => x.Value).FirstOrDefault();
try try
{ {
@ -125,6 +128,7 @@ namespace Backend.Controllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -170,6 +174,7 @@ namespace Backend.Controllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -210,6 +215,7 @@ namespace Backend.Controllers
catch (Exception exception) catch (Exception exception)
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }

View File

@ -242,31 +242,6 @@ namespace Backend.Controllers
return apiResult; return apiResult;
} }
/// <summary>
/// 獲取專案名稱(東別)
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<Variable>> ProjectName()
{
ApiResult<Variable> apiResult = new ApiResult<Variable>();
try
{
var variable = await backendRepository.GetOneAsync<Variable>("select * from variable where deleted = 0 and system_type = 'project_name';");
apiResult.Data = variable;
apiResult.Code = "0000";
apiResult.Msg = "成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
} }
} }

View File

@ -179,7 +179,7 @@ namespace Backend.Services.Implement
string[] s2 = s1[0].Split('/'); string[] s2 = s1[0].Split('/');
var displayName = s1[1].Split('=')[1]; var displayName = s1[1].Split('=')[1];
row.name = s1[0].Replace('/', '_').Remove(s1[0].Length - 1, 1).Remove(0, 1); row.name = s1[0].Remove(s1[0].Length - 1, 1).Remove(0, 1);
row.displayName = displayName; row.displayName = displayName;
row.isHistory = false; row.isHistory = false;
@ -275,30 +275,30 @@ namespace Backend.Services.Implement
var newConPoint = conPoint.Where(x => !x.isHistory).ToArray(); var newConPoint = conPoint.Where(x => !x.isHistory).ToArray();
foreach(var n in newConPoint) foreach(var n in newConPoint)
{ {
if (n.name.Split('_').Length == 9) if (n.name.Split('/').Length == 9)
{ {
result.Add(new ImpNiaItem result.Add(new ImpNiaItem
{ {
device_area_tag = n.name.Split('_')[0], device_area_tag = n.name.Split('/')[0],
device_building_tag = n.name.Split('_')[1], device_building_tag = n.name.Split('/')[1],
device_system_tag = n.name.Split('_')[2], device_system_tag = n.name.Split('/')[2],
device_name_tag = n.name.Split('_')[3], device_name_tag = n.name.Split('/')[3],
device_point_name = n.name.Split('_')[8], device_point_name = n.name.Split('/')[8],
full_name = n.displayName, full_name = n.displayName,
parent_path = oneStationName, parent_path = oneStationName,
isHistory = n.isHistory isHistory = n.isHistory
}); });
} }
else if (n.name.Split('_').Length == 11) //Arena_D2_CWB_L110_CAP_D2_CWB_L110_CAP_MET1_ER else if (n.name.Split('/').Length == 11) //Arena_D2_CWB_L110_CAP_D2_CWB_L110_CAP_MET1_ER
{ {
if (n.name.Split('_')[6] == "S" || n.name.Split('_')[6] == "CWB") //for security system and CWB system if (n.name.Split('/')[6] == "S" || n.name.Split('/')[6] == "CWB") //for security system and CWB system
{ {
result.Add(new ImpNiaItem { result.Add(new ImpNiaItem {
device_building_tag = n.name.Split('_')[5], device_building_tag = n.name.Split('/')[5],
device_system_tag = n.name.Split('_')[6], device_system_tag = n.name.Split('/')[6],
device_floor_tag = n.name.Split('_')[7], device_floor_tag = n.name.Split('/')[7],
device_name_tag = n.name.Split('_')[8], device_name_tag = n.name.Split('/')[8],
device_point_name = n.name.Split('_')[10], device_point_name = n.name.Split('/')[10],
full_name = n.displayName, full_name = n.displayName,
parent_path = oneStationName, parent_path = oneStationName,
isHistory = n.isHistory isHistory = n.isHistory
@ -308,11 +308,11 @@ namespace Backend.Services.Implement
{ {
result.Add(new ImpNiaItem result.Add(new ImpNiaItem
{ {
device_building_tag = n.name.Split('_')[5], device_building_tag = n.name.Split('/')[5],
//device_system_tag = n.name.Split('_')[1], //device_system_tag = n.name.Split('/')[1],
device_floor_tag = n.name.Split('_')[7], device_floor_tag = n.name.Split('/')[7],
device_name_tag = n.name.Split('_')[6], device_name_tag = n.name.Split('/')[6],
device_point_name = n.name.Split('_')[10], device_point_name = n.name.Split('/')[10],
full_name = n.displayName, full_name = n.displayName,
parent_path = oneStationName, parent_path = oneStationName,
isHistory = n.isHistory isHistory = n.isHistory

View File

@ -7,7 +7,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>忘記密碼 | IBMS後台管理系統</title> <title>忘記密碼 | @ViewData["ProjectName"]後台管理系統</title>
<!-- base css --> <!-- base css -->
<link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css"> <link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css">
<link id="appbundle" rel="stylesheet" media="screen, print" href="~/css/app.bundle.css"> <link id="appbundle" rel="stylesheet" media="screen, print" href="~/css/app.bundle.css">
@ -29,7 +29,7 @@
<div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-2"> <div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-2">
<div class="w-100 page-logo-link press-scale-down d-flex align-items-center"> <div class="w-100 page-logo-link press-scale-down d-flex align-items-center">
<img src="/img/dome.png" width="50%" aria-roledescription="logo"> <img src="/img/dome.png" width="50%" aria-roledescription="logo">
<span class="page-logo-text">IBMS後台管理系統</span> <span class="page-logo-text">@ViewData["ProjectName"]後台管理系統</span>
</div> </div>
</div> </div>
<div class="card p-4 border-top-left-radius-0 border-top-right-radius-0"> <div class="card p-4 border-top-left-radius-0 border-top-right-radius-0">

View File

@ -7,7 +7,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>登入 | IBMS後台管理系統</title> <title>登入 | @ViewData["ProjectName"]後台管理系統</title>
<!-- base css --> <!-- base css -->
<link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css"> <link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css">
@ -31,7 +31,7 @@
<div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-2"> <div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-2">
<div class="w-100 page-logo-link press-scale-down d-flex align-items-center"> <div class="w-100 page-logo-link press-scale-down d-flex align-items-center">
<img src="/img/dome.png" width="50%" aria-roledescription="logo"> <img src="/img/dome.png" width="50%" aria-roledescription="logo">
<span class="page-logo-text">IBMS後台管理系統</span> <span class="page-logo-text">@(ViewBag.ProjectName)後台管理系統</span>
</div> </div>
</div> </div>
<div class="card p-4 border-top-left-radius-0 border-top-right-radius-0"> <div class="card p-4 border-top-left-radius-0 border-top-right-radius-0">

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="description" content="Page Title"> <meta name="description" content="Page Title">
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - IBMS後台管理系統</title> <title>@ViewData["Title"] - @ViewData["ProjectName"]後台管理系統</title>
<!-- base css --> <!-- base css -->
<link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css" asp-append-version="true"> <link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css" asp-append-version="true">
@ -353,7 +353,7 @@
</a> </a>
</form> </form>
</div>--> </div>-->
<h1 class="subheader-title">IBMS後台管理系統</h1> <h1 class="subheader-title">@ViewData["ProjectName"]後台管理系統</h1>
<div class="ml-auto d-flex"> <div class="ml-auto d-flex">
<!-- activate app search icon (mobile) --> <!-- activate app search icon (mobile) -->
@ -998,3 +998,5 @@
@RenderSection("Scripts", required: false) @RenderSection("Scripts", required: false)
</body> </body>
</html> </html>
<script>
</scirpt>

View File

@ -1243,7 +1243,7 @@ namespace BackendWorkerService.Quartz.Jobs
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":
var sum = Convert.ToDecimal(real["@val"].ToString()); var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@sum_rawdata", sum); arrangeRawData.Add("@sum_rawdata", sum);
break; break;
} }
@ -1311,7 +1311,7 @@ namespace BackendWorkerService.Quartz.Jobs
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":
var sum = Convert.ToDecimal(real["@val"].ToString()); var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@sum_rawdata", sum); arrangeRawData.Add("@sum_rawdata", sum);
break; break;
} }

View File

@ -826,7 +826,7 @@ namespace BackendWorkerService.Services.Implement
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":
var sum = Convert.ToDecimal(real["@val"].ToString()); var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@sum_rawdata", sum); arrangeRawData.Add("@sum_rawdata", sum);
break; break;
} }
@ -894,7 +894,7 @@ namespace BackendWorkerService.Services.Implement
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":
var sum = Convert.ToDecimal(real["@val"].ToString()); var sum = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@sum_rawdata", sum); arrangeRawData.Add("@sum_rawdata", sum);
break; break;
} }