diff --git a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs index 9d94efb..bde63d4 100644 --- a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs @@ -786,114 +786,114 @@ namespace SolarPower.Quartz.Jobs } #endregion // end from here - #region 補償機制 - var gobackDay = this.Configuration.GetValue("GoBackDay"); //回推天數 - var Connection_string = Configuration.GetValue("mySql"); - var start_date = DateTimeNow.AddDays(-1 * gobackDay); - var end_date = DateTimeNow.AddDays(-1); - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】"); - procSensorSvc sensorSvc = new procSensorSvc(Connection_string); - procInvSvc invSvc = new procInvSvc(Connection_string, logger); - procStationSvc siteSvc = new procStationSvc(Connection_string); - foreach (var powerStation in powerStations) - { - start_date = DateTimeNow.AddDays(-1 * gobackDay); - for (; start_date <= end_date; start_date = start_date.AddDays(1)) - { - var day_str = start_date.ToString("yyyy-MM-dd"); - #region 歸檔 Sensor - try - { - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); - sensorSvc.archiveData(powerStation.Code, day_str); - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); - } - catch (Exception exception) - { - logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); - logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - if (exception.InnerException != null) - { - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); - } - } - #endregion + //#region 補償機制 + //var gobackDay = this.Configuration.GetValue("GoBackDay"); //回推天數 + //var Connection_string = Configuration.GetValue("mySql"); + //var start_date = DateTimeNow.AddDays(-1 * gobackDay); + //var end_date = DateTimeNow.AddDays(-1); + //logger.LogInformation("【CalcAvgPowerStationJob】【開始執行補償機制】"); + //procSensorSvc sensorSvc = new procSensorSvc(Connection_string); + //procInvSvc invSvc = new procInvSvc(Connection_string, logger); + //procStationSvc siteSvc = new procStationSvc(Connection_string); + //foreach (var powerStation in powerStations) + //{ + // start_date = DateTimeNow.AddDays(-1 * gobackDay); + // for (; start_date <= end_date; start_date = start_date.AddDays(1)) + // { + // var day_str = start_date.ToString("yyyy-MM-dd"); + // #region 歸檔 Sensor + // try + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); + // sensorSvc.archiveData(powerStation.Code, day_str); + // logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); + // } + // catch (Exception exception) + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str); + // logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + // if (exception.InnerException != null) + // { + // logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + // } + // } + // #endregion - #region 歸檔 電錶 - try - { - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); - sensorSvc.archiveMeterData(powerStation.Code, day_str); - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); - } - catch (Exception exception) - { - logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); - logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - if (exception.InnerException != null) - { - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); - } - } - #endregion + // #region 歸檔 電錶 + // try + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); + // sensorSvc.archiveMeterData(powerStation.Code, day_str); + // logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); + // } + // catch (Exception exception) + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str); + // logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + // if (exception.InnerException != null) + // { + // logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + // } + // } + // #endregion - #region 歸檔 Inv - try - { - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); - invSvc.archiveData(powerStation.Code, day_str); - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); - } - catch (Exception exception) - { - logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); - logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - if (exception.InnerException != null) - { - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); - } - } - #endregion + // #region 歸檔 Inv + // try + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); + // invSvc.archiveData(powerStation.Code, day_str); + // logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); + // } + // catch (Exception exception) + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str); + // logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + // if (exception.InnerException != null) + // { + // logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + // } + // } + // #endregion - #region 歸檔 Station hour - try - { - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); - siteSvc.archiveData(powerStation.Code, day_str); - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); - } - catch (Exception exception) - { - logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); - logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - if (exception.InnerException != null) - { - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); - } - } - #endregion + // #region 歸檔 Station hour + // try + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); + // siteSvc.archiveData(powerStation.Code, day_str); + // logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); + // } + // catch (Exception exception) + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str); + // logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + // if (exception.InnerException != null) + // { + // logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + // } + // } + // #endregion - #region 製作日報表 - try - { - logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); - invSvc.report_invDay(powerStation.Code, day_str); - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); - } - catch (Exception exception) - { - logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); - logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); - if (exception.InnerException != null) - { - logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); - } - } - #endregion - } - } - logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】"); - #endregion + // #region 製作日報表 + // try + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); + // invSvc.report_invDay(powerStation.Code, day_str); + // logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); + // } + // catch (Exception exception) + // { + // logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str); + // logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + // if (exception.InnerException != null) + // { + // logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); + // } + // } + // #endregion + // } + //} + //logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】"); + //#endregion diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 797a454..b19a634 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -53,8 +53,7 @@ namespace SolarPower.Quartz.Jobs x.priority == 2 && (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority2).ToList(); - var ExceptionListex3 = ExceptionList.Where(x => x.sourceState == 1 && - x.priority == 3 && + var ExceptionListex3 = ExceptionList.Where(x => x.priority == 3 && (DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority3).ToList(); ExceptionListex.AddRange(ExceptionListex2); ExceptionListex.AddRange(ExceptionListex3); @@ -63,24 +62,37 @@ namespace SolarPower.Quartz.Jobs { var UserListWithPowerstation = await overviewRepository.GetUserListWithPowerstation(Exception.PowerStationId); - var Content = $"電站名稱:{Exception.PowerStationName}" + "
" + - $"設備編號:{Exception.errDevice}" + "
" + - $"異常ID編號:{Exception.id}" + "
" + + //var Content = $"電站名稱:{Exception.PowerStationName}" + "
" + + // $"設備編號:{Exception.errDevice}" + "
" + + // $"異常ID編號:{Exception.id}" + "
" + + // $"異常類別:{Exception.alarmClassName}" + "
" + + // $"異常訊息:{Exception.errMsg}" + "
"; + //if(Exception.errMsgT == "d") + //{ + // Content += $"當前數值:{Exception.errValue}" + "
"; + //} + //Content += $"發生時間:{Exception.dev_time}"; + var Content = $"發生時間:{Exception.dev_time}" + "
" + + $"電站名稱:{Exception.PowerStationName}" + "
" + $"異常類別:{Exception.alarmClassName}" + "
" + - $"設備訊息:{Exception.errMsg}" + "
"; - if(Exception.errMsgT == "d") + $"異常訊息:{Exception.errMsg}" + "
" + + $"設備編號:{Exception.errDevice}" + "
" + + $"異常編號:{Exception.id}" + "
"; + if (Exception.errMsgT == "d") { Content += $"當前數值:{Exception.errValue}" + "
"; } - Content += $"發生時間:{Exception.dev_time}"; + foreach (var user in UserListWithPowerstation) { + var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id); + string companyName = getCompany.Result; NoticeSchedule DaySchedule = new NoticeSchedule() { UserId = user.Id, EmailType = 4, RecipientEmail = user.Email, - Subject = "異常通知", + Subject = "太陽能監控系統異常通知-" + Exception.PowerStationName + "-" + Exception.alarmClassName, Content = Content, RecipientName = user.Name, Type = 1, diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index 911a475..d476084 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -250,6 +250,9 @@ namespace SolarPower.Quartz.Jobs var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented)); if (stationReportName != "") { + var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id); + string companyName = getCompany.Result; + if (user.Email != null && IsValidEmail(user.Email)) { NoticeSchedule DaySchedule = new NoticeSchedule() @@ -257,7 +260,7 @@ namespace SolarPower.Quartz.Jobs UserId = user.Id, EmailType = 0, RecipientEmail = user.Email, - Subject = "日報表", + Subject = companyName + "-太陽能監控系統-日報表", Attachment = stationReportName, RecipientName = user.Name, Type = 1 @@ -290,12 +293,14 @@ namespace SolarPower.Quartz.Jobs var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented)); if (user.Email != null && IsValidEmail(user.Email)) { + var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id); + string companyName = getCompany.Result; NoticeSchedule MaxSchedule = new NoticeSchedule() { UserId = user.Id, EmailType = 2, RecipientEmail = user.Email, - Subject = "綜合報表", + Subject = companyName + "-太陽能監控系統-綜合報表", Attachment = stationMaxReportName, RecipientName = user.Name, Type = 1 @@ -326,10 +331,12 @@ namespace SolarPower.Quartz.Jobs var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented)); if (user.Email != null && IsValidEmail(user.Email)) { + var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id); + string companyName = getCompany.Result; NoticeSchedule MaxmonthSchedule = new NoticeSchedule() { RecipientEmail = user.Email, - Subject = "綜合報表", + Subject = companyName + "-太陽能監控系統-綜合報表", Attachment = stationReportmaxmonthName, RecipientName = user.Name, Type = 1, @@ -372,10 +379,12 @@ namespace SolarPower.Quartz.Jobs { if (user.Email != null && IsValidEmail(user.Email)) { + var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id); + string companyName = getCompany.Result; NoticeSchedule MonthSchedule = new NoticeSchedule() { RecipientEmail = user.Email, - Subject = "月報表", + Subject = companyName + "-太陽能監控系統-月報表", Attachment = stationReportmonthName, RecipientName = user.Name, Type = 1, diff --git a/SolarPower/Quartz/Jobs/SendEmailJob.cs b/SolarPower/Quartz/Jobs/SendEmailJob.cs index 0302aa5..33d55d2 100644 --- a/SolarPower/Quartz/Jobs/SendEmailJob.cs +++ b/SolarPower/Quartz/Jobs/SendEmailJob.cs @@ -54,11 +54,7 @@ namespace SolarPower.Quartz.Jobs { attachments = notice.Attachment.Split(',').ToList(); } - - var getCompany = noticeScheduleRepository.GetCompanyNameById(notice.Id); - string companyName = getCompany.Result; - - var result = Send(recipientEmails, notice.Subject, notice.Content, attachments, companyName); + var result = Send(recipientEmails, notice.Subject, notice.Content, attachments); if (result.CompareTo("成功") == 0) { @@ -99,7 +95,7 @@ namespace SolarPower.Quartz.Jobs } } - private string Send(List recipientEmails, string subject, string content, List attachments, string companyName) + private string Send(List recipientEmails, string subject, string content, List attachments) { var reason = string.Empty; var CanDoSend = true; @@ -108,8 +104,7 @@ namespace SolarPower.Quartz.Jobs MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼 MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼 MyMail.IsBodyHtml = true; //是否使用html格式 - //var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>"; - var kkk = companyName + $" 太陽能電站管理系統通知 <{smtp.UserName}>"; + var kkk = $"太陽能電站管理系統通知 <{smtp.UserName}>"; MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人 foreach (var email in recipientEmails) { diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 6f37cc1..ff7f8c7 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -39,7 +39,7 @@ { } @@ -48,7 +48,7 @@ { } @@ -57,7 +57,7 @@ { } @@ -66,7 +66,7 @@ { } @@ -75,7 +75,7 @@ { } @@ -86,7 +86,7 @@ { } @@ -95,7 +95,7 @@ { } @@ -196,8 +196,47 @@ } } - $(function () { + function checkPage() { + isloadingdone_uptodate = true; + isloadingdone_info = true; + isloadingdone_inverterinfo = true; + isloadingdone_inverter = true; + isloadingdone_history = true; + isloadingdone_exception = true; + isloadingdone_operation = true; + var i1 = document.getElementById("page_UpToDate"); + var i2 = document.getElementById("page_Info"); + var i3 = document.getElementById("page_InverterInfo"); + var i4 = document.getElementById("page_Inverter"); + var i5 = document.getElementById("page_History"); + var i6 = document.getElementById("page_Exception"); + var i7 = document.getElementById("page_OperationRecord"); + if (i1 != null) + { + isloadingdone_uptodate = false; + } + if (i2 != null) { + isloadingdone_info = false; + } + if (i3 != null) { + isloadingdone_inverterinfo = false; + } + if (i4 != null) { + isloadingdone_inverter = false; + } + if (i5 != null) { + isloadingdone_history = false; + } + if (i6 != null) { + isloadingdone_exception = false; + } + if (i7 != null) { + isloadingdone_operation = false; + } + } + $(function () { + checkPage(); var url = new URL(location.href); stationId = url.searchParams.get('stationId'); diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs index 99f5400..96ba532 100644 --- a/solarApp/fmArchive.cs +++ b/solarApp/fmArchive.cs @@ -19,6 +19,7 @@ namespace solarApp System.Timers.Timer _timer; bool autoTask = false; //測試自動跑 irrDayHour 累計日照小時差異 procSyncError svc = new procSyncError(); // 異常資料同步 + DateTime doTimerTaskTime = DateTime.Now; public fmArchive() { InitializeComponent(); @@ -102,11 +103,6 @@ namespace solarApp // } - /// - /// timer 觸發 - /// - /// - /// private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //每日歸檔 @@ -119,16 +115,19 @@ namespace solarApp dtSelect2.Value = System.DateTime.Now.AddDays(-1); bt_archive.PerformClick(); autoTask = false; + //bt_archive_Click.PerformClick(); } //異常處理 每 5分鐘跑一次 - if ((DateTime.Now.Minute % 5) == 0 && autoTask == false) + if ( DateTime.Now.Hour >= 05 && (DateTime.Now.Minute % 5) == 0 && (DateTime.Now.Second) < 30 && (autoTask == false || (DateTime.Now - doTimerTaskTime).TotalMinutes > 30)) { + doTimerTaskTime = DateTime.Now; autoTask = true; - lbMsgTitle.Text = "異常處理 " + DateTime.Now.ToString() + " timer start"; + lbMsgTitle.Text = "異常處理 " + DateTime.Now.ToString() + " timer start"; btSyncErr.PerformClick(); - lbMsgTitle.Text = "異常處理 done" + DateTime.Now.ToString(); + lbMsgTitle.Text = "異常處理 done" + DateTime.Now.ToString() ; autoTask = false; + //bt_archive_Click.PerformClick(); } @@ -297,8 +296,8 @@ namespace solarApp string date2 = dtSelect2.Value.ToString("yyyy-MM-dd"); procSensorSvc sensorSvc = new procSensorSvc(); procInvSvc invSvc = new procInvSvc(); - procStationSvc siteSvc = new procStationSvc(); - + procStationSvc siteSvc = new procStationSvc(); + foreach (var item in site_list) { //RadioButton rb = new RadioButton(); @@ -306,15 +305,12 @@ namespace solarApp //rb.Text = item.SiteName; //rb.Tag = item.SiteDB; foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2))) - { + { sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); invSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); siteSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); - invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); } } - - #region 累計日照 sensorSvc.isFirst = true; foreach (var item in site_list) { @@ -323,10 +319,10 @@ namespace solarApp { sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); sensorSvc.isFirst = false; + invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); } } - #endregion - + lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!"; } @@ -556,7 +552,8 @@ namespace solarApp procInvSvc invSvc = new procInvSvc(); procStationSvc siteSvc = new procStationSvc(); - + //foreach (var item in site_list) + //{ sensorSvc.isFirst = true; foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2))) { @@ -566,8 +563,9 @@ namespace solarApp invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); - } - + } + i++; + //} lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!"; } @@ -600,12 +598,8 @@ namespace solarApp MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼 MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼 MyMail.IsBodyHtml = true; //是否使用html格式 - if (tbUserName.Text.Trim().Length > 0) - { - var kkk = $"FIC 太陽能電站管理系統通知 <{tbUserName.Text.Trim()}>"; - MyMail.From = new System.Net.Mail.MailAddress(tbUserName.Text.Trim()); //寄件人 - } - + var kkk = $"FIC 太陽能電站管理系統通知 <{tbUserName.Text.Trim()}>"; + MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人 foreach (var email in recipientEmails) { MyMail.To.Add(email); //設定收件者Email @@ -636,8 +630,7 @@ namespace solarApp if (CanDoSend) { SMTPConfig smtp = new SMTPConfig(); ; - //smtp.Host = "smtp.gmail.com"; - smtp.Host = "msa.hinet.net"; + smtp.Host = "smtp.gmail.com"; //smtp.UserName = "ficgreen01@gmail.com"; //smtp.Password = "qwe2015qwe"; //smtp.UserName = "ficgreen02@gmail.com"; @@ -646,13 +639,8 @@ namespace solarApp //smtp.Password = "wswgnluvoodfexrb"; //smtp.EnableSsl = true; //smtp.Port = 587; - if (tbUserName.Text.Trim().Length > 0) - { - smtp.UserName = tbUserName.Text; - smtp.Password = tbPassword.Text; - } - //smtp.UserName = tbUserName.Text; - //smtp.Password = tbPassword.Text; + smtp.UserName = tbUserName.Text; + smtp.Password = tbPassword.Text; if (rbSSL.Checked) { smtp.EnableSsl = true;