From 8f76245a137573785db67533558a94f9aee8c356 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 19 Aug 2021 18:53:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=20google=20map=20=E4=BF=AE=E6=94=B9=202.=20?= =?UTF-8?q?=E5=AF=84=E4=BF=A1=E4=BA=BA=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/MyBaseController.cs | 22 ++++++++++++++----- SolarPower/Controllers/RoleController.cs | 2 +- SolarPower/Quartz/Jobs/SendEmailJob.cs | 4 ++-- .../Implement/OverviewRepository.cs | 12 ++++++---- .../Services/Implement/SendEmailService.cs | 4 +++- SolarPower/Views/MapOverview/Index.cshtml | 12 +++++++++- SolarPower/appsettings.Development.json | 13 ++++++++--- SolarPower/appsettings.json | 6 ++--- 8 files changed, 55 insertions(+), 20 deletions(-) diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index b728aaf..5a469f7 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -92,19 +92,31 @@ namespace SolarPower.Controllers var per_auch_arr = auth.Split(','); foreach (var x in per_auch_arr) { + if (x.Contains("PowerStation")) + { + auth_arr.Add("PowerStation"); + } + auth_arr.Add(x); } } if (myUser.Role.Layer != (int)RoleLayerEnum.PlatformAdmin && !auth_arr.Contains(controllerName)) { - filterContext.Result = new RedirectToRouteResult( - new RouteValueDictionary - { + if(auth_arr.Contains("StationOverview") && !auth_arr.Contains("PowerStation")) + { + //只有電站總覽 且未包含 電站管理 + } + else + { + filterContext.Result = new RedirectToRouteResult( + new RouteValueDictionary + { {"controller", "Login"}, {"action", "SignOut"} - }); - return; + }); + return; + } } diff --git a/SolarPower/Controllers/RoleController.cs b/SolarPower/Controllers/RoleController.cs index 704789f..3b7fcc3 100644 --- a/SolarPower/Controllers/RoleController.cs +++ b/SolarPower/Controllers/RoleController.cs @@ -210,7 +210,7 @@ namespace SolarPower.Controllers List roleAuths = new List(); RoleAuth roleAuth = new RoleAuth(); - roleAuth.Id = role.Id; + roleAuth.Id = id; roleAuth.AuthCode = "A"; roleAuth.CreatedBy = myUser.Id; diff --git a/SolarPower/Quartz/Jobs/SendEmailJob.cs b/SolarPower/Quartz/Jobs/SendEmailJob.cs index 3808b40..71a356e 100644 --- a/SolarPower/Quartz/Jobs/SendEmailJob.cs +++ b/SolarPower/Quartz/Jobs/SendEmailJob.cs @@ -102,8 +102,8 @@ namespace SolarPower.Quartz.Jobs MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼 MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼 MyMail.IsBodyHtml = true; //是否使用html格式 - - MyMail.From = new System.Net.Mail.MailAddress(smtp.UserName); //寄件人 + var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>"; + MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人 foreach (var email in recipientEmails) { MyMail.To.Add(email); //設定收件者Email diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 964199d..708d96b 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -463,7 +463,8 @@ namespace SolarPower.Repository.Implement inv.KWH FROM inverter_history_hour inv WHERE inv.PowerStationId = @PowerStationId - AND DATE_FORMAT(inv.timestamp, '%Y-%m-%d') = @Day"; + AND DATE_FORMAT(inv.timestamp, '%Y-%m-%d') = @Day + ORDER BY inv.TIMESTAMP"; result = (await conn.QueryAsync(sql_power, new { PowerStationId = powerStationId, Day = day })).ToList(); } @@ -487,7 +488,8 @@ namespace SolarPower.Repository.Implement inv.KWH FROM inverter_history_day inv WHERE inv.PowerStationId = @PowerStationId - AND DATE_FORMAT(inv.timestamp, '%Y-%m') = @Month"; + AND DATE_FORMAT(inv.timestamp, '%Y-%m') = @Month + ORDER BY inv.TIMESTAMP"; result = (await conn.QueryAsync(sql_power, new { PowerStationId = powerStationId, Month = month })).ToList(); } @@ -511,7 +513,8 @@ namespace SolarPower.Repository.Implement inv.KWH FROM inverter_history_month inv WHERE inv.PowerStationId = @PowerStationId - AND DATE_FORMAT(inv.timestamp, '%Y-%m') BETWEEN @StartMonth AND @EndMonth"; + AND DATE_FORMAT(inv.timestamp, '%Y-%m') BETWEEN @StartMonth AND @EndMonth + ORDER BY inv.TIMESTAMP"; result = (await conn.QueryAsync(sql_power, new { PowerStationId = powerStationId, StartMonth = startMonth, EndMonth = endMonth })).ToList(); } @@ -535,7 +538,8 @@ namespace SolarPower.Repository.Implement inv.KWH FROM inverter_history_month inv WHERE inv.PowerStationId = @PowerStationId - AND DATE_FORMAT(inv.timestamp, '%Y') = @Year"; + AND DATE_FORMAT(inv.timestamp, '%Y') = @Year + ORDER BY inv.TIMESTAMP"; result = (await conn.QueryAsync(sql_power, new { PowerStationId = powerStationId, Year = year })).ToList(); } diff --git a/SolarPower/Services/Implement/SendEmailService.cs b/SolarPower/Services/Implement/SendEmailService.cs index b91ca88..397ad4f 100644 --- a/SolarPower/Services/Implement/SendEmailService.cs +++ b/SolarPower/Services/Implement/SendEmailService.cs @@ -28,7 +28,9 @@ namespace SolarPower.Services MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼 MyMail.IsBodyHtml = true; //是否使用html格式 - MyMail.From = new System.Net.Mail.MailAddress(smtp.UserName); //寄件人 + var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>"; + + MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人 foreach(var email in recipientEmails) { MyMail.To.Add(email); //設定收件者Email diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 789fb5d..47e16b8 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -260,7 +260,11 @@ mapOverview.powerStations.forEach(function (item, index) { var contentString = '
' + '
' + - '

' + item.name + '

' + + '

' + + '' + + item.name + + '' + + '

' + '
' + '
' + '
' + @@ -309,6 +313,12 @@ google.maps.event.addListener(marker, 'click', (function (marker, i) { return function () { infowindow.setContent(location[1]); + + google.maps.event.addListener(infowindow, 'domready', function () { + $(document).find('#content').parent().css('overflow-x', 'hidden'); + + }); + infowindow.open(map, marker); } })(marker, i)); diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index ff5776a..2c8090f 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -23,10 +23,10 @@ //}, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", - "CalcAvgPowerStationJob": "0 0 2 * * ?", + "CalcAvgPowerStationJob": "0/10 * * * * ?", "OperationScheduleJob": "0 0 2 * * ?", "CalcInverter15minJob": "0 2/15 * * * ?", - "SendEmailJob": "0 15 2 * * ?", + "SendEmailJob": "0/10 * * * * ?", "ExceptionSchedule": "0 0/5 * * * ?" }, "SMTPConfig": { @@ -35,5 +35,12 @@ "UserName": "shanghohui@gmail.com", "Password": "wswgnluvoodfexrb", "EnableSsl": true - } + }, + //"SMTPConfig": { + // "Host": "smtp.gmail.com", + // "Port": 25, + // "UserName": "ficgreen01@gmail.com", + // "Password": "qwe2015qwe", + // "EnableSsl": true + //} } diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index 40e4a29..f01e034 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -27,14 +27,14 @@ "CalcAvgPowerStationJob": "0 0 2 * * ?", "OperationScheduleJob": "0 0 2 * * ?", "CalcInverter15minJob": "0 2/15 * * * ?", - "SendEmailJob": "0 15 2 * * ?", + "SendEmailJob": "0 0/5 * * * ?", "ExceptionSchedule": "0 0/5 * * * ?" }, "SMTPConfig": { "Host": "smtp.gmail.com", "Port": 25, - "UserName": "shanghohui@gmail.com", - "Password": "wswgnluvoodfexrb", + "UserName": "ficgreen01@gmail.com", + "Password": "qwe2015qwe", "EnableSsl": true } }