public UnitOfWork(DataContext context) { _dataContext = context; Projects = new ProjectRepository(_dataContext); Variables = new VariableRepository(_dataContext); Records = new RecordRepository(_dataContext); Notifications = new NotificationRepository(_dataContext); Auth = new AuthRepository(_dataContext); Endpoints = new EndpointRepository(_dataContext); }
public async Task <ResolveServiceEndpointResponse> Discover([FromBody] ResolveServiceEndpointRequest requestModel) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Service Discover request for: {requestModel.Region}:{requestModel.ServiceType}"); } if (!ModelState.IsValid) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Resolution request was sent with an invalid model ModelState."); } return(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.GeneralRequestError)); } //We need to check if we know about the locale //If we don't we should indicate it is unlisted //We also need to check if the keypair region and servicetype exist if (!await EndpointRepository.HasEntryAsync(requestModel.Region, requestModel.ServiceType)) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Client requested unlisted service Region: {requestModel.Region} Service: {requestModel.ServiceType}."); } return(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.ServiceUnlisted)); } ResolvedEndpoint endpoint = await EndpointRepository.RetrieveAsync(requestModel.Region, requestModel.ServiceType); if (endpoint == null) { //Log the error. It shouldn't be null if the checks passed if (LoggingService.IsEnabled(LogLevel.Error)) { LoggingService.LogError($"Resolution request {requestModel.ServiceType} for region {requestModel.Region} failed even through it was a known pair."); } return(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.GeneralRequestError)); } //Just return the JSON model response to the client return(new ResolveServiceEndpointResponse(endpoint)); }
private List <IAutoDeployService> GetAgentServices() { List <EndpointInfo> endPoints = EndpointRepository.GetEndPoints(); List <IAutoDeployService> AutoDeployServices = new List <IAutoDeployService>(); foreach (EndpointInfo endPoint in endPoints) { try { AutoDeployServices.Add(WCFUtilities.ServiceFactory <IAutoDeployService> .GetService(endPoint.Address)); LogManager.Instance.WriteInfo("EndPoint Added : " + endPoint.Address); } catch (Exception ex) { LogManager.Instance.WriteError("Couldnt add EndPoint : " + endPoint.Address + " Error Message : " + ex.Message + @"** \n You should check Endpoint address at Config\Agents.xml"); } } return(AutoDeployServices); }
public async Task <ResponseModel <ServiceResolutionResult, ResolvedServiceEndpointResponseCode> > DiscoverServicesAsync([FromRoute(Name = "name")] string serviceType, CancellationToken token = default) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Service Discover request for: {serviceType}"); } if (!ModelState.IsValid) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Resolution request was sent with an invalid model ModelState."); } return(Failure <ServiceResolutionResult, ResolvedServiceEndpointResponseCode>(ResolvedServiceEndpointResponseCode.GeneralRequestError)); } //We need to check if we know about the locale //If we don't we should indicate it is unlisted //We also need to check if the keypair region and servicetype exist //TODO: Deployment mode handling, right now it's set to INTERNAL if (!await EndpointRepository.ContainsAsync(serviceType, token)) { if (LoggingService.IsEnabled(LogLevel.Debug)) { LoggingService.LogDebug($"Client requested unlisted service Service: {serviceType}."); } return(Failure <ServiceResolutionResult, ResolvedServiceEndpointResponseCode>(ResolvedServiceEndpointResponseCode.ServiceUnlisted)); } //Assume no failure ResolvedService[] endpoints = (await EndpointRepository .RetrieveAllAsync(serviceType, token)) .Select(m => new ResolvedService(m.Name, m.Endpoint)) .ToArray(); return(Success <ServiceResolutionResult, ResolvedServiceEndpointResponseCode>(new ServiceResolutionResult(endpoints))); }