Beispiel #1
0
        public async Task <IEnumerable <Service> > GetServices(TimeRangeQuery query)
        {
            var sql = "SELECT DISTINCT [Value] FROM Tags where [Key] = 'service.name'";

            using (var conn = await GetConnectionAsync())
                using (var cmd = new SqlCommand(sql, conn))
                {
                    using (var reader = await cmd.ExecuteReaderAsync())
                    {
                        if (reader.HasRows)
                        {
                            var services = new List <Service>();

                            while (await reader.ReadAsync())
                            {
                                var service = new Service();
                                service.Name = reader.GetString(0);
                                services.Add(service);
                            }

                            return(services);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
        }
Beispiel #2
0
        public Task <IEnumerable <Service> > GetServices(TimeRangeQuery query)
        {
            var services = _dbContext.Tags.AsNoTracking().Where(x => x.Key == QueryConstants.Service).Select(x => x.Value).Distinct().ToList();

            return(Task.FromResult(services.Select(x => new Service {
                Name = x
            })));
        }
        public async Task <IEnumerable <Service> > GetServices(TimeRangeQuery query)
        {
            var index       = _indexManager.CreateServiceIndex();
            var countResult = await _elasticClient.CountAsync <Service>(x => x.Index(index));

            var serviceResult = await _elasticClient.SearchAsync <Service>(s => s.Index(index).Size((int)countResult.Count));

            return(serviceResult.Documents);
        }