BusinessServiceFactory.cs 1016 B

123456789101112131415161718192021222324252627282930313233343536
  1. using EVCB_OCPP.Domain;
  2. using EVCB_OCPP.Packet.Messages.SubTypes;
  3. using EVCB_OCPP.WSServer.Dto;
  4. using System;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. namespace EVCB_OCPP.WSServer.Service
  8. {
  9. public interface IBusinessService
  10. {
  11. Task<IdTokenInfo> Authorize(string chargeBoxId, string idTag,int? connectorId=-1);
  12. Task NotifyFaultStatus(ErrorDetails details);
  13. Task NotifyConnectorUnplugged(string chargeBoxId,string data);
  14. }
  15. static public class BusinessServiceFactory
  16. {
  17. static public IBusinessService CreateBusinessService(string customerId)
  18. {
  19. bool isCallOut = false;
  20. using (var db = new MainDBContext())
  21. {
  22. isCallOut = db.Customer.Where(x => x.Id == new Guid(customerId)).Select(x => x.CallPartnerApiOnSchedule).SingleOrDefault();
  23. }
  24. return isCallOut ? new OuterBusinessService(customerId) : (IBusinessService)new LocalBusinessService(customerId);
  25. }
  26. }
  27. }