diff --git a/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2 b/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2
deleted file mode 100644
index 7deac22..0000000
Binary files a/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2 and /dev/null differ
diff --git a/.vs2/slnSolarPower/config/applicationhost.config b/.vs2/slnSolarPower/config/applicationhost.config
deleted file mode 100644
index 3269632..0000000
--- a/.vs2/slnSolarPower/config/applicationhost.config
+++ /dev/null
@@ -1,995 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs
index a7d8118..305b048 100644
--- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs
+++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs
@@ -842,8 +842,8 @@ namespace SolarPower.Quartz.Jobs
}
#endregion
- if (!this.environment.IsDevelopment())
- {
+ //if (!this.environment.IsDevelopment())
+ //{
#region step3. 將historiers INSERT 到 power_station_history_hour 資料表
List history_properties = new List()
{
@@ -1076,7 +1076,7 @@ namespace SolarPower.Quartz.Jobs
};
await powerStationRepository.AddWeatherObservation(weatherObservations, weather_observation_properties);
#endregion
- }
+ // }
logger.LogInformation("【CalcPowerStationJob】【任務完成】");
}
diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJobV2.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJobV2.cs
index f3c2c2b..e9cc908 100644
--- a/SolarPower/Quartz/Jobs/CalcPowerStationJobV2.cs
+++ b/SolarPower/Quartz/Jobs/CalcPowerStationJobV2.cs
@@ -142,8 +142,8 @@ namespace SolarPower.Quartz.Jobs
}
}
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step3. 將historiers INSERT 到 power_station_history_hour 資料表
List history_properties = new List()
{
@@ -169,7 +169,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddPowerStationHistory(powerStationHistoriesHour, history_properties);
logger.LogInformation("【Insert PowerStationHistoryHour】【ArchiveStation】【完成寫入 PowerStationHistoryHour 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
private async Task ArchiveStationForPowerStation(List powerStations, string dateTime)
@@ -339,8 +339,8 @@ namespace SolarPower.Quartz.Jobs
}
}
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step5. calcPowerStations UPDATE 到 power_station 資料表
List power_station_properties = new List()
{
@@ -365,7 +365,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.UpdateList(calcPowerStations, power_station_properties);
logger.LogInformation("【update Power_Station】【ArchiveStation】【完成更新 Power_Station 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
private async Task ArchiveStationForPowerStationWithWinForm(List powerStations, string dateTime)
@@ -476,8 +476,8 @@ namespace SolarPower.Quartz.Jobs
}
#endregion
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step6. 將 inverter INSERT 到 inverter_history_hour 資料表
List inverter_history_properties = new List()
{
@@ -542,7 +542,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddInverterHistory(inverterHistoriesHour, inverter_history_properties);
logger.LogInformation("【Insert InverterHistoryHour】【ArchiveInverter】【完成寫入 inverter_history_hour 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
private async Task ArchiveSensoravg(List powerStations, string dateTime)
@@ -589,8 +589,8 @@ namespace SolarPower.Quartz.Jobs
}
}
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step7. 將 sensoravg INSERT 到 sensoravg_history_hour 資料表
List sensoravg_history_properties = new List()
{
@@ -651,7 +651,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddSensorAvgHistory(sensorAvgHistoryHour, sensoravg_history_properties);
logger.LogInformation("【Insert SensoravgHistoryHour】【ArchiveSensoravg】【完成寫入 sensoravg_history_hour 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
private async Task ArchiveMeter(List powerStations, string dateTime)
@@ -702,8 +702,8 @@ namespace SolarPower.Quartz.Jobs
}
}
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step8. 將 meter INSERT 到 meter_history_hour 資料表
List memter_history_properties = new List()
{
@@ -726,7 +726,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddMeterHistory(meterHistoriesHour, memter_history_properties);
logger.LogInformation("【Insert MeterHistoryHour】【ArchiveMeter】【完成寫入 meter_history_hour 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
private async Task ArchiveWeather(List powerStations, string dateTime)
@@ -832,8 +832,8 @@ namespace SolarPower.Quartz.Jobs
}
}
}
- if (!environment.IsDevelopment())
- {
+ //if (!environment.IsDevelopment())
+ //{
#region step9. 新增天氣資訊
List weather_observation_properties = new List()
{
@@ -845,7 +845,7 @@ namespace SolarPower.Quartz.Jobs
await powerStationRepository.AddWeatherObservation(weatherObservations, weather_observation_properties);
logger.LogInformation("【Insert WeatherObservation】【ArchiveWeather】【完成寫入 weather_observation 資料】- {0}", dateTime);
#endregion
- }
+ //}
}
}
diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
index b19a634..4f84366 100644
--- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
+++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
@@ -53,7 +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.priority == 3 &&
+ var ExceptionListex3 = ExceptionList.Where(x => x.sourceState == 1 && x.priority == 3 &&
(DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).TotalSeconds / 60) >= ExceptionTimes_Priority3).ToList();
ExceptionListex.AddRange(ExceptionListex2);
ExceptionListex.AddRange(ExceptionListex3);
@@ -98,19 +98,18 @@ namespace SolarPower.Quartz.Jobs
Type = 1,
ExceptionId = Exception.id
};
- List properties = new List()
- {
- "UserId",
- "EmailType",
- "RecipientEmail",
- "Subject",
- "Content",
- "RecipientName",
- "Type",
- "ExceptionId"
- };
- await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
-
+ //List properties = new List()
+ //{
+ // "UserId",
+ // "EmailType",
+ // "RecipientEmail",
+ // "Subject",
+ // "Content",
+ // "RecipientName",
+ // "Type",
+ // "ExceptionId"
+ //};
+ //await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
}
diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs
index 96bfac3..9119df5 100644
--- a/SolarPower/Repository/Implement/OverviewRepository.cs
+++ b/SolarPower/Repository/Implement/OverviewRepository.cs
@@ -860,9 +860,9 @@ namespace SolarPower.Repository.Implement
and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
left join power_station ps on ps.`Code` = site_id
left join operation_record pr on pr.ErrorCode = a.id
- where ps.`Code` is not null
+ where sourceState = 1 and ps.`Code` is not null and priority < 20
) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
- WHERE ns.Id IS NULL and a.dev_time >= '{ DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}' ";
+ WHERE ns.Id IS NULL ";
exceptionEmailInfos = (await conn.QueryAsync(sql)).ToList();
}
catch (Exception exception)
@@ -882,7 +882,7 @@ namespace SolarPower.Repository.Implement
{
var sql = @$"SELECT u.Name,u.Email,u.Id FROM power_station_operation_personnel pss
LEFT JOIN user u ON u.Id = pss.UserId
- WHERE pss.Deleted = 0 AND pss.EmailException = 1 AND pss.PowerStationId = {id} AND u.Deleted = 0";
+ WHERE pss.Deleted = 0 AND pss.EmailException = 1 AND pss.PowerStationId = {id} AND u.Deleted = 0 and Email is not null";
result = (await conn.QueryAsync(sql)).ToList();
}
catch (Exception exception)
diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs
index fcc705c..14c7a0d 100644
--- a/SolarPower/Startup.cs
+++ b/SolarPower/Startup.cs
@@ -96,66 +96,66 @@ namespace SolarPower
#region [JI
//services.AddHostedService();
//if (envName == "Production")
- if (envName != "Production")
- {
+ //if (envName != "Production")
+ //{
////K[QuartzA
services.AddSingleton();
services.AddSingleton();
- ////K[Job
- //#region wpe / C email A
- services.AddSingleton();
- services.AddSingleton(
- new JobSchedule(jobType: typeof(OperationScheduleJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:OperationScheduleJob"))
- );
- //#endregion
+ ////K[Job
+ //#region wpe / C email A
+ services.AddSingleton();
+ services.AddSingleton(
+ new JobSchedule(jobType: typeof(OperationScheduleJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:OperationScheduleJob"))
+ );
+ //#endregion
- //#region pqfܾT(CI2}l15@Ӵ`)
- services.AddSingleton();
- services.AddSingleton(
- new JobSchedule(jobType: typeof(CalcInverter15minJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcInverter15minJob"))
- );
- //#endregion
+ //#region pqfܾT(CI2}l15@Ӵ`)
+ services.AddSingleton();
+ services.AddSingleton(
+ new JobSchedule(jobType: typeof(CalcInverter15minJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcInverter15minJob"))
+ );
+ //#endregion
- ////#region pqoqqT(CI5)
- //services.AddSingleton();
- //services.AddSingleton(
- //new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcPowerStationJob"))
- ////new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: "0/10 * * * * ?")
- //);
- ////#endregion
+ ////#region pqoqqT(CI5)
+ //services.AddSingleton();
+ //services.AddSingleton(
+ //new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcPowerStationJob"))
+ ////new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: "0/10 * * * * ?")
+ //);
+ ////#endregion
- //#region pqoqqT(CI5)
- services.AddSingleton();
- services.AddSingleton(
- new JobSchedule(jobType: typeof(CalcPowerStationJobV2), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcPowerStationJobV2"))
- //new JobSchedule(jobType: typeof(CalcPowerStationJobV2), cronExpression: "0/10 * * * * ?")
- );
- //#endregion
+ //#region pqoqqT(CI5)
+ services.AddSingleton();
+ services.AddSingleton(
+ new JobSchedule(jobType: typeof(CalcPowerStationJobV2), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcPowerStationJobV2"))
+ //new JobSchedule(jobType: typeof(CalcPowerStationJobV2), cronExpression: "0/10 * * * * ?")
+ );
+ //#endregion
- //#region pqӶqBPRBkWP 30饭B(Cѭ2I)
- services.AddSingleton();
- services.AddSingleton(
- new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcAvgPowerStationJob"))
- //new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: "0 03 7 ? * * *")
- );
- //#endregion
+ //#region pqӶqBPRBkWP 30饭B(Cѭ2I)
+ services.AddSingleton();
+ services.AddSingleton(
+ new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcAvgPowerStationJob"))
+ //new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: "0 03 7 ? * * *")
+ );
+ //#endregion
- //#region HeEmail(Cѭ2I)
- services.AddSingleton();
- services.AddSingleton(
- new JobSchedule(jobType: typeof(SendEmailJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:SendEmailJob"))
- );
- //#endregion
+ //#region HeEmail(Cѭ2I)
+ services.AddSingleton();
+ services.AddSingleton(
+ new JobSchedule(jobType: typeof(SendEmailJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:SendEmailJob"))
+ );
+ //#endregion
- //#region d߲`sWEmail
- services.AddSingleton();
+ //#region d߲`sWEmail
+ services.AddSingleton();
services.AddSingleton(
new JobSchedule(jobType: typeof(ExceptionSchedule), cronExpression: Configuration.GetValue("BackgroundServiceCron:ExceptionSchedule"))
);
//#endregion
services.AddHostedService();
- }
+ //}
#endregion
services.AddApplicationInsightsTelemetry();
diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json
index 3153171..28bb471 100644
--- a/SolarPower/appsettings.json
+++ b/SolarPower/appsettings.json
@@ -47,7 +47,7 @@
"Host": "smtp.gmail.com",
"Port": 25,
"UserName": "ficgreen01@gmail.com",
- "Password": "qwe2015qwe",
+ "Password": "opuisjyxgyjbjtha", //2022-09-02 update by jiahao
"EnableSsl": true
},
"ExceptionTimes": 240, //`qɶA()
diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs
index 19dd64c..ce9a685 100644
--- a/solarApp/fmArchive.Designer.cs
+++ b/solarApp/fmArchive.Designer.cs
@@ -30,8 +30,8 @@ namespace solarApp
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
@@ -89,6 +89,7 @@ namespace solarApp
this.tabPage4 = new System.Windows.Forms.TabPage();
this.btSyncErr = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
+ this.lbMsgStatus = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -394,8 +395,8 @@ namespace solarApp
//
this.gv_inv_detail.AllowUserToAddRows = false;
this.gv_inv_detail.AllowUserToDeleteRows = false;
- dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
+ dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+ this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5;
this.gv_inv_detail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gv_inv_detail.Dock = System.Windows.Forms.DockStyle.Fill;
this.gv_inv_detail.Location = new System.Drawing.Point(768, 75);
@@ -411,8 +412,8 @@ namespace solarApp
//
this.gv_rpt_invDay.AllowUserToAddRows = false;
this.gv_rpt_invDay.AllowUserToDeleteRows = false;
- dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
+ dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
+ this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
this.gv_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gv_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Left;
this.gv_rpt_invDay.Location = new System.Drawing.Point(0, 75);
@@ -428,6 +429,7 @@ namespace solarApp
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
+ this.panel1.Controls.Add(this.lbMsgStatus);
this.panel1.Controls.Add(this.lbMsgTitle);
this.panel1.Controls.Add(this.bt_invDay);
this.panel1.Controls.Add(this.btVerifyData);
@@ -498,7 +500,7 @@ namespace solarApp
//
this.lbSiteName_sensor.AutoSize = true;
this.lbSiteName_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- this.lbSiteName_sensor.Location = new System.Drawing.Point(520, 20);
+ this.lbSiteName_sensor.Location = new System.Drawing.Point(520, 17);
this.lbSiteName_sensor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSiteName_sensor.Name = "lbSiteName_sensor";
this.lbSiteName_sensor.Size = new System.Drawing.Size(107, 24);
@@ -755,6 +757,15 @@ namespace solarApp
//
this.timer1.Interval = 10000;
//
+ // lbMsgStatus
+ //
+ this.lbMsgStatus.AutoSize = true;
+ this.lbMsgStatus.Location = new System.Drawing.Point(520, 49);
+ this.lbMsgStatus.Name = "lbMsgStatus";
+ this.lbMsgStatus.Size = new System.Drawing.Size(18, 19);
+ this.lbMsgStatus.TabIndex = 16;
+ this.lbMsgStatus.Text = "...";
+ //
// fmArchive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
@@ -849,5 +860,6 @@ namespace solarApp
private System.Windows.Forms.TabPage tabPage4;
private System.Windows.Forms.Button btSyncErr;
private System.Windows.Forms.Button button3;
+ private System.Windows.Forms.Label lbMsgStatus;
}
}
\ No newline at end of file
diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs
index 96ba532..36f1fda 100644
--- a/solarApp/fmArchive.cs
+++ b/solarApp/fmArchive.cs
@@ -20,6 +20,7 @@ namespace solarApp
bool autoTask = false; //測試自動跑 irrDayHour 累計日照小時差異
procSyncError svc = new procSyncError(); // 異常資料同步
DateTime doTimerTaskTime = DateTime.Now;
+ TimeSpan doTaskDuratin;
public fmArchive()
{
InitializeComponent();
@@ -105,8 +106,18 @@ namespace solarApp
private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
+ lbMsgStatus.Text = (autoTask) ? "autoTask = true" : "autoTask = false";
+ lbMsgStatus.Text += " timespan = " + (DateTime.Now - doTimerTaskTime).TotalMinutes.ToString();
+
+ // 凌晨 2點後,如果間隔30分鐘 沒有跑異常同步 就啟動啟動
+ doTaskDuratin = DateTime.Now - doTimerTaskTime; // 1200 sec = 20 分鐘
+ if (System.DateTime.Now.Hour >= 2 && doTaskDuratin.TotalSeconds > 1200 && (autoTask == true))
+ {
+ doTimerTaskTime = DateTime.Now;
+ autoTask = false;
+ }
//每日歸檔
- if (System.DateTime.Now.Hour == 00 && DateTime.Now.Minute == 15 && autoTask == false)
+ if (DateTime.Now.Hour == 00 && DateTime.Now.Minute == 15 )
{
//MessageBox.Show("ok");
autoTask = true;
@@ -119,7 +130,7 @@ namespace solarApp
}
//異常處理 每 5分鐘跑一次
- if ( DateTime.Now.Hour >= 05 && (DateTime.Now.Minute % 5) == 0 && (DateTime.Now.Second) < 30 && (autoTask == false || (DateTime.Now - doTimerTaskTime).TotalMinutes > 30))
+ if ((DateTime.Now.Minute % 5) == 0 && (DateTime.Now.Second) < 30 && (autoTask == false))
{
doTimerTaskTime = DateTime.Now;
autoTask = true;