/// <summary> /// Convert a WWCP charge detail record into a corresponding eMIP charge detail record. /// </summary> /// <param name="ChargeDetailRecord">A WWCP charge detail record.</param> /// <param name="WWCPChargeDetailRecord2ChargeDetailRecord">A delegate which allows you to modify the convertion from WWCP charge detail records to eMIP charge detail records.</param> public static ChargeDetailRecord ToEMIP(this WWCP.ChargeDetailRecord ChargeDetailRecord, CPO.WWCPChargeDetailRecord2ChargeDetailRecordDelegate WWCPChargeDetailRecord2ChargeDetailRecord = null) { var CDR = new ChargeDetailRecord( CDRNature: CDRNatures.Final, ServiceSessionId: ServiceSession_Id.Parse(ChargeDetailRecord.SessionId.ToString()), RequestedServiceId: Service_Id.GenericChargeService, EVSEId: ChargeDetailRecord.EVSEId.Value.ToEMIP().Value, UserId: ChargeDetailRecord.AuthenticationStart.ToEMIP().Value, StartTime: ChargeDetailRecord.SessionTime.StartTime, EndTime: ChargeDetailRecord.SessionTime.EndTime.Value, UserContractIdAlias: null, ExecPartnerSessionId: null, ExecPartnerOperatorId: null, SalesPartnerSessionId: null, //ChargeDetailRecord.GetCustomDataAs<PartnerSession_Id?>("eMIP.PartnerSessionId"), SalesPartnerOperatorId: null, PartnerProductId: ChargeDetailRecord.ChargingProduct?.Id.ToEMIP(), MeterReports: new MeterReport[] { MeterReport.Create(ChargeDetailRecord.Duration.HasValue ? ChargeDetailRecord.Duration.Value.TotalMinutes.ToString("0.##").Replace(',', '.') : (ChargeDetailRecord.EnergyMeteringValues.Last().Timestamp - ChargeDetailRecord.EnergyMeteringValues.First().Timestamp).TotalMinutes.ToString("0.##").Replace(',', '.'), "min", MeterTypes.TotalDuration), MeterReport.Create(ChargeDetailRecord.ConsumedEnergy.HasValue ? ChargeDetailRecord.ConsumedEnergy.Value.ToString("0.##").Replace(',', '.') : (ChargeDetailRecord.EnergyMeteringValues.Last().Value - ChargeDetailRecord.EnergyMeteringValues.First().Value).ToString("0.##").Replace(',', '.'), "kWh", MeterTypes.TotalEnergy), }, InternalData: new Dictionary <String, Object> { { WWCP_CDR, ChargeDetailRecord } }); if (WWCPChargeDetailRecord2ChargeDetailRecord != null) { CDR = WWCPChargeDetailRecord2ChargeDetailRecord(ChargeDetailRecord, CDR); } return(CDR); }
public static ServiceSession_Id?ToEMIP(this ChargingSession_Id?ChargingSessionId) => ChargingSessionId.HasValue ? ServiceSession_Id.Parse(ChargingSessionId.ToString()) : new ServiceSession_Id?();
public static ServiceSession_Id ToEMIP(this ChargingSession_Id ChargingSessionId) => ServiceSession_Id.Parse(ChargingSessionId.ToString());