diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index e8cbc18..79fe6fb 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -447,6 +447,20 @@ namespace SolarPower.Controllers } #endregion + BackFillSchedule backFillSchedule = new BackFillSchedule() + { + UID = powerStation.Code, + DBName = powerStation.SiteDB, + TableName = "s" + powerStation.Code + "01_station" + }; + properties = new List() + { + "UID", + "DBName", + "TableName" + }; + await powerStationRepository.AddAnyThing(backFillSchedule, properties, "back_fill_schedule"); + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; apiResult.Data = await powerStationRepository.GetOneAsync(id); @@ -1110,6 +1124,22 @@ namespace SolarPower.Controllers }; await powerStationRepository.AddDevice(DeviceInfo, properties, powerStation.SiteDB); + BackFillSchedule backFillSchedule = new BackFillSchedule() + { + ColName = Device.ColName, + UID = deviceController.ControllerId + "R" + Newnum, + DBName = powerStation.SiteDB, + TableName = Device.TableName + }; + properties = new List() + { + "ColName", + "UID", + "DBName", + "TableName" + }; + await powerStationRepository.AddAnyThing(backFillSchedule, properties, "back_fill_schedule"); + apiResult.Code = "0000"; apiResult.Msg = "新增成功"; } @@ -2284,22 +2314,37 @@ namespace SolarPower.Controllers BrandNum = post.BrandNum }; List properties = new List() - { - "Status", - "Brand", - "Capacity", - "Enabled", - "Model", - "InstallDate", - "InverterName", - "Pyrheliometer", - "ControllerId", - "SerialNumber", - "CreatedBy", - "InverterId", - "BrandNum" - }; + { + "Status", + "Brand", + "Capacity", + "Enabled", + "Model", + "InstallDate", + "InverterName", + "Pyrheliometer", + "ControllerId", + "SerialNumber", + "CreatedBy", + "InverterId", + "BrandNum" + }; await powerStationRepository.AddInverter(inverter, properties, powerStation.SiteDB); + + BackFillSchedule backFillSchedule = new BackFillSchedule() + { + UID = deviceController.ControllerId + Newnum, + DBName = powerStation.SiteDB, + TableName = "s" + deviceController.ControllerId + "_inv" + }; + properties = new List() + { + "UID", + "DBName", + "TableName" + }; + await powerStationRepository.AddAnyThing(backFillSchedule, properties, "back_fill_schedule"); + apiResult.Code = "0000"; apiResult.Msg = "新增成功"; } diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 9fb9ecc..d64dd19 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -966,4 +966,12 @@ namespace SolarPower.Models.PowerStation public string BrandNum { get; set; } } + public class BackFillSchedule + { + public string DBName { get; set; } + public string TableName { get; set; } + public string ColName { get; set; } + public string UID { get; set; } + } + } diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index eb72fa6..0468504 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -33,7 +33,7 @@ namespace SolarPower.Quartz.Jobs var ExceptionList = await overviewRepository.GetEmailExceptionList(); if(ExceptionList.Count > 0 ) { - var ExceptionListex = ExceptionList.Where(x => x.normalTime == null && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Hours >= 4).ToList(); + var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Hours >= 4).ToList(); foreach (var Exception in ExceptionListex) diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index a24eae3..9c85142 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -5088,5 +5088,6 @@ namespace SolarPower.Repository.Implement return result; } } + } } diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index cd1f6b2..9b9e034 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -628,5 +628,36 @@ namespace SolarPower.Repository.Implement } return Num; } + /// + /// 新增資料 + /// + /// + /// + /// + /// + /// + public async Task AddAnyThing(A result, List properties, string tableName) + { + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + conn.Open(); + var trans = conn.BeginTransaction(); + try + { + string sql = GenerateInsertQueryWithCustomTable(properties, tableName); + await conn.ExecuteAsync(sql, result); + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } } } diff --git a/SolarPower/Repository/Interface/IRepositoryBase.cs b/SolarPower/Repository/Interface/IRepositoryBase.cs index f4371cd..183cbbf 100644 --- a/SolarPower/Repository/Interface/IRepositoryBase.cs +++ b/SolarPower/Repository/Interface/IRepositoryBase.cs @@ -111,5 +111,7 @@ namespace SolarPower.Repository.Interface /// /// Task PurgeOneByIdWithCustomDBNameAndTable(int id, string db_name, string table_name); + + Task AddAnyThing(A result, List properties, string tableName); } } diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index 5f21920..79097d0 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -460,14 +460,12 @@ } else { - - - $.each(rel.data, function (index, val) { //電站卡片 $('#templateCard').find('.col-xl-2').attr('id', 'card' + val.id).clone().appendTo($('#solarCard' + val.cityId)); $('#card' + val.id).find('#editSolarUrl').attr('href', localurl + '/edit?stationId=' + val.id); $('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', val.mainDisplay); + $('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('style', "width: 100%;height: 138px;"); $('#card' + val.id).find('#solarName').text(val.name); $('#card' + val.id).find('#today_kwh').text(val.kwh); $('#card' + val.id).find('#kwhkwp').text(val.inverterAmount); @@ -490,43 +488,6 @@ }, 'json'); } - //電站區域 - //$('#templateAreaTab').find('li').attr('id', 'AreaTabnewtaipei').clone().appendTo($('#areaTab')); - //$('#AreaTabnewtaipei').find('a').attr('href', '#tab-newtaipei'); - //$('#AreaTabnewtaipei').find('a').attr('class', 'nav-link fs-lg px-4'); - //$('#AreaTabnewtaipei').find('#areaName').html('新北市') - //$('#AreaTabnewtaipei').find('#solarCount').html('2') - - //$('#templateAreaTab').find('li').attr('id', 'AreaTabHsinchu').clone().appendTo($('#areaTab')); - //$('#AreaTabHsinchu').find('a').attr('href', '#tab-Hsinchu'); - //$('#AreaTabHsinchu').find('a').attr('class', 'nav-link fs-lg px-4'); - //$('#AreaTabHsinchu').find('#areaName').html('新竹市') - //$('#AreaTabHsinchu').find('#solarCount').html('3') - - //$('#templateAreaTab').find('li').attr('id', 'AreaTabPingtung').clone().appendTo($('#areaTab')); - //$('#AreaTabPingtung').find('a').attr('href', '#tab-Pingtung'); - //$('#AreaTabPingtung').find('a').attr('class', 'nav-link fs-lg px-4'); - //$('#AreaTabPingtung').find('#areaName').html('屏東縣') - //$('#AreaTabPingtung').find('#solarCount').html('1') - - //電站區域內容 - //$('#templateArea').find('.tab-pane').attr('id', 'tab-newtaipei').clone().appendTo($('#area')); - //$('#tab-newtaipei').attr('aria-labelledby', 'tab-newtaipei') - //$('#tab-newtaipei').find('#solarCard').attr('id', 'solarCardnewtaipei'); - //$('#tab-newtaipei').find('#solarTable').attr('id', 'solarTablenewtaipei'); - - //$('#templateArea').find('.tab-pane').attr('id', 'tab-Hsinchu').clone().appendTo($('#area')); - //$('#tab-Hsinchu').attr('aria-labelledby', 'tab-Hsinchu') - //$('#tab-Hsinchu').find('#solarCard').attr('id', 'solarCardHsinchu'); - //$('#tab-Hsinchu').find('#solarTable').attr('id', 'solarTableHsinchu'); - - //$('#templateArea').find('.tab-pane').attr('id', 'tab-Pingtung').clone().appendTo($('#area')); - //$('#tab-Pingtung').attr('aria-labelledby', 'tab-Pingtung') - //$('#tab-Pingtung').find('#solarCard').attr('id', 'solarCardPingtung'); - //$('#tab-Pingtung').find('#solarTable').attr('id', 'solarTablePingtung'); - - //電站卡片 - $('.nav-tabs a[href="#tab-newtaipei"]').tab('show'); diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index d31144d..1350648 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -2114,7 +2114,7 @@ document.getElementById('Device_Enabled_modal').disabled = true; $("#Device-modal .modal-title").html("裝置資料 - 新增"); $("#Device-form").trigger("reset"); - /*$("#Device_TableName_modal").val("s" + $("#Device_Controller_modal").text() + "_sensoravg");*/ + $("#Device_TableName_modal").val("s" + $("#Device_Controller_modal").text() + "_sensoravg"); $("#Device-modal").modal(); } //#endregion diff --git a/SolarPower/Views/PowerStation/_DeviceSetting.cshtml b/SolarPower/Views/PowerStation/_DeviceSetting.cshtml index 09e72b2..af441d2 100644 --- a/SolarPower/Views/PowerStation/_DeviceSetting.cshtml +++ b/SolarPower/Views/PowerStation/_DeviceSetting.cshtml @@ -185,7 +185,7 @@
-
@@ -259,7 +259,7 @@
-
} +
+ @Html.Partial("_InverterInfo") +
+ @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_History")) {
@@ -116,10 +120,6 @@
} -
- @Html.Partial("_InverterInfo") -
- @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Inverter")) {