diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs index 04caffd..88ca4a2 100644 --- a/SolarPower/Controllers/OperationController.cs +++ b/SolarPower/Controllers/OperationController.cs @@ -659,82 +659,83 @@ namespace SolarPower.Controllers } - if (post.WorkPersonIds != null) + if(post.Emailcheck == 1) { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - List noticeSchedules = new List(); - foreach (var person in post.WorkPersonIds) + if (post.WorkPersonIds != null) { - var fixtype = post.WorkType switch + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + List noticeSchedules = new List(); + foreach (var person in post.WorkPersonIds) + { + var fixtype = post.WorkType switch + { + 0 => "清洗", + 1 => "巡檢", + 2 => "維修", + _ => "" + }; + var user = await userRepository.GetOneAsync(person); + NoticeSchedule schedule = new NoticeSchedule() + { + EmailType = 3, + Type = 1, + UserId = person, + RecipientName = user.Name, + RecipientEmail = user.Email, + Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, + Content = "維修項目" + post.FixDo + "
注意事項 :" + post.Notice, + }; + noticeSchedules.Add(schedule); + } + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); + } + + if (post.FixFirm != 0) + { + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + var fixtype = operationRecord.WorkType switch { 0 => "清洗", 1 => "巡檢", 2 => "維修", _ => "" }; - var user = await userRepository.GetOneAsync(person); + var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); + var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); NoticeSchedule schedule = new NoticeSchedule() { EmailType = 3, Type = 1, - UserId = person, - RecipientName = user.Name, - RecipientEmail = user.Email, + RecipientName = firm.Name, + RecipientEmail = firm.Email, Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, Content = "維修項目" + post.FixDo + "
注意事項 :" + post.Notice, }; - noticeSchedules.Add(schedule); + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); } - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); } - - if (post.FixFirm != 0) - { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - var fixtype = operationRecord.WorkType switch - { - 0 => "清洗", - 1 => "巡檢", - 2 => "維修", - _ => "" - }; - var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); - var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - NoticeSchedule schedule = new NoticeSchedule() - { - EmailType = 3, - Type = 1, - RecipientName = firm.Name, - RecipientEmail = firm.Email, - Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, - Content = "維修項目" + post.FixDo + "
注意事項 :" + post.Notice, - }; - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); - } - - //using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Suppress)) //{ @@ -880,83 +881,89 @@ namespace SolarPower.Controllers } #endregion - - if (post.WorkPersonIds != null) + if (post.Emailcheck == 1) { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - List noticeSchedules = new List(); - foreach (var person in post.WorkPersonIds) + if (post.WorkPersonIds != null) { - var fixtype = operationRecord.WorkType switch + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + List noticeSchedules = new List(); + foreach (var person in post.WorkPersonIds) + { + var fixtype = operationRecord.WorkType switch + { + 0 => "清洗", + 1 => "巡檢", + 2 => "維修", + _ => "" + }; + var user = await userRepository.GetOneAsync(person); + NoticeSchedule schedule = new NoticeSchedule() + { + EmailType = 3, + Type = 1, + UserId = person, + RecipientName = user.Name, + RecipientEmail = user.Email, + Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, + Content = "維修項目:" + post.FixDo + "
注意事項 :" + post.Notice, + }; + noticeSchedules.Add(schedule); + } + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); + } + if (post.FixFirm != 0) + { + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + var fixtype = post.WorkType switch { 0 => "清洗", 1 => "巡檢", 2 => "維修", _ => "" }; - var user = await userRepository.GetOneAsync(person); + var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); + var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); NoticeSchedule schedule = new NoticeSchedule() { EmailType = 3, Type = 1, - UserId = person, - RecipientName = user.Name, - RecipientEmail = user.Email, + RecipientName = firm.Name, + RecipientEmail = firm.Email, Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, Content = "維修項目:" + post.FixDo + "
注意事項 :" + post.Notice, }; - noticeSchedules.Add(schedule); + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); + + + } - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); } - if (post.FixFirm != 0) - { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - var fixtype = post.WorkType switch - { - 0 => "清洗", - 1 => "巡檢", - 2 => "維修", - _ => "" - }; - var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); - var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - NoticeSchedule schedule = new NoticeSchedule() - { - EmailType = 3, - Type = 1, - RecipientName = firm.Name, - RecipientEmail = firm.Email, - Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, - Content = "維修項目:" + post.FixDo + "
注意事項 :" + post.Notice, - }; - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); - } + #endregion diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index f10b710..a251c26 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -293,6 +293,7 @@ namespace SolarPower.Models public string Notice { get; set; } public string Description { get; set; } public IFormFile[] RecordFiles { get; set; } + public byte Emailcheck { get; set; } } public class UpdateOperationRecord : Updated diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index a8f3d46..d592df2 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -20,7 +20,7 @@
-

即時總發電量

+

今日總發電量

0.00

@@ -36,7 +36,7 @@
-

即時日照度

+

今日日照度

0.00

@@ -279,7 +279,7 @@ '
' + '
' + '
今日發電量(kW h):' + item.today_kWh.toFixed(2) + '
'+ - '
即時日照度(k W/m2):' + item.today_irradiance + '
'+ + '
今日日照度(k W/m2):' + item.today_irradiance + '
'+ '
有效日照時數(kwh/kwp):' + item.today_kwhkwp.toFixed(2) + '
' + '
裝置容量(kWp):' + item.generatingCapacity.toFixed(3) + '
' + '
掛錶日期:' + item.electricityMeterAt + '
' + diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index a19c193..dac2a90 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -211,8 +211,13 @@
+
+
+ + +
+
-
@@ -707,7 +712,7 @@ $("#work_time_modal-error").hide(); - + $("#EmailcheckBox").prop("checked", false); $("#record-form-modal").modal(); } //#endregion @@ -1038,7 +1043,7 @@ - + $("#EmailcheckBox").prop("checked", false); $("#record-form-modal").modal(); }, 'json'); }); @@ -1057,94 +1062,87 @@ //#region 儲存表單資料 function SaveRecord() { if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "") { - Swal.fire( - { - title: "儲存", - text: "你確定是否儲存此筆資料?\r\n 儲存成功後將會發送Email至負責人員及廠商", - type: "warning", - icon: 'warning', - showCancelButton: true, - confirmButtonText: "是", - cancelButtonText: "否" - }).then(function (result) { - if (result.value) { - if ($("#record-form").valid()) { - var url = "/Operation/SaveOperationRecord"; + if ($("#record-form").valid()) + { + var url = "/Operation/SaveOperationRecord"; - var formData = new FormData(); + var formData = new FormData(); - @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { - return parseInt(item); - }) *@ + @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { + return parseInt(item); + }) *@ - formData.append("Id", selected_id); - formData.append("PowerStationId", $("#power_station_select_modal").val()); - formData.append("WorkType", selected_work_type); - formData.append("ErrorCode", $("#error_code_modal").val()); - formData.append("FixDo", $("#fix_do_modal").val()); - formData.append("FixFirm", $("#fix_firm_select_modal").val()); - formData.append("Status", $("input[name=status_modal]:checked").val()); - $("#work_person_select_modal").val().forEach(function (item) { - formData.append("WorkPersonIds", parseInt(item)); - }); - formData.append("WorkTime", $("#work_time_modal").val()); - formData.append("Notice", $("#notice_textarea_modal").val()); - formData.append("Description", $("#description_textarea_modal").val()); + formData.append("Id", selected_id); + formData.append("PowerStationId", $("#power_station_select_modal").val()); + formData.append("WorkType", selected_work_type); + formData.append("ErrorCode", $("#error_code_modal").val()); + formData.append("FixDo", $("#fix_do_modal").val()); + formData.append("FixFirm", $("#fix_firm_select_modal").val()); + formData.append("Status", $("input[name=status_modal]:checked").val()); + $("#work_person_select_modal").val().forEach(function (item) { + formData.append("WorkPersonIds", parseInt(item)); + }); + formData.append("WorkTime", $("#work_time_modal").val()); + formData.append("Notice", $("#notice_textarea_modal").val()); + formData.append("Description", $("#description_textarea_modal").val()); + if (document.querySelector('[id=EmailcheckBox]:checked')) { + formData.append("Emailcheck", 1); + } + else { + formData.append("Emailcheck", 0); + } + $.ajax({ + type: "POST", + url: url, + data: formData, + cache: false, + contentType: false, + processData: false, + success: function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - $.ajax({ - type: "POST", - url: url, - data: formData, - cache: false, - contentType: false, - processData: false, - success: function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } + var myDropzone = Dropzone.forElement("#record-file-form"); - var myDropzone = Dropzone.forElement("#record-file-form"); + if (myDropzone.files.length > 0) { - if (myDropzone.files.length > 0) { + selected_id = rel.data; - selected_id = rel.data; + myDropzone.processQueue(); - myDropzone.processQueue(); - - myDropzone.on("successmultiple", function (file, rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } - - toast_ok(rel.msg); - $('#record-form-modal').modal('hide'); - recordFileDropzone.removeAllFiles(); - if (status == 2) { - operationRecordTable.column(10).visible(true); - } - else { - operationRecordTable.column(10).visible(false); - } - operationRecordTable.ajax.reload(); - }); - } else { - $('#record-form-modal').modal('hide'); - myDropzone.removeAllFiles(); - if (status == 2) { - operationRecordTable.column(10).visible(true); - } - else { - operationRecordTable.column(10).visible(false); - } - operationRecordTable.ajax.reload(); - } + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; } + + toast_ok(rel.msg); + $('#record-form-modal').modal('hide'); + recordFileDropzone.removeAllFiles(); + if (status == 2) { + operationRecordTable.column(10).visible(true); + } + else { + operationRecordTable.column(10).visible(false); + } + operationRecordTable.ajax.reload(); }); + } else { + $('#record-form-modal').modal('hide'); + myDropzone.removeAllFiles(); + if (status == 2) { + operationRecordTable.column(10).visible(true); + } + else { + operationRecordTable.column(10).visible(false); + } + operationRecordTable.ajax.reload(); } } }); + } } else { diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index ede80d0..6f96a5e 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -94,7 +94,7 @@
-

即時日照度

+

今日日照度

0.00

diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index feba4a5..a8000df 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -951,6 +951,32 @@ $("#work_person_select_modal").val(record.workPersonId); } } + + $("#work_person_select_modal").select2({ dropdownParent: $('#record-form-modal') }); + }); + + //查詢該電站的廠商 + var url_power_station_firm = "/PowerStation/GetFirmSelectOptionList"; + + $.post(url_power_station_firm, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + + $("#fix_firm_select_modal").empty(); + if (rel.data.length > 0) { + + $.each(rel.data, function (index, val) { + $("#fix_firm_select_modal").append($("