52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using Dapper;
|
|
using SolarPower.Helper;
|
|
using SolarPower.Models;
|
|
using SolarPower.Repository.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SolarPower.Repository.Implement
|
|
{
|
|
public class AnalysisStationCombineRepository : RepositoryBase<AnalysisStationCombine>, IAnalysisStationCombineRepository
|
|
{
|
|
public AnalysisStationCombineRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
|
{
|
|
tableName = "power_station";
|
|
}
|
|
|
|
public async Task<AnalysisStationCombine> GetPowerStationInfoList(ChartInput post)
|
|
{
|
|
var a = new AnalysisStationCombine();
|
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
|
{
|
|
conn.Open();
|
|
using (var trans = conn.BeginTransaction())
|
|
{
|
|
try
|
|
{
|
|
string sql = @"SELECT AVG(KWHKWP),TOTALMONEY,TOTALKWH,TOTALCARBON,PR";
|
|
|
|
a = await conn.QueryFirstOrDefaultAsync<AnalysisStationCombine>(sql);
|
|
|
|
trans.Commit();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
trans.Rollback();
|
|
throw exception;
|
|
}
|
|
finally
|
|
{
|
|
conn.Close();
|
|
}
|
|
}
|
|
}
|
|
return a;
|
|
}
|
|
|
|
}
|
|
}
|