diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index d762167..d42fbb6 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -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(sql, new { PowerStationId = id })).ToList(); + result = (await conn.QueryAsync(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(sql)).ToList(); + count = (await conn.QueryAsync(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(sql, new { Controllerid = controllerid })).ToList(); + inverterTable = (await conn.QueryAsync(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(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(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(sql, new { PowerStationId = powerStationId })).ToList(); + result = (await conn.QueryAsync(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(sql, new { PowerStationId = powerStationId })).ToList(); + result = (await conn.QueryAsync(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(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(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(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList(); + result = (await conn.QueryAsync(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(sql, new { PowerStationId = powerStationId }); + result = await conn.QueryFirstAsync(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(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(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(sql); + result = await conn.QueryFirstOrDefaultAsync(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(sql, new { DBName = db_name, TableName = table_name }); + result = await conn.QueryFirstOrDefaultAsync(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(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(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(sql, new { DateTime = dateTime }); + result = await conn.QueryFirstOrDefaultAsync(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(); } diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index 07cdd16..b0a25f8 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -419,7 +419,7 @@ namespace SolarPower.Repository.Implement { var sql = $"SELECT Value FROM variable WHERE Name = @Name"; - result = await conn.QueryFirstOrDefaultAsync(sql, new { Name = name }); + result = await conn.QueryFirstOrDefaultAsync(sql, new { Name = name }, commandTimeout: 600); } catch (Exception exception) {