public static Dictionary <Uri, ServiceProfile> GetServices <T>() { Dictionary <Uri, ServiceProfile> services = new Dictionary <Uri, ServiceProfile>(); GetServicesRequest request = new GetServicesRequest(); request.ServiceName = typeof(T).FullName; GetServicesResponse response = MessageSender.Send <IServiceDiscoveryService, GetServicesResponse, GetServicesRequest>( delegate(IServiceDiscoveryService s, GetServicesRequest r) { return(s.GetServices(r)); }, request); if (response.Services != null) { foreach (var service in response.Services) { ServiceProfile profile = new ServiceProfile() { Name = service.Name, ContractName = service.ContractName, Binding = service.Binding, Address = service.Address, HostName = service.HostName, Uri = service.Uri, }; services.Add(profile.Uri, profile); } } return(services); }
public GetServicesResponse GetServices(GetServicesRequest request) { var response = new GetServicesResponse(); response.ServiceInfoList = new List <ServiceInfo>(); //response.ServiceInfoList = // _allInfo.Where(w => w.ServerName == request.ServerName || request.AllServices).Distinct().ToList(); var deneme = _allInfo.Where(w => w.ServerName == request.ServerName || request.AllServices) .GroupBy(g => g.ApplicationName) .Select(group => new { ApplicationName = group.Key, Items = group.ToList() }) .ToList(); foreach (var item in deneme) { var serviceInfo = item.Items.FirstOrDefault(); if (serviceInfo != null) { response.ServiceInfoList.Add(new ServiceInfo() { ServerName = serviceInfo.ServerName, ApplicationName = item.ApplicationName, FirstHeartBeatDate = serviceInfo.FirstHeartBeatDate, LastHeartBeatDate = serviceInfo.LastHeartBeatDate }); } } return(response); }
public async Task <ActionResult> Get() { GetServicesRequest request = new GetServicesRequest(); GetServicesResponse response = await _getServiceHandler.Handle(request); return(Ok(response)); }
public override async Task <GetServicesResponse> GetServices(GetServicesRequest request, ServerCallContext context) { var serviceName = await _ServiceQuery.GetServices(context.CancellationToken); GetServicesResponse getServicesResponse = new GetServicesResponse(); getServicesResponse.Services.Add(serviceName.Distinct().ToArray()); return(getServicesResponse); }
/// <summary> /// Gets the services. /// </summary> /// <param name="request">The services request.</param> /// <returns>The <see cref="Task"/> containing the API response with <see cref="GetServicesResponse"/>.</returns> public virtual Task <ApiResponse <GetServicesResponse> > GetAllAsync(GetServicesRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var requestContext = PrepareRequestContext().WithQuery(request.Query.Build()); return(CallAsync <GetServicesResponse>(requestContext)); }
public GetServicesResponse GetServices(GetServicesRequest request) { BeginMethod("GetServices"); List <Service> res = new List <Service>(); bool includeCapability = request.IncludeCapability; foreach (Service service in SimulatorConfiguration.ServicesConfiguration.Services) { Service copy = new Service(); copy.Namespace = service.Namespace; copy.Version = service.Version; if (includeCapability) { copy.Capabilities = SimulatorConfiguration.ServicesConfiguration.GetServiceCapabilitiesElement(service.Namespace); } string localAddress = string.Empty; switch (service.Namespace) { case Common.Definitions.OnvifService.DEVICE: localAddress = Definitions.LocalAddress.DEVICE; break; case Common.Definitions.OnvifService.ACCESSCONTROL: localAddress = Definitions.LocalAddress.ACCESSCONTROL; break; case Common.Definitions.OnvifService.DOORCONTROL: localAddress = Definitions.LocalAddress.DOORCONTROL; break; case Common.Definitions.OnvifService.EVENTS: localAddress = Definitions.LocalAddress.EVENTS; break; } copy.XAddr = _host + localAddress; res.Add(copy); } EndMethod(); return(new GetServicesResponse(res.ToArray())); }
public Boolean getServices() { GetServicesRequest request = new GetServicesRequest(); request.session = MainWindow.Session; try { applicationService.AllServices = client.GetServices(request); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 获得所有监控服务 /// </summary> /// <param name="serverID"></param> /// <returns></returns> public List <Command> GetServices(string serverID) { List <Command> commands = new List <Command>(); var server = GetServer(serverID); Client client = new Client(); GetServicesRequest request = new GetServicesRequest(); string url = client.GetRealUrl(request, server.Url); var response = SDKFactory.Client.Execute(request, url: url); if (response.IsError) { throw new Exception(response?.ErrorMessage); } commands = response?.List; return(commands); }
public async Task HandleTest(int page, int limit) { var request = new GetServicesRequest { Pagination = new PaginationModel(page, limit) }; var cancellationToken = CancellationToken.None; // var getServicesResponse = await new GetServicesRequestHandler(mapper, mockServiceRepo.Object).Handle(request, cancellationToken); // //Assert.AreEqual(2, getServicesResponse.Services.Count); Assert.AreEqual(2, getServicesResponse.ResponseModels.Count()); }
public GetServicesResponse GetServices(GetServicesRequest request) { try { if (request == null) { throw new ArgumentNullException("request"); } GetServicesResponse response = new GetServicesResponse(); response.Services = new List <ServiceData>(); Type contractType = (from c in contracts where c.ContractType.FullName == request.ServiceName select c.ContractType).FirstOrDefault(); if (contractType != null) { IList <ServiceEndpoint> endpoints = EndpointProvider.GetEndpoints(contractType); foreach (var endpoint in endpoints) { ServiceData service = new ServiceData() { Name = endpoint.Name, ContractName = endpoint.Contract.ContractType.FullName, Binding = endpoint.Binding.Name, Address = endpoint.Address.Uri.ToString(), HostName = endpoint.ListenUri.Host, Uri = endpoint.ListenUri, }; response.Services.Add(service); } } return(response); } catch (Exception ex) { throw new FaultException <ServiceDiscoveryServiceFault>(new ServiceDiscoveryServiceFault(ex.Message, ex), ex.Message); } }
public static T GetService <T>(string hostName, string uri) where T : class { GetServicesRequest request = new GetServicesRequest(); request.ServiceName = typeof(T).FullName; GetServicesResponse response = MessageSender.Send <IServiceDiscoveryService, GetServicesResponse, GetServicesRequest>( delegate(IServiceDiscoveryService s, GetServicesRequest r) { return(s.GetServices(r)); }, request); if (response.Services != null && response.Services.Count > 0) { ChannelFactory <T> channelFactory = new ChannelFactory <T>(new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName)); T client = channelFactory.CreateChannel(new EndpointAddress(response.Services.Find(s => s.Uri.Host == hostName && s.Uri.ToString() == uri).Uri)); return(client); } throw new ContractNotFoundException(string.Format(CultureInfo.InvariantCulture, "Cannot find service type [{0}] by hostname [{1}].", typeof(T).FullName, hostName)); }
public static T GetService <T, C>(C callback) where T : class { GetServicesRequest request = new GetServicesRequest(); request.ServiceName = typeof(T).FullName; GetServicesResponse response = MessageSender.Send <IServiceDiscoveryService, GetServicesResponse, GetServicesRequest>( delegate(IServiceDiscoveryService s, GetServicesRequest r) { return(s.GetServices(r)); }, request); if (response.Services != null && response.Services.Count > 0) { Locator.Remove <T>(); DuplexChannelFactory <T> channelFactory = new DuplexChannelFactory <T>(new InstanceContext(callback), new NetTcpBinding(ServiceConfiguration.DefaultNetTcpBindingName)); T client = channelFactory.CreateChannel(new EndpointAddress(response.Services[0].Uri)); return(client); } throw new ContractNotFoundException(string.Format(CultureInfo.InvariantCulture, "Cannot find service type [{0}].", typeof(T).FullName)); }
public GetServicesResponse GetServices(GetServicesRequest request) { return(_hbArchiveProcessor.GetServices(request)); }
GetServicesResponse IOnVifDevice.GetServices(GetServicesRequest request) { throw new NotImplementedException(); }
public override Task <GetServicesResponse> GetServices(GetServicesRequest request, ServerCallContext context) { return(base.GetServices(request, context)); }