Merge branch 'master' into Willy

This commit is contained in:
b110212000 2021-06-28 15:39:03 +08:00
commit e04cdfe65f
19 changed files with 200 additions and 48 deletions

View File

@ -144,7 +144,7 @@ namespace SolarPower.Controllers
UpdatePassword update = new UpdatePassword()
{
Password = edFunction.GetSHA256Encryption(newPassword),
Password = newPassword,
UpdatedBy = user.Id,
Id = user.Id
};

View File

@ -334,11 +334,6 @@ namespace SolarPower.Controllers
try
{
//if (!IsPlatformLayer(myUser.Role.Layer))
//{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
// post.SelectedCompanyId = myUser.CompanyId;
//}
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
foreach (var recode in recodes)

View File

@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
using SolarPower.Models;
using SolarPower.Models.User;
using SolarPower.Repository.Interface;
using SolarPower.Services.Interface;
using System;
using System.Collections.Generic;
using System.Data;
@ -20,10 +21,13 @@ namespace SolarPower.Controllers
{
private readonly IUserRepository userRepository;
private readonly ISendEmailService sendEmailService;
private string logoPath = "/upload/company_logo/";
public UserController(IUserRepository userRepository) : base()
public UserController(IUserRepository userRepository,
ISendEmailService sendEmailService) : base()
{
this.userRepository = userRepository;
this.sendEmailService = sendEmailService;
}
public IActionResult Index()
@ -299,8 +303,7 @@ namespace SolarPower.Controllers
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
string random_password = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(chars.Length)]).ToArray());
//TODO 新增的密碼要寄信
random_password = edFunction.GetSHA256Encryption(random_password);
var newPassword = edFunction.GetSHA256Encryption(random_password);
user = new User()
{
@ -308,7 +311,7 @@ namespace SolarPower.Controllers
Name = post.Name,
Email = post.Email,
Account = post.Account,
Password = random_password,
Password = newPassword,
RoleId = post.RoleId,
Phone = post.Phone,
CreatedBy = myUser.Id,
@ -328,6 +331,16 @@ namespace SolarPower.Controllers
await userRepository.AddAsync(user, properties);
var sendSubject = "新增帳號成功";
var sendContent = $"您的新密碼為:{random_password}";
List<string> recipientEmails = new List<string>()
{
user.Email
};
sendEmailService.Send(recipientEmails, sendSubject, sendContent);
apiResult.Code = "0000";
apiResult.Msg = "儲存成功";
#endregion

View File

@ -32,12 +32,13 @@ namespace SolarPower.Helper
EDFunction ed = new EDFunction();
var serverStr = ed.AESDecrypt(dbConfig.Server);
var portStr = ed.AESDecrypt(dbConfig.Port);
var databaseStr = ed.AESDecrypt(dbConfig.Database);
var rootStr = ed.AESDecrypt(dbConfig.Root);
var passwordStr = ed.AESDecrypt(dbConfig.Password);
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
var connStr = @"server=210.61.91.43;port=10068;database=solar_power_test;user=idafenweb;password=P@ssw0rd;charset=utf8;";
var connStr = $"server={serverStr};port={portStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
//var connStr = @"server=210.61.91.43;port=10068;database=solar_power_test;user=idafenweb;password=P@ssw0rd;charset=utf8;";
this._connectionString = connStr;
}

View File

@ -8,6 +8,7 @@ namespace SolarPower.Models
public class DBConfig
{
public string Server { get; set; }
public string Port { get; set; }
public string Database { get; set; }
public string Root { get; set; }
public string Password { get; set; }

View File

@ -212,6 +212,8 @@ namespace SolarPower.Models
public List<int> PowerStationIds { get; set; } //電站編號
public byte WorkType { get; set; } //工作項目
public string Range { get; set; } //取得搜尋範圍
public string StartTime { get; set; } //起始日期
public string EndTime { get; set; } //結束日期
}
/// <summary>

View File

@ -215,15 +215,19 @@ namespace SolarPower.Repository.Implement
WHERE opr.Deleted = 0
AND ps.Id IN @PowerStationIds";
if (!string.IsNullOrEmpty(filter.Range))
{
filter.StartTime = filter.Range.Split('-')[0];
filter.EndTime = filter.Range.Split('-')[1];
sql += " AND opr.StartTime <= @EndDate";
sql += " AND opr.EndTime >= @StartDate";
}
if (filter.WorkType > 0)
{
filter.WorkType -= 1;
sql += @" AND opr.WorkType = @WorkType";
if (!string.IsNullOrEmpty(filter.Range))
{
}
}
else
{
@ -239,9 +243,33 @@ namespace SolarPower.Repository.Implement
WHERE opr.Deleted = 0
AND ps.Id IN @PowerStationIds
AND opr.WorkType = 2";
if (!string.IsNullOrEmpty(filter.Range))
{
filter.StartTime = filter.Range.Split('-')[0];
filter.EndTime = filter.Range.Split('-')[1];
sql += " AND opr.StartTime <= @EndDate";
sql += " AND opr.EndTime >= @StartDate";
}
else
{
var today = DateTime.Now.ToString("yyyy-MM-dd");
var dateLimit = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");
sql += $" AND opr.CreatedAt BETWEEN '{dateLimit} 00:00:00' AND '{today} 23:59:59'";
//sql += $" AND opr.StartTime <= {today}";
//sql += $" AND opr.EndTime >= {dateLimit}";
}
}
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql, filter)).ToList();
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql,
new {
PowerStationIds = filter.PowerStationIds,
WorkType = filter.WorkType,
StartDate = filter.StartTime,
EndDate = filter.EndTime
})).ToList();
var sql_file = "SELECT * FROM operation_record_file WHERE Deleted = 0 AND RecordId = @RecordId";
foreach (var x in result)

View File

@ -34,6 +34,7 @@ namespace SolarPower
Configuration = configuration;
dBConfig.Server = Configuration.GetValue<string>("DBConfig:Server");
dBConfig.Port = Configuration.GetValue<string>("DBConfig:Port");
dBConfig.Database = Configuration.GetValue<string>("DBConfig:Database");
dBConfig.Root = Configuration.GetValue<string>("DBConfig:Root");
dBConfig.Password = Configuration.GetValue<string>("DBConfig:Password");

View File

@ -29,11 +29,11 @@
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">近30天</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeDate30()">近30天</button>
</div>
<div class="pr-3">
<div class="form-group">
<input class="form-control" id="example-date" type="text" name="date" value="2023-07-23">
<input class="form-control" id="date-range" type="text" name="date" value="">
</div>
</div>
</div>
@ -204,7 +204,7 @@
<p>檔案上傳</p>
</div>
<div id="recode_files_div" class="col-10">
<div class="row align-items-center"></div>
<div class="row align-items-center img-zoom-div"></div>
</div>
</div>
<div class="row px-3">
@ -241,6 +241,7 @@
var Allids = new Array(0);//全部縣市
var Allpowerids = new Array(0);//全部電站
var Type = 0; // 項目
var datepicker;
//#region Array.Remove
Array.prototype.remove = function (val) {
@ -252,14 +253,28 @@
//#endregion
$(function () {
$('input[id="example-date"]').daterangepicker({
//#region Date Picker
datepicker = $('#date-range').daterangepicker({
autoUpdateInput: false,
locale: { format: 'YYYY/MM/DD' },
opens: 'left'
}, function (start, end, label) {
console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
@*console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));*@
});
$('#date-range').on('apply.daterangepicker', function (ev, picker) {
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
$(this).trigger('change');
});
$('#date-range').on('cancel.daterangepicker', function (ev, picker) {
$(this).val('');
$(this).trigger('change');
});
//#endregion
//#region 預設載入該使用者可以選擇的電站
//#region 載入縣市
var Nurl = "/PowerStation/GetSolarCitySummary";
$.post(Nurl, function (rel) {
if (rel.code != "0000") {
@ -306,7 +321,6 @@
})
})
//#endregion
//#endregion
//#region 切換電站時,載入該電站運維人員
$("#power_station_select_modal").change(function () {
@ -373,7 +387,7 @@
'targets': 7,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'className': 'dt-body-center img-zoom-div',
'createdCell': function (td, cellData, rowData, row, col) {
$(td).empty();
$(td).append('<div class="row"></div>');
@ -417,7 +431,7 @@
"data": function (d) {
d.PowerStationIds = powerids;
d.WorkType = Type;
d.Range = $('#company_taxIDNumber').val();
d.Range = $('#date-range').val();
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
@ -453,6 +467,12 @@
}
//#endregion
//#region 改變日期
$('#date-range').on('change', function () {
operationRecodeTable.ajax.reload();
});
//#endregion
//#region 新增維修單
function AddRecode() {
selected_id = 0;
@ -581,6 +601,13 @@
OperationPlanTable.ajax.reload();
})
//#endregion
//#region 點擊圖片放大
$('#operation_recode_table').on("click", "img.img-zoom", function () {
var _this = $(this);//將當前的pimg元素作為_this傳入函式
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
});
//#endregion
//#region 編輯表單內容
@ -652,6 +679,7 @@
});
//#endregion
//#region 表單驗證
$("#recode-form").validate({
rules: {
@ -788,7 +816,7 @@
} else if (word_format.indexOf(split[split.length - 1].toLowerCase()) > -1) {
str += '<a href="' + value.fileName + '" class="btn btn-info waves-effect waves-themed mb-3 mr-2" download><i class="fal fa-file-word"></i></a>';
} else {
str += '<img src="' + value.fileName + '" width="100%"/>';
str += '<img src="' + value.fileName + '" class="img-zoom" width="100%" />';
}
str += '</div>';
dom.append(str);
@ -852,5 +880,21 @@
}, 'json');
}
//#endregion
//#region 查詢近30天
function ChangeDate30() {
var today = new Date();
var dateLimit = new Date(new Date().setDate(today.getDate() - 30));
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
datepicker.data('daterangepicker').setEndDate(today_format);
$('#date-range').val(dateLimit_format + ' - ' + today_format);
$('#date-range').trigger('change');
}
//#endregion
</script>
}

View File

@ -581,7 +581,7 @@
powerStationSingleLineCard = $("#power-station-image-card > .row");
powerStationSingleLineCard.empty();
rel.data.forEach(function (value, index) {
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
CreatePowerStationImageBox(powerStationSingleLineCard, value);
});
}, 'json');
@ -2015,7 +2015,7 @@
function CreatePowerStationImageBox(dom, value) {
var str = '<div class="col-xl">' +
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
'<img src="' + value.image + '" class="card-img-top" alt="...">' +
'<img src="' + value.image + '" class="card-img-top img-zoom" alt="...">' +
'<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right del-power-station-image-btn" data-id="' + value.id + '">' +
'<i class="fal fa-times"></i>' +
'</a>' +

View File

@ -37,7 +37,7 @@
</a>
</div>
</div>
<div class="card-body" id="power-station-image-card">
<div class="card-body">
<div class="w-100">
<table id="Inverter_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
@ -66,7 +66,7 @@
</a>
</div>
</div>
<div class="card-body" id="power-station-image-card">
<div class="card-body">
<div class="w-100">
<table id="Device_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">
@ -101,7 +101,7 @@
</a>
</div>
</div>
<div class="card-body" id="power-station-image-card">
<div class="card-body">
<div class="w-100">
<table id="ShareDevice_table" class="table table-bordered table-hover m-0 text-center">
<thead class="thead-themed">

View File

@ -11,7 +11,7 @@
</div>
</div>
<div class="card-body" id="power-station-image-card">
<div class="row d-flex justify-content-between">
<div class="row d-flex justify-content-between img-zoom-div">
</div>
</div>

View File

@ -1094,6 +1094,13 @@
</div>
</div>
<!-- /.變更密碼 -->
<!-- Image Zoom Outer Div -->
<div id="img-zoom-outer-div" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:9999;width:100%;height:100%; overflow-y:scroll;display:none;">
<div id="innerdiv" style="position:absolute; top: 50%; left: 50%; transform:translate(-50%,-50%);width:1440px;">
<img id="bigimg" style="border:5px solid #fff;" width="100%" src="" />
</div>
</div>
<!--Base JS-->
<script src="~/js/vendors.bundle.js"></script>
<script src="~/js/app.bundle.js"></script>
@ -1116,11 +1123,11 @@
<script src="~/js/jquery.table2excel.min.js"></script>
<!-- Custome JS -->
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/js/image.zoom.js" asp-append-version="true"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<!--<script src="~/js/daterangepicker.js"></script>-->
@*各頁面的JavaScript*@
@RenderSection("Scripts", required: false)
</body>

View File

@ -9,6 +9,7 @@
"LoginExpireMinute": 60, //()
"DBConfig": {
"Server": "LPp7aTdHGEFQJieGkSGl0g==",
"Port": "CY1x+1WYXRCBab3wKnBCOQ==",
"Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
"Root": "mWlR2HshQNhRRE34jg4kdg==",
"Password": "y4uPqlH9ncTgR/I07qpwaA=="

View File

@ -9,10 +9,11 @@
"AllowedHosts": "*",
"LoginExpireMinute": 60, //()
"DBConfig": {
"Server": "LPp7aTdHGEFQJieGkSGl0g==",
"Database": "k48iBBWXwJHPZF9zkF8UjreGN2uYWz6R",
"Root": "2TdWJL+VXK8xbnhD8iA0zNJMT95nSE5W",
"Password": "BxXjVEJCYCyPmlt03xAKmUNEnXzHhw1j"
"Server": "MVgHWzR3rGDgD57TUoFunA==",
"port": "r4AoXMUDodcQjIzofGNCcg==",
"Database": "Lxlx7Hae506yu/zopo2npw==",
"Root": "mWlR2HshQNhRRE34jg4kdg==",
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
},
"SMTPConfig": {
"Host": "smtp.gmail.com",

View File

@ -0,0 +1,53 @@
(function () {
});
$(".img-zoom-div").on("click", "img.img-zoom", function () {
var _this = $(this);//將當前的pimg元素作為_this傳入函式
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
});
function imgShow(outerdiv, innerdiv, bigimg, _this) {
var src = _this.attr("src");//獲取當前點選的pimg元素中的src屬性
$(bigimg).attr("src", src);//設定#bigimg元素的src屬性
$("body").css({ "position": "sticky", "overflow": "hidden" });
$(outerdiv).fadeIn("fast");//淡入顯示#outerdiv及.pimg
///*獲取當前點選圖片的真實大小,並顯示彈出層及大圖*/
//$(_this).attr("src", src).on("load", function () {
// var windowW = $(window).width();//獲取當前視窗寬度
// var windowH = $(window).height();//獲取當前視窗高度
// var realWidth = this.width;//獲取圖片真實寬度
// var realHeight = this.height;//獲取圖片真實高度
// var imgWidth, imgHeight;
// //var scale = 0.8;//縮放尺寸,當圖片真實寬度和高度大於視窗寬度和高度時進行縮放
// var scale = 1440 / realWidth; //放大圖片到1440p
// if (realHeight > windowH * scale) {//判斷圖片高度
// imgHeight = windowH * scale;//如大於視窗高度,圖片高度進行縮放
// imgWidth = imgHeight / realHeight * realWidth;//等比例縮放寬度
// if (imgWidth > windowW * scale) {//如寬度扔大於視窗寬度
// imgWidth = windowW * scale;//再對寬度進行縮放
// }
// } else if (realWidth > windowW * scale) {//如圖片高度合適,判斷圖片寬度
// imgWidth = windowW * scale;//如大於視窗寬度,圖片寬度進行縮放
// imgHeight = imgWidth / realWidth * realHeight;//等比例縮放高度
// } else {//如果圖片真實高度和寬度都符合要求,高寬不變
// imgWidth = realWidth * scale;
// imgHeight = realHeight * scale;
// }
// $(bigimg).css("width", imgWidth);//以最終的寬度對圖片縮放
// var w = (windowW - imgWidth) / 2;//計算圖片與視窗左邊距
// var h = (windowH - imgHeight) / 2;//計算圖片與視窗上邊距
// $(innerdiv).css({ "top": h, "left": w });//設定#innerdiv的top和left屬性
// $(outerdiv).fadeIn("fast");//淡入顯示#outerdiv及.pimg
//});
$(outerdiv).click(function () {//再次點選淡出消失彈出層
$(this).fadeOut("fast");
$("body").css({ "position": "static", "overflow": "auto" });
});
}

View File

@ -123,6 +123,7 @@ function ChangePassword() {
$.post(url, send_data, function (rel) {
if (rel.code == "9999") {
toast_error(rel.msg);
return;
}
else if (rel.code == "9998") {
toast_error(rel.msg);
@ -130,6 +131,10 @@ function ChangePassword() {
setTimeout(function () {
location.href = "/Login/Logout";
}, 5000)
return;
} else if (rel.code == "0001") {
toast_error(rel.msg);
return;
}
toast_ok(rel.msg);

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B