延長讀取 DB 的時間 (每小時的更新),改成10分鐘
This commit is contained in:
parent
f248541655
commit
aa7dbfba8d
@ -679,7 +679,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN user u ON lb.CreatedBy = u.Id
|
||||
WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<LandBuilding>(sql, new { PowerStationId = id })).ToList();
|
||||
result = (await conn.QueryAsync<LandBuilding>(sql, new { PowerStationId = id }, commandTimeout: 600)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -1900,7 +1900,7 @@ namespace SolarPower.Repository.Implement
|
||||
try
|
||||
{
|
||||
string sql = $"SELECT id FROM {db_name}.controller WHERE PowerStationId = {stationId}";
|
||||
count = (await conn.QueryAsync<int>(sql)).ToList();
|
||||
count = (await conn.QueryAsync<int>(sql, commandTimeout: 600)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -1965,7 +1965,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN user ON inv.CreatedBy = user.id
|
||||
LEFT JOIN {db_name}.device de ON inv.Pyrheliometer = de.id
|
||||
WHERE inv.Deleted = 0 AND inv.ControllerId IN @Controllerid";
|
||||
inverterTable = (await conn.QueryAsync<InverterTable>(sql, new { Controllerid = controllerid })).ToList();
|
||||
inverterTable = (await conn.QueryAsync<InverterTable>(sql, new { Controllerid = controllerid }, commandTimeout: 600)).ToList();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -2158,7 +2158,7 @@ namespace SolarPower.Repository.Implement
|
||||
FROM {table_name} WHERE DATE_FORMAT(FROM_UNIXTIME(timestamp / 1000), '%Y-%m-%d %H') = @DateTime
|
||||
";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationHistory>(sql, new { DateTime = dateTime });
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationHistory>(sql, new { DateTime = dateTime }, commandTimeout: 600);//加上時間
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -2207,7 +2207,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_history_hour");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -2238,7 +2238,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateUpdateQuery(properties);
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -2522,7 +2522,7 @@ namespace SolarPower.Repository.Implement
|
||||
ORDER BY temp.ColName
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId }, commandTimeout: 600)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -2580,7 +2580,7 @@ namespace SolarPower.Repository.Implement
|
||||
) temp
|
||||
ORDER BY temp.ColName";
|
||||
|
||||
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
result = (await conn.QueryAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId }, commandTimeout: 600)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -2651,7 +2651,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
var sql = @$"SELECT a.TIMESTAMP, {calc}(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { DateTime = dateTime });
|
||||
result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { DateTime = dateTime }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -2677,7 +2677,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "sensor_history_hour");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -3130,7 +3130,7 @@ namespace SolarPower.Repository.Implement
|
||||
GROUP BY left(s.CrdTime, 13), s.INVERTERID
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList();
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 600)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3158,7 +3158,7 @@ namespace SolarPower.Repository.Implement
|
||||
AND d.PowerStationId = @PowerStationId
|
||||
ORDER BY d.ColName";
|
||||
|
||||
result = await conn.QueryFirstAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId });
|
||||
result = await conn.QueryFirstAsync<DeviceInfo>(sql, new { PowerStationId = powerStationId }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3186,7 +3186,7 @@ namespace SolarPower.Repository.Implement
|
||||
WHERE {col_name} != 0
|
||||
AND FROM_UNIXTIME(TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<double>(sql, new { DateTime = dateTime });
|
||||
result = await conn.QueryFirstOrDefaultAsync<double>(sql, new { DateTime = dateTime }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3438,7 +3438,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "inverter_history_hour");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -3573,7 +3573,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "weather_observation");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -3632,7 +3632,7 @@ namespace SolarPower.Repository.Implement
|
||||
LEFT JOIN weather_description wd ON wd.WeatherName = wf.Wx
|
||||
WHERE c.Id = {CityId} AND '{now}' BETWEEN wf.StartTime AND wf.EndTime ORDER BY wf.CreatedAt desc";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<NowWeather>(sql);
|
||||
result = await conn.QueryFirstOrDefaultAsync<NowWeather>(sql, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3739,7 +3739,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = @DBName AND TABLE_NAME = @TableName;";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { DBName = db_name, TableName = table_name });
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { DBName = db_name, TableName = table_name }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3783,7 +3783,7 @@ namespace SolarPower.Repository.Implement
|
||||
GROUP BY FROM_UNIXTIME(timestamp / 1000, '%Y-%m-%d %H')";
|
||||
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<SensorAvgHistory>(sql, new { DateTime = dateTime });
|
||||
result = await conn.QueryFirstOrDefaultAsync<SensorAvgHistory>(sql, new { DateTime = dateTime }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -3809,7 +3809,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "sensoravg_history_hour");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
@ -4099,7 +4099,7 @@ namespace SolarPower.Repository.Implement
|
||||
WHERE LEFT(FROM_UNIXTIME(m.timestamp / 1000, '%Y-%m-%d %H'), 10) = @DateTime
|
||||
AND RIGHT(FROM_UNIXTIME(m.timestamp / 1000, '%Y-%m-%d %H'), 2) = '55' ) m2
|
||||
ON m1.timestamp = m2.timestamp AND m1.METERID = m2.METERID";
|
||||
result = await conn.QueryFirstOrDefaultAsync<MeterHistory>(sql, new { DateTime = dateTime });
|
||||
result = await conn.QueryFirstOrDefaultAsync<MeterHistory>(sql, new { DateTime = dateTime }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -4125,7 +4125,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "meter_history_hour");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity, trans);
|
||||
count = await conn.ExecuteAsync(sql, entity, trans, commandTimeout: 600);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql = $"SELECT Value FROM variable WHERE Name = @Name";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { Name = name });
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql, new { Name = name }, commandTimeout: 600);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user