datatab
This commit is contained in:
parent
0a9713fc94
commit
7ecdd8603d
@ -498,7 +498,7 @@ namespace SolarPower.Controllers
|
||||
"UID",
|
||||
"CreatedBy"
|
||||
};
|
||||
await powerStationRepository.AddDevice(DeviceInfo, properties);
|
||||
await powerStationRepository.UpdateDevice(DeviceInfo, properties);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
}
|
||||
@ -516,6 +516,23 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
List<DeviceTable> deviceTables = new List<DeviceTable>();
|
||||
ApiResult<List<DeviceTable>> apiResult = new ApiResult<List<DeviceTable>>();
|
||||
try
|
||||
{
|
||||
apiResult.Code = "0000";
|
||||
deviceTables = await powerStationRepository.DeviceTable(stationId);
|
||||
foreach (DeviceTable a in deviceTables)
|
||||
{
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
}
|
||||
apiResult.Data = deviceTables;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
}
|
||||
var result = Json(new
|
||||
{
|
||||
data = apiResult
|
||||
|
||||
@ -139,6 +139,7 @@ namespace SolarPower.Models.PowerStation
|
||||
}
|
||||
public class DeviceTable : DeviceInfo
|
||||
{
|
||||
public string UID { get; set; }//設備編號
|
||||
public string Function { get; set; }//功能
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,7 +259,31 @@ namespace SolarPower.Repository.Implement
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 裝置dataTable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<DeviceTable>> DeviceTable(int stationId)
|
||||
{
|
||||
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||
conn.Open();
|
||||
List<DeviceTable> Device = new List<DeviceTable>();
|
||||
try
|
||||
{
|
||||
string sql = @$"SELECT * FROM device WHERE Deleted = 0 AND PowerStationId = @StationId";
|
||||
Device = (await conn.QueryAsync<DeviceTable>(sql, new { StationId = stationId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return Device;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,11 @@ namespace SolarPower.Repository.Interface
|
||||
public interface IPowerStationRepository : IRepositoryBase<PowerStation>
|
||||
{
|
||||
Task<int> AddOperation(OperationInfo operation, List<string> properties);
|
||||
/// <summary>
|
||||
/// 運維dataTable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OperationTable>> OperationTable (int stationId);
|
||||
Task<OperationInfo> OneOperationInfo (int stationId);
|
||||
Task UpdateOperation(OperationInfo operation, List<string> properties);
|
||||
@ -31,5 +36,11 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateDevice(Device DeviceInfo, List<string> properties);
|
||||
/// <summary>
|
||||
/// 設備datatable
|
||||
/// </summary>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DeviceTable>> DeviceTable(int stationId);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user