private int QueryTrajectoryStations(T entity, T header, WitsmlQueryParser parser, IQueryContext context) { var stations = GetTrajectoryStations(entity); var chunked = IsQueryingStationFile(entity, header); if (chunked) { var uri = entity.GetUri(); stations = GetMongoFileStationData(uri); } SetTrajectoryStations(entity, stations); var ignored = parser.IsStructuralRangeQuery() ? new List <string> { "md" } : null; var query = new MongoDbQuery <T>(Container, GetCollection(), parser, null, ignored); query.Navigate(OptionsIn.ReturnElements.IdOnly.Value); query.FilterRecurringElements(entity.AsList()); var count = FilterStationData(entity, stations, parser, context); SetIndexRange(entity, parser, false); FormatStationData(entity, parser); return(count); }
protected override async Task <DatasourceResult <List <T> > > RunAsync() { string assemblyPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath; Configuration cfg = ConfigurationManager.OpenExeConfiguration(assemblyPath); string isQueyMongo = cfg.AppSettings.Settings["AlwaysQueryMongo"].Value; int switchTimeDurations = int.Parse(cfg.AppSettings.Settings["SwitchTimeDuration"].Value); if (isQueyMongo != "true") { if (DateTimeOffset.Now.ToUnixTimeMilliseconds() - QueryConstant.PreviousSwitchTime >= switchTimeDurations * 60 * 1000 && QueryConstant.IsSwitch && switchTimeDurations > 0) { QueryConstant.IsSwitch = false; } if (QueryConstant.IsSwitch) { var mongoQuery = new MongoDbQuery <T>(_query.Collection, _query.BoolQuery, _query.EsSort, _query.Aggregations, _query.From, _query.Size); var resultMongo = await mongoQuery.GetResult(); return(resultMongo); } var elasticsearchQuery = new ElasticsearchQuery <T>(_query.EsClient, _query.BoolQuery, _query.EsSort, _query.Aggregations, _query.From, _query.Size); var result = await elasticsearchQuery.GetResult(); return(result); } else { var mongoQuery = new MongoDbQuery <T>(_query.Collection, _query.BoolQuery, _query.EsSort, _query.Aggregations, _query.From, _query.Size); var result = await mongoQuery.GetResult(); return(result); } }
protected override async Task <DatasourceResult <List <T> > > RunFallbackAsync() { string assemblyPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath; Configuration cfg = ConfigurationManager.OpenExeConfiguration(assemblyPath); string isQueyMongo = cfg.AppSettings.Settings["AlwaysQueryMongo"].Value; if (isQueyMongo != "true") { QueryConstant.IsSwitch = true; QueryConstant.PreviousSwitchTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); var mongoQuery = new MongoDbQuery <T>(_query.Collection, _query.BoolQuery, _query.EsSort, _query.Aggregations, _query.From, _query.Size); var result = await mongoQuery.GetResult(); return(result); } return(new DatasourceResult <List <T> >()); }