電站管理-裝置設定: 加上sensorTypeId和sensorTypeDetailId的值
This commit is contained in:
parent
1aae1190d9
commit
a56620286a
@ -1177,7 +1177,9 @@ namespace SolarPower.Controllers
|
||||
"Status",
|
||||
"Enabled",
|
||||
"InstallDate",
|
||||
"BrandNum"
|
||||
"BrandNum",
|
||||
"SensorTypeId",
|
||||
"SensorTypeDetailId"
|
||||
};
|
||||
if (Device.WarrantyDate != "0001-01-01")
|
||||
{
|
||||
@ -1246,7 +1248,9 @@ namespace SolarPower.Controllers
|
||||
"Status",
|
||||
"Enabled",
|
||||
"InstallDate",
|
||||
"BrandNum"
|
||||
"BrandNum",
|
||||
"SensorTypeId",
|
||||
"SensorTypeDetailId"
|
||||
};
|
||||
if (Device.WarrantyDate != "0001-01-01")
|
||||
{
|
||||
|
||||
@ -442,6 +442,8 @@ namespace SolarPower.Models.PowerStation
|
||||
public string InstallDate { get { return Convert.ToDateTime(installDate).ToString("yyyy-MM-dd"); } set { installDate = value; } } //安裝日期
|
||||
public string BrandNum { get; set; }//廠商序號
|
||||
public string WarrantyDate { get { return Convert.ToDateTime(warrantyDate).ToString("yyyy-MM-dd"); } set { warrantyDate = value; } } //保固日期
|
||||
public int SensorTypeId { get; set; }
|
||||
public int SensorTypeDetailId { get; set; }
|
||||
}
|
||||
|
||||
public class Device : DeviceInfo
|
||||
|
||||
@ -1018,6 +1018,10 @@ namespace SolarPower.Repository.Implement
|
||||
var trans = conn.BeginTransaction();
|
||||
try
|
||||
{
|
||||
string getSensorTypeId = $@"SELECT id from sensor_type
|
||||
WHERE SensorEName = '{DeviceInfo.Type}' AND Deleted = 0";
|
||||
DeviceInfo.SensorTypeId = await conn.QueryFirstOrDefaultAsync<int>(getSensorTypeId);
|
||||
DeviceInfo.SensorTypeDetailId = DeviceInfo.SensorTypeId;
|
||||
|
||||
string sql = GenerateInsertQueryWithCustomDBNameAndTable(properties, db_name, "device");
|
||||
await conn.ExecuteAsync(sql, DeviceInfo);
|
||||
@ -1050,6 +1054,11 @@ namespace SolarPower.Repository.Implement
|
||||
var trans = conn.BeginTransaction();
|
||||
try
|
||||
{
|
||||
string getSensorTypeId = $@"SELECT id from sensor_type
|
||||
WHERE SensorEName = '{DeviceInfo.Type}' AND Deleted = 0";
|
||||
DeviceInfo.SensorTypeId = await conn.QueryFirstOrDefaultAsync<int>(getSensorTypeId);
|
||||
DeviceInfo.SensorTypeDetailId = DeviceInfo.SensorTypeId;
|
||||
|
||||
var updateQuery = GenerateUpdateQueryWithCustomDBNameAndTable(properties, db_name, "device");
|
||||
await conn.ExecuteAsync(updateQuery.ToString(), DeviceInfo, trans);
|
||||
trans.Commit();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user