[後端] 修改後端controller router, 修改login index標題

This commit is contained in:
dev02 2023-05-18 17:25:15 +08:00
parent 47f29cdddf
commit 7b55ec92af
8 changed files with 773 additions and 2 deletions

View File

@ -0,0 +1,232 @@
using FrontendWebApi.Models;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Repository.BackendRepository.Interface;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class EmergencyContactController : MyBaseController<EmergencyContactController>
{
private readonly IBackendRepository backendRepository;
public EmergencyContactController(IBackendRepository backendRepository)
{
this.backendRepository = backendRepository;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<ActionResult> EmergencyContactTable (List<int> selectgroupidlist)
{
List<EmergencyContactTable> Emergency_member_tables = new List<EmergencyContactTable>();
ApiResult<List<EmergencyContactTable>> apiResult = new ApiResult<List<EmergencyContactTable>>();
try
{
Emergency_member_tables = await backendRepository.GetAllAsync<EmergencyContactTable>($@"
select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id
left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department
where em.grouping in @groupinglist and em.deleted = 0",new { groupinglist = selectgroupidlist });
apiResult.Code = "0000";
apiResult.Data = Emergency_member_tables;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
data = apiResult
});
return result;
}
public FileResult ExportPDF(string post)
{
var grouping = JsonConvert.DeserializeObject<export>(post);
var stream = new MemoryStream();
try
{
var Emergency_member_tables = backendRepository.GetAllAsync<EmergencyContactTable>($@"
select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id
left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department
where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist });
using (var doc = new Document())
{
using (var writer = PdfWriter.GetInstance(doc, stream))
{
writer.CloseStream = false;
BaseFont BaseF = BaseFont.CreateFont("C:\\Windows\\Fonts\\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font fontCh = new Font(BaseF, 14);
doc.Open();
PdfPTable table = new PdfPTable(new float[] { 1, 1, 1, 1, 1 ,1 });
table.TotalWidth = 480f;
table.LockedWidth = true;
PdfPCell header = new PdfPCell(new Phrase(grouping.disaster+"-聯絡清單", fontCh));
header.Colspan = 6;
table.AddCell(header);
table.AddCell(new Phrase("組別", fontCh));
table.AddCell(new Phrase("姓名", fontCh));
table.AddCell(new Phrase("部門", fontCh));
table.AddCell(new Phrase("電話", fontCh));
table.AddCell(new Phrase("LINE ID", fontCh));
table.AddCell(new Phrase("電子信箱", fontCh));
foreach(var group in Emergency_member_tables.Result)
{
table.AddCell(new Phrase(group.groupingName, fontCh));
table.AddCell(new Phrase(group.full_name, fontCh));
table.AddCell(new Phrase(group.departmentName, fontCh));
table.AddCell(new Phrase(group.phone, fontCh));
table.AddCell(new Phrase(group.lineid, fontCh));
table.AddCell(new Phrase(group.email, fontCh));
}
doc.Add(table);
doc.Close();
}
}
var bytes = stream.ToArray();
stream.Position = 0;
}
catch (Exception exception)
{
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return File(stream, "application/pdf", grouping.disaster+"-聯絡清單.pdf");
}
public FileResult ExportExcel(string post)
{
var grouping = JsonConvert.DeserializeObject<export>(post);
var workbook = new XSSFWorkbook();
var ms = new NpoiMemoryStream
{
AllowClose = false
};
#region excel設定
IFont font12 = workbook.CreateFont();
font12.FontName = "新細明體";
font12.FontHeightInPoints = 12;
ICellStyle style12 = workbook.CreateCellStyle();
style12.SetFont(font12);
style12.Alignment = HorizontalAlignment.Center;
style12.VerticalAlignment = VerticalAlignment.Center;
IFont font12Times = workbook.CreateFont();
font12Times.FontName = "Times New Roman";
font12Times.FontHeightInPoints = 12;
IFont font18 = workbook.CreateFont();
font18.FontName = "新細明體";
font18.FontHeightInPoints = 18;
font18.IsBold = true;
ICellStyle styleTitle18 = workbook.CreateCellStyle();
styleTitle18.SetFont(font18);
styleTitle18.Alignment = HorizontalAlignment.Center;
styleTitle18.VerticalAlignment = VerticalAlignment.Center;
ICellStyle styleLeft12 = workbook.CreateCellStyle();
styleLeft12.SetFont(font12);
styleLeft12.Alignment = HorizontalAlignment.Left;
styleLeft12.VerticalAlignment = VerticalAlignment.Center;
ICellStyle styleLine12 = workbook.CreateCellStyle();
styleLine12.SetFont(font12);
styleLine12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
styleLine12.VerticalAlignment = VerticalAlignment.Center;
styleLine12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
ICellStyle stylein12 = workbook.CreateCellStyle();
stylein12.SetFont(font12Times);
stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
stylein12.VerticalAlignment = VerticalAlignment.Center;
stylein12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
stylein12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
stylein12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
stylein12.WrapText = true;
#endregion
try
{
var Emergency_member_tables = backendRepository.GetAllAsync<EmergencyContactTable>($@"
select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id
left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department
where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist }).Result;
var sheet = workbook.CreateSheet(grouping.disaster+"-聯絡清單");
int RowPosition = 0;
IRow row = sheet.CreateRow(RowPosition);
sheet.SetColumnWidth(0, 4 * 160 * 6);
sheet.SetColumnWidth(1, 4 * 160 * 6);
sheet.SetColumnWidth(2, 4 * 160 * 6);
sheet.SetColumnWidth(3, 4 * 160 * 6);
sheet.SetColumnWidth(4, 4 * 160 * 6);
sheet.SetColumnWidth(5, 4 * 160 * 6);
ICell cell = row.CreateCell(0);
cell.SetCellValue("組別");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue("姓名");
cell.CellStyle = styleLine12;
cell = row.CreateCell(2);
cell.SetCellValue("部門");
cell.CellStyle = styleLine12;
cell = row.CreateCell(3);
cell.SetCellValue("電話");
cell.CellStyle = styleLine12;
cell = row.CreateCell(4);
cell.SetCellValue("LINE ID");
cell.CellStyle = styleLine12;
cell = row.CreateCell(5);
cell.SetCellValue("電子信箱");
cell.CellStyle = styleLine12;
foreach (var group in Emergency_member_tables)
{
RowPosition += 1;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(0);
cell.SetCellValue(group.groupingName);
cell.CellStyle = style12;
cell = row.CreateCell(1);
cell.SetCellValue(group.full_name);
cell.CellStyle = style12;
cell = row.CreateCell(2);
cell.SetCellValue(group.departmentName);
cell.CellStyle = style12;
cell = row.CreateCell(3);
cell.SetCellValue(group.phone);
cell.CellStyle = style12;
cell = row.CreateCell(4);
cell.SetCellValue(group.lineid);
cell.CellStyle = style12;
cell = row.CreateCell(5);
cell.SetCellValue(group.email);
cell.CellStyle = style12;
}
workbook.Write(ms);
ms.Flush();
ms.Seek(0, SeekOrigin.Begin);
}
catch(Exception exception)
{
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return File(ms, "application/vnd.ms-excel", grouping.disaster + "-聯絡清單.xlsx");
}
}
}

View File

@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class EmergencyDeviceMenuController : MyBaseController<EmergencyDeviceMenuController>
{
private readonly ILogger<EmergencyDeviceMenuController> _logger;
public EmergencyDeviceMenuController(ILogger<EmergencyDeviceMenuController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,142 @@
using FrontendWebApi.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Repository.BackendRepository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class EmergencyRecordController : MyBaseController<EmergencyRecordController>
{
private readonly IBackendRepository backendRepository;
public EmergencyRecordController(IBackendRepository backendRepository)
{
this.backendRepository = backendRepository;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<ApiResult<List<KeyValue>>> DisasterList()
{
ApiResult<List<KeyValue>> apiResult = new ApiResult<List<KeyValue>>();
List<KeyValue> Variable = new List<KeyValue>();
try
{
var sqlString = @$"select system_value as Value, system_key as Name from variable a where a.system_type = 'disaster' and a.deleted = 0";
Variable = await backendRepository.GetAllAsync<KeyValue>(sqlString);
apiResult.Code = "0000";
apiResult.Data = Variable;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
[HttpPost]
public async Task<ApiResult<List<KeyValue>>> BuildInfoList()
{
ApiResult<List<KeyValue>> apiResult = new ApiResult<List<KeyValue>>();
List<KeyValue> KeyValue = new List<KeyValue>();
try
{
var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC";
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
apiResult.Code = "0000";
apiResult.Data = KeyValue;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
[HttpPost]
public async Task<ActionResult> EmergencyRecordTable(EmergencyRecordEventPost post)
{
List<EmergencyRecordEventTable> EmergencyRecordEvent = new List<EmergencyRecordEventTable>();
ApiResult<List<EmergencyRecordEventTable>> apiResult = new ApiResult<List<EmergencyRecordEventTable>>();
try
{
var sqlplus = "";
if(post.selectaType != 2 )
{
sqlplus = $"and ee.type = '{post.selectaType}'";
}
if (post.dateranger != null)
{
var date = post.dateranger.Replace(" ", "").Split("-");
sqlplus += $"and ee.created_at between '{date[0].Replace(" / ", " - ")} 00:00:00' and '{date[1].Replace(" / ", " - ")} 23:59:59'";
}
EmergencyRecordEvent = await backendRepository.GetAllAsync<EmergencyRecordEventTable>($@"
select d.device_number device_name,v.system_key disaster_name,ee.*,b.full_name building_name from emergency_event ee
left join (select * from variable v where v.system_type = 'disaster') v on v.system_value = ee.disaster
left join device d on d.device_guid = ee.device_guid
left join building b on b.building_guid = ee.building_guid
where ee.deleted = 0 and ee.building_guid = '{post.selectaBuild}' and ee.disaster = '{post.selectaDisaster}' {sqlplus}
");
apiResult.Code = "0000";
apiResult.Data = EmergencyRecordEvent;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
data = apiResult
});
return result;
}
[HttpPost]
public async Task<ActionResult> EmergencyItemTable(string event_guid)
{
List<EmergencyRecordItem> EmergencyRecordEvent = new List<EmergencyRecordItem>();
ApiResult<List<EmergencyRecordItem>> apiResult = new ApiResult<List<EmergencyRecordItem>>();
try
{
EmergencyRecordEvent = await backendRepository.GetAllAsync<EmergencyRecordItem>($@"
select * from emergency_item where event_guid = '{event_guid}' order by created_at desc
");
apiResult.Code = "0000";
apiResult.Data = EmergencyRecordEvent;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】");
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
var result = Json(new
{
data = apiResult
});
return result;
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class HomeController : MyBaseController<HomeController>
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,144 @@
using FrontendWebApi.Jwt;
using FrontendWebApi.Models;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Repository.BackendRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class LoginController : Controller
{
private readonly ILogger<LoginController> logger;
private readonly IBackendRepository backendRepository;
private readonly IFrontendRepository frontendRepository;
private readonly IJwtHelpers jwt;
//string jwt_str = "login";
protected MyUserInfo myUserInfo = null;
protected JwtGet myUser;
protected string jwt_str = null;
protected bool jwtlife = true;
public LoginController
(
ILogger<LoginController> logger,
IBackendRepository backendRepository,
IFrontendRepository frontendRepository,
IJwtHelpers jwt
)
{
this.logger = logger;
this.jwt = jwt;
this.backendRepository = backendRepository;
this.frontendRepository = frontendRepository;
}
public IActionResult Index(string jwt)
{
ViewBag.jwt = jwt;
ViewBag.ProjectName = backendRepository.GetOneAsync<string>("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result;
return View();
}
[HttpPost]
[Route("api/Login")]
public async Task<ActionResult<ApiResult<TnToken>>> Login(Login login)
{
ApiResult<TnToken> apiResult = new ApiResult<TnToken>(null);
ErrorCode errorCode = new ErrorCode();
try
{
ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
EDFunction eDFunction = new EDFunction();
//string SHA256Pwd = eDFunction.GetSHA256Encryption(login.password);
var User = await backendRepository.GetOneAsync<User>("userinfo", @$"account = '{login.account}' and deleted = 0");
if (User == null)
{
apiResult.Code = "9998";
return Ok(apiResult);
}
JwtLogin jwtLoing = new JwtLogin()
{
account = User.account,
email = User.email,
full_name = User.full_name,
userinfo_guid = User.userinfo_guid
};
apiResult.Code = "0000";
apiResult.Data = jwt.GenerateToken(jwtLoing);
}
catch
{
apiResult.Code = "9999";
return BadRequest(apiResult);
}
return Ok(apiResult);
}
[HttpPost]
public async Task<ActionResult<ApiResult<string>>> CheckJwt()
{
ApiResult<string> apiResult = new ApiResult<string>(null);
ErrorCode errorCode = new ErrorCode();
try
{
var ctx = ControllerContext.HttpContext;
ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList();
myUser = new JwtGet()
{
account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(),
email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(),
full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(),
exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(),
};
if (myUser.exp == 0)
{
jwt_str = "Jwt Token不合法";
jwtlife = false;
}
else
{
//if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
//{
//取得當前登入使用者資訊
EDFunction edFunction = new EDFunction();
HttpContext.Session.SetString("MyApiAccount", edFunction.AESEncrypt(myUser.account)); //將帳號透過AES加密
//}
}
apiResult.Code = "0000";
}
catch(Exception exception)
{
apiResult.Code = "9999";
string json = System.Text.Json.JsonSerializer.Serialize(myUser.account);
logger.LogError("【Login/Index - 登入資訊】" + json);
logger.LogError("【Login/Index】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
}
}

View File

@ -0,0 +1,170 @@
using FrontendWebApi.Jwt;
using FrontendWebApi.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Configuration;
using Repository.BackendRepository.Interface;
using Repository.BaseRepository.Interface;
using Repository.FrontendRepository.Interface;
using Repository.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Routing;
using System.Diagnostics;
using Repository.BackendRepository.Implement;
namespace FrontendWebApi.Controllers
{
public class MyBaseController<T> : Controller where T : MyBaseController<T>
{
private ILogger<T> _logger;
protected ILogger<T> Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService<ILogger<T>>());
private IBackendRepository backendRepository => HttpContext?.RequestServices.GetService<IBackendRepository>();
private IJwtHelpers jwt => HttpContext?.RequestServices.GetService<IJwtHelpers>();
private IFrontendRepository frontendRepository => HttpContext?.RequestServices.GetService<IFrontendRepository>();
public BackgroundService backgroundService;
public MyBaseController() { }
protected MyUserInfo myUserInfo = null;
protected JwtGet myUser;
protected string jwt_str = null;
protected bool jwtlife = true;
public string controllerName;
public string actionName;
public ErrorCode errorCode = new ErrorCode();
[Authorize]
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
EDFunction edFunction = new EDFunction();
var myAccount = edFunction.AESDecrypt(HttpContext.Session.GetString("MyApiAccount"));
controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱
actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱
//紀錄當前PID
Process currentProcess = Process.GetCurrentProcess();
Dictionary<string, object> updateProcess = new Dictionary<string, object>();
updateProcess.Add("@system_value", currentProcess.Id.ToString());
frontendRepository.UpdateProcessPID(updateProcess, "variable", "system_type = 'watchDogCongfig' AND system_key = 'AlarmPID'");
bool isAjaxCall = filterContext.HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest";
if (string.IsNullOrEmpty(myAccount))
{
if (isAjaxCall)
{
filterContext.HttpContext.Response.Clear();
filterContext.HttpContext.Response.StatusCode = 499;
return;
}
else
{
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary
{
{"controller", "Login"},
{"action", "Index"}
});
return;
}
}
else
{
//取得當前登入使用者資訊
myUserInfo = frontendRepository.GetMyUserInfoByAccount<MyUserInfo>(myAccount);
var showview = frontendRepository.GetAllAsync<string>($@"select ap.ShowView from userinfo us
left join role_auth ra on ra.role_guid = us.role_guid
left join auth_page ap on ap.AuthCode = ra.AuthCode
where us.userinfo_guid = '{myUserInfo.Userinfo_guid}'");
myUserInfo.ShowView = showview.Result;
ViewBag.myUserInfo = myUserInfo;
ViewBag.role = showview.Result;
//var showviewt = new List<string>()
// {
// "EmergencyDeviceMenuIndex",
// "EmergencyContactIndex",
// "EmergencyRecordIndex",
// "RescueDeviceFireExtinguisher",
// "RescueDeviceAED",
// };
//ViewBag.role = showviewt;
}
//var ctx = filterContext.HttpContext;
//ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*");
//ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
//ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
//var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList();
//myUser = new JwtGet()
//{
// account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(),
// email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(),
// full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(),
// exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
// nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(),
// userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(),
//};
//TODO 模擬JWT記得刪除
//myUser.account = "Bajascript";
//myUser.email = "asd@com";
//myUser.full_name = "野原廣志";
//myUser.exp = 3600;
//myUser.userinfo_guid = "1EF9CEAC-4DBF-E2BE-8B1D-CB3014E0DA17";
//if (myUser.exp == 0)
//{
// jwt_str = "Jwt Token不合法";
// jwtlife = false;
// ViewBag.myUserInfo = null;
// ViewBag.role = null;
//}
//else
//{
// if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds)
// {
// //取得當前登入使用者資訊
// myUserInfo = frontendRepository.GetMyUserInfoByAccount<MyUserInfo>(myUser.account);
// //var showview = frontendRepository.GetAllAsync<string>($@"select ap.ShowView from userinfo us
// // left join role_auth ra on ra.role_guid = us.role_guid
// // left join auth_page ap on ap.AuthCode = ra.AuthCode
// // where us.userinfo_guid = '{myUserInfo.Userinfo_guid}'");
// //myUserInfo.ShowView = showview.Result;
// ViewBag.myUserInfo = myUserInfo;
// var showviewt = new List<string>()
// {
// "EmergencyDeviceMenuIndex",
// "EmergencyContactIndex",
// "EmergencyRecordIndex",
// "RescueDeviceFireExtinguisher",
// "RescueDeviceAED",
// };
// //ViewBag.role = showview.Result;
// ViewBag.role = showviewt;
// jwtlife = true;
// JwtLogin jwtLoing = new JwtLogin()
// {
// account = myUser.account,
// email = myUser.email,
// full_name = myUser.full_name,
// userinfo_guid = myUser.userinfo_guid
// };
// jwt_str = jwt.GenerateToken(jwtLoing).token;
// }
//}
base.OnActionExecuting(filterContext);
}
}
}

View File

@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Repository.BackendRepository.Interface;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace FrontendWebApi.Controllers
{
public class RescueDeviceController : MyBaseController<RescueDeviceController>
{
private readonly IBackendRepository backendRepository;
public RescueDeviceController(IBackendRepository backendRepository)
{
this.backendRepository = backendRepository;
}
public IActionResult FireExtinguisher()
{
return View();
}
public IActionResult AED()
{
return View();
}
}
}

View File

@ -6,7 +6,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登入 | IBMS緊急應變系統</title>
<title>登入 | @ViewData["ProjectName"]緊急應變系統</title>
<!-- base css -->
<link id="vendorsbundle" rel="stylesheet" media="screen, print" href="~/css/vendors.bundle.css">
@ -30,7 +30,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-4">
<div class="page-logo-link press-scale-down d-flex align-items-center">
<img src="/img/dome.png" width="50%" aria-roledescription="logo">
<span class="page-logo-text mr-1">IBMS緊急應變系統</span>
<span class="page-logo-text mr-1">@ViewData["ProjectName"]緊急應變系統</span>
</div>
</div>
<div class="card p-4 border-top-left-radius-0 border-top-right-radius-0">