コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public async Task <ActionResult> Get()
        {
            GetServicesRequest request = new GetServicesRequest();

            GetServicesResponse response = await _getServiceHandler.Handle(request);

            return(Ok(response));
        }
コード例 #4
0
ファイル: GrpcQuery.cs プロジェクト: lison666/tracing
        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);
        }
コード例 #5
0
ファイル: ServiceApi.cs プロジェクト: holydk/moysklad-sdk
        /// <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));
        }
コード例 #6
0
        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()));
        }
コード例 #7
0
        public Boolean getServices()
        {
            GetServicesRequest request = new GetServicesRequest();

            request.session = MainWindow.Session;
            try
            {
                applicationService.AllServices = client.GetServices(request);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #8
0
ファイル: ServerBusiness.cs プロジェクト: mazhufeng/DataSync
        /// <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());
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
 public GetServicesResponse GetServices(GetServicesRequest request)
 {
     return(_hbArchiveProcessor.GetServices(request));
 }
コード例 #14
0
 GetServicesResponse IOnVifDevice.GetServices(GetServicesRequest request)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
 public override Task <GetServicesResponse> GetServices(GetServicesRequest request, ServerCallContext context)
 {
     return(base.GetServices(request, context));
 }