|
@@ -1562,57 +1562,65 @@ namespace EVCB_OCPP.WSServer
|
|
|
|
|
|
if (string.IsNullOrEmpty(client.ChargeBoxId)) return displayPriceText;
|
|
|
|
|
|
- using (SqlConnection conn = new SqlConnection(webConnectionString))
|
|
|
+ try
|
|
|
{
|
|
|
- var parameters = new DynamicParameters();
|
|
|
- parameters.Add("@MachineId", client.MachineId, DbType.String, ParameterDirection.Input);
|
|
|
- string displayPricestrSql = "";
|
|
|
- string strSql = "";
|
|
|
-
|
|
|
- if (client.IsAC)
|
|
|
+ using (SqlConnection conn = new SqlConnection(webConnectionString))
|
|
|
{
|
|
|
- displayPricestrSql = " SELECT [AC_BillingMethod] as BillingMethod,[AC_FeeName] as FeeName,[AC_Fee] as ChargingFeebyHour" +
|
|
|
- " ,[AC_ParkingFee] as ParkingFee, [Currency] FROM[StationMachine] left join[dbo].[Station]" +
|
|
|
- " on[StationMachine].StationId = Station.[Id] where StationMachine.MachineId=@MachineId and Station.IsBilling=1; ";
|
|
|
+ var parameters = new DynamicParameters();
|
|
|
+ parameters.Add("@MachineId", client.MachineId, DbType.String, ParameterDirection.Input);
|
|
|
+ string displayPricestrSql = "";
|
|
|
+ string strSql = "";
|
|
|
|
|
|
- strSql = " SELECT CAST( [StartTime] as varchar(5)) StartTime,CAST( [EndTime] as varchar(5)) EndTime,[Fee] FROM[StationMachine] left join [dbo].[StationFee]" +
|
|
|
- " on[StationMachine].StationId = StationFee.StationId where StationMachine.MachineId =@MachineId and StationFee.IsAC=1; ";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- displayPricestrSql = " SELECT [DC_BillingMethod] as BillingMethod,[DC_FeeName] as FeeName,[DC_Fee] as ChargingFeebyHour" +
|
|
|
- " ,[DC_ParkingFee] as ParkingFee, [Currency] FROM[StationMachine] left join[dbo].[Station]" +
|
|
|
- " on[StationMachine].StationId = Station.[Id] where StationMachine.MachineId=@MachineId and Station.IsBilling=1; ";
|
|
|
+ if (client.IsAC)
|
|
|
+ {
|
|
|
+ displayPricestrSql = " SELECT [AC_BillingMethod] as BillingMethod,[AC_FeeName] as FeeName,[AC_Fee] as ChargingFeebyHour" +
|
|
|
+ " ,[AC_ParkingFee] as ParkingFee, [Currency] FROM[StationMachine] left join[dbo].[Station]" +
|
|
|
+ " on[StationMachine].StationId = Station.[Id] where StationMachine.MachineId=@MachineId and Station.IsBilling=1; ";
|
|
|
|
|
|
- strSql = " SELECT CAST( [StartTime] as varchar(5)) StartTime,CAST( [EndTime] as varchar(5)) EndTime,[Fee] FROM[StationMachine] left join [dbo].[StationFee]" +
|
|
|
- " on[StationMachine].StationId = StationFee.StationId where StationMachine.MachineId =@MachineId and StationFee.IsAC=0; ";
|
|
|
+ strSql = " SELECT CAST( [StartTime] as varchar(5)) StartTime,CAST( [EndTime] as varchar(5)) EndTime,[Fee] FROM[StationMachine] left join [dbo].[StationFee]" +
|
|
|
+ " on[StationMachine].StationId = StationFee.StationId where StationMachine.MachineId =@MachineId and StationFee.IsAC=1; ";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ displayPricestrSql = " SELECT [DC_BillingMethod] as BillingMethod,[DC_FeeName] as FeeName,[DC_Fee] as ChargingFeebyHour" +
|
|
|
+ " ,[DC_ParkingFee] as ParkingFee, [Currency] FROM[StationMachine] left join[dbo].[Station]" +
|
|
|
+ " on[StationMachine].StationId = Station.[Id] where StationMachine.MachineId=@MachineId and Station.IsBilling=1; ";
|
|
|
|
|
|
- }
|
|
|
- var result = await conn.QueryAsync<StationFee>(displayPricestrSql, parameters);
|
|
|
- if (result.Count() == 0)
|
|
|
- {
|
|
|
- return string.Empty;
|
|
|
- }
|
|
|
- var stationPrice = result.First();
|
|
|
+ strSql = " SELECT CAST( [StartTime] as varchar(5)) StartTime,CAST( [EndTime] as varchar(5)) EndTime,[Fee] FROM[StationMachine] left join [dbo].[StationFee]" +
|
|
|
+ " on[StationMachine].StationId = StationFee.StationId where StationMachine.MachineId =@MachineId and StationFee.IsAC=0; ";
|
|
|
|
|
|
- if (stationPrice.BillingMethod == 1)
|
|
|
- {
|
|
|
- var chargingPriceResult = await conn.QueryAsync<ChargingPrice>(strSql, parameters);
|
|
|
- client.ChargingPrices = chargingPriceResult.ToList();
|
|
|
- if (string.IsNullOrEmpty(client.ChargingPrices[0].StartTime))
|
|
|
+ }
|
|
|
+ var result = await conn.QueryAsync<StationFee>(displayPricestrSql, parameters);
|
|
|
+ if (result.Count() == 0)
|
|
|
+ {
|
|
|
+ return string.Empty;
|
|
|
+ }
|
|
|
+ var stationPrice = result.First();
|
|
|
+
|
|
|
+ if (stationPrice.BillingMethod == 1)
|
|
|
{
|
|
|
- client.ChargingPrices = new List<ChargingPrice>();
|
|
|
+ var chargingPriceResult = await conn.QueryAsync<ChargingPrice>(strSql, parameters);
|
|
|
+ client.ChargingPrices = chargingPriceResult.ToList();
|
|
|
+ if (string.IsNullOrEmpty(client.ChargingPrices[0].StartTime))
|
|
|
+ {
|
|
|
+ client.ChargingPrices = new List<ChargingPrice>();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ displayPriceText = stationPrice.FeeName;
|
|
|
+ client.BillingMethod = stationPrice.BillingMethod;
|
|
|
+ client.Currency = stationPrice.Currency;
|
|
|
+ client.ChargingFeebyHour = stationPrice.ChargingFeebyHour;
|
|
|
+ client.ParkingFee = stationPrice.ParkingFee;
|
|
|
+ client.IsBilling = true;
|
|
|
}
|
|
|
|
|
|
- displayPriceText = stationPrice.FeeName;
|
|
|
- client.BillingMethod = stationPrice.BillingMethod;
|
|
|
- client.Currency = stationPrice.Currency;
|
|
|
- client.ChargingFeebyHour = stationPrice.ChargingFeebyHour;
|
|
|
- client.ParkingFee = stationPrice.ParkingFee;
|
|
|
- client.IsBilling = true;
|
|
|
}
|
|
|
-
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Error("SetDefaultFee",ex.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
return displayPriceText;
|
|
|
}
|
|
|
|
|
@@ -1838,16 +1846,16 @@ namespace EVCB_OCPP.WSServer
|
|
|
var dd = DateTime.UtcNow;
|
|
|
SqlParameter[] parameter =
|
|
|
{
|
|
|
- new SqlParameter("CreatedOn",dd),
|
|
|
- new SqlParameter("ChargeBoxId",clientData.ChargeBoxId==null?"unknown":clientData.ChargeBoxId.Replace("'","''")),
|
|
|
- new SqlParameter("MessageType",messageType.Replace("'","''")),
|
|
|
+ new SqlParameter("CreatedOn",23){ Value=dd},
|
|
|
+ new SqlParameter("ChargeBoxId",50){ Value=clientData.ChargeBoxId==null?"unknown":clientData.ChargeBoxId.Replace("'","''")},
|
|
|
+ new SqlParameter("MessageType",50){ Value=messageType.Replace("'","''")},
|
|
|
new SqlParameter("Data",data.Replace("'","''")),
|
|
|
- new SqlParameter("Msg",errorMsg.Replace("'","''")),
|
|
|
- new SqlParameter("IsSent",isSent),
|
|
|
- new SqlParameter("EVSEEndPoint",clientData.RemoteEndPoint==null?"123":clientData.RemoteEndPoint.ToString()),
|
|
|
- new SqlParameter("Session",clientData.SessionID==null?"123":clientData.SessionID)
|
|
|
+ new SqlParameter("Msg",200){ Value=errorMsg.Replace("'","''")},
|
|
|
+ new SqlParameter("IsSent",1){ Value=isSent},
|
|
|
+ new SqlParameter("EVSEEndPoint",25){ Value=clientData.RemoteEndPoint==null?"123":clientData.RemoteEndPoint.ToString()},
|
|
|
+ new SqlParameter("Session",36){ Value=clientData.SessionID==null?"123":clientData.SessionID}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
db.Database.ExecuteSqlCommand(sp, parameter);
|
|
|
}
|
|
|
}
|