From 1d6434c987145acf2d3e8f4aea3e79f426bd0b6b Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Thu, 28 Jul 2022 09:37:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A0=81=E9=9D=A2-=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1=E6=9B=B4=E6=96=B0=E9=80=9A=E7=9F=A5:=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=80=9A=E7=9F=A5=E7=B3=BB=E7=B5=B1=EF=BC=8C=E9=80=8F?= =?UTF-8?q?=E9=81=8Eemail=E7=99=BC=E9=80=9A=E7=9F=A5=E7=B5=A6=E6=89=80?= =?UTF-8?q?=E6=9C=89=E9=81=8B=E7=B6=AD=E4=BA=BA=E5=93=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SystemUpdateController.cs | 52 +++++++ SolarPower/Models/SystemUpdate.cs | 17 +++ SolarPower/Views/Shared/_Layout.cshtml | 10 +- SolarPower/Views/SystemUpdate/Index.cshtml | 127 ++++++++++++++++++ 4 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 SolarPower/Controllers/SystemUpdateController.cs create mode 100644 SolarPower/Models/SystemUpdate.cs create mode 100644 SolarPower/Views/SystemUpdate/Index.cshtml diff --git a/SolarPower/Controllers/SystemUpdateController.cs b/SolarPower/Controllers/SystemUpdateController.cs new file mode 100644 index 0000000..4afaad7 --- /dev/null +++ b/SolarPower/Controllers/SystemUpdateController.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; +using SolarPower.Repository.Interface; +using SolarPower.Models; +using Microsoft.Extensions.Logging; +using SolarPower.Models.SystemUpdate; + +namespace SolarPower.Controllers +{ + public class SystemUpdateController : MyBaseController + { + private readonly IOperationRepository operationRepository; + + public SystemUpdateController(IOperationRepository operationRepository) : base() + { + this.operationRepository = operationRepository; + } + + public IActionResult Index() + { + return View(); + } + + [HttpPost] + public async Task> SendNotice(PostSystemUpdate post) + { + ApiResult apiResult = new ApiResult(); + #region 更新通知 加入NoticeSchedule + try + { + var people = await operationRepository.GetAllOperations(); + await operationRepository.InsertNoticeSchedule(people, post.Subject, post.Content, post.EmailType); + //sendEmailService.Send(recipientEmails, sendSubject, sendContent);//直接寄信 沒有紀錄 + apiResult.Code = "0000"; + apiResult.Msg = "已發送到通知行程"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + #endregion + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + + + } +} diff --git a/SolarPower/Models/SystemUpdate.cs b/SolarPower/Models/SystemUpdate.cs new file mode 100644 index 0000000..a697644 --- /dev/null +++ b/SolarPower/Models/SystemUpdate.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Models.SystemUpdate +{ + public class PostSystemUpdate + { + public string Subject { get; set; } //主旨 + public string Content { get; set; } //內容 + public int EmailType { get; set; } //信件類型 + + } + +} diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 809dced..5c1243a 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -394,7 +394,7 @@ } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Company") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("Role") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("SensorType"))@*TODO修改定時任務權限*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Company") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("Role") || ViewBag.auths.Contains("User") || ViewBag.auths.Contains("SensorType") || ViewBag.auths.Contains("SystemUpdate"))@*TODO修改定時任務權限*@ {
  • @@ -426,6 +426,14 @@
  • } + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("SystemUpdate")) + { +
  • + + 系統更新管理 + +
  • + } @*@if (ViewBag.auths.Contains("User")) {
  • diff --git a/SolarPower/Views/SystemUpdate/Index.cshtml b/SolarPower/Views/SystemUpdate/Index.cshtml new file mode 100644 index 0000000..328201f --- /dev/null +++ b/SolarPower/Views/SystemUpdate/Index.cshtml @@ -0,0 +1,127 @@ +@{ + ViewData["MainNum"] = "7"; + ViewData["SubNum"] = "4"; + ViewData["Title"] = "系統更新管理"; +} +@using SolarPower.Models.Role +@model RoleLayerEnum + + + +
    +

    + @ViewData["Title"] +

    +
    + + +
    + +
    + +
    +
    +
    +
    +
    + @*只有平台人員可以新增公司*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) + { + + } +
    +
    +
    +
    +
    + + + +@section Scripts { + +} \ No newline at end of file