新增頁面-系統更新通知: 新增通知系統,透過email發通知給所有運維人員
This commit is contained in:
parent
b980f61f21
commit
1d6434c987
52
SolarPower/Controllers/SystemUpdateController.cs
Normal file
52
SolarPower/Controllers/SystemUpdateController.cs
Normal file
@ -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<SystemUpdateController>
|
||||
{
|
||||
private readonly IOperationRepository operationRepository;
|
||||
|
||||
public SystemUpdateController(IOperationRepository operationRepository) : base()
|
||||
{
|
||||
this.operationRepository = operationRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> SendNotice(PostSystemUpdate post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
17
SolarPower/Models/SystemUpdate.cs
Normal file
17
SolarPower/Models/SystemUpdate.cs
Normal file
@ -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; } //信件類型
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -394,7 +394,7 @@
|
||||
</li>
|
||||
}
|
||||
|
||||
@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修改定時任務權限*@
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "7" ? "active open" : "")">
|
||||
<a href="#" title="系統管理" data-filter-tags="category">
|
||||
@ -426,6 +426,14 @@
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("SystemUpdate"))
|
||||
{
|
||||
<li class="@(ViewData["MainNum"] == "7" && ViewData["SubNum"] == "4" ? "active" : "")">
|
||||
<a asp-controller="SystemUpdate" asp-action="Index" title="系統更新管理" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">系統更新管理</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
@*@if (ViewBag.auths.Contains("User"))
|
||||
{
|
||||
<li class="">
|
||||
|
||||
127
SolarPower/Views/SystemUpdate/Index.cshtml
Normal file
127
SolarPower/Views/SystemUpdate/Index.cshtml
Normal file
@ -0,0 +1,127 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "7";
|
||||
ViewData["SubNum"] = "4";
|
||||
ViewData["Title"] = "系統更新管理";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@model RoleLayerEnum
|
||||
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">系統管理</a></li>
|
||||
<li class="breadcrumb-item active">@ViewData["Title"]</li>
|
||||
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
|
||||
</ol>
|
||||
|
||||
<div class="subheader">
|
||||
<h1 class="subheader-title">
|
||||
<i class='subheader-icon fal fa-globe'></i> @ViewData["Title"]
|
||||
</h1>
|
||||
</div>
|
||||
<!-- Your main content goes below here: -->
|
||||
|
||||
<div class="d-flex justify-content-center text-secondary" style="top: 10%; transform: translateY(50%); z-index: 100; position: relative;">
|
||||
<div class="spinner-border" role="status" style="width: 3rem; height: 3rem; display:none;" id="loading"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div id="panel-5" class="panel">
|
||||
<div class="panel-container show">
|
||||
<div class="panel-content">
|
||||
@*只有平台人員可以新增公司*@
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
|
||||
{
|
||||
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddNotice()">
|
||||
<span class="fal fa-plus mr-1"></span>
|
||||
新增通知
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="SystemUpdateNotice-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
系統更新通知 - 新增
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="SystemUpdateNotice-form" id="SystemUpdateNotice-form">
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Subject_modal"><span class="text-danger">*</span>主旨</label>
|
||||
<input type="text" id="Subject_modal" name="Subject_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Content_modal"><span class="text-danger">*</span>通知內容</label>
|
||||
<input type="text" id="Content_modal" name="Content_modal" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SendNotice()">送出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
//#region 新增 系統更新通知
|
||||
function AddNotice() {
|
||||
$("#SystemUpdateNotice-modal .modal-title").html("系統更新通知 - 新增");
|
||||
$("#SystemUpdateNotice-form").trigger("reset");
|
||||
$("#SystemUpdateNotice-modal").modal();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
function showLoading() {
|
||||
var i = document.getElementById("loading");
|
||||
i.style.display = "block";
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
var i = document.getElementById("loading");
|
||||
i.style.display = "none";
|
||||
}
|
||||
|
||||
//#region 送出通知
|
||||
function SendNotice() {
|
||||
showLoading();
|
||||
var url = "/SystemUpdate/SendNotice";
|
||||
if ($("#SystemUpdateNotice-form").valid()) {
|
||||
var send_data = {
|
||||
Subject: $("#Subject_modal").val(),
|
||||
Content: $("#Content_modal").val(),
|
||||
EmailType: 5
|
||||
}
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
hideLoading();
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
hideLoading();
|
||||
toast_ok(rel.msg);
|
||||
$('#SystemUpdateNotice-modal').modal('hide');
|
||||
return;
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
</script>
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user