示例#1
0
        public async Task <List <TModel> > GetPastHoursData(DataSourceIdentification dataSourceIdentification, int hour, string cryptoTicker)
        {
            FluxQueryBuilder queryBulder = this.GetHourDataQuery(dataSourceIdentification, hour).AddFilter("ticker", cryptoTicker);
            List <FluxTable> data        = await this.context.Client.GetQueryApi().QueryAsync(queryBulder.CreateQuery(), dataSourceIdentification.Organization);

            return(this.ParseData(data));
        }
示例#2
0
        public async Task DeleteAll(DataSourceIdentification dataSourceIdentification)
        {
            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            await this.Delete(dataSourceIdentification, new DateTimeRange());
        }
示例#3
0
        private FluxQueryBuilder GetHourDataQuery(DataSourceIdentification dataSourceIdentification, int hour)
        {
            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            FluxQueryBuilder queryBuilder = new FluxQueryBuilder();

            return(queryBuilder.From(dataSourceIdentification.Bucket)
                   .RangePastDays(hour)
                   .AddMeasurementFilter(this.measurementName));
        }
示例#4
0
        public async Task Delete(DataSourceIdentification dataSourceIdentification, DeletePredicateRequest deletePredicate)
        {
            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            if (deletePredicate is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(deletePredicate));
            }

            await this.context.Client.GetDeleteApi().Delete(deletePredicate, dataSourceIdentification.Bucket, dataSourceIdentification.Organization).ConfigureAwait(false);
        }
示例#5
0
        public async Task Delete(DataSourceIdentification dataSourceIdentification, DateTimeRange dateTimeRange)
        {
            if (dateTimeRange is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dateTimeRange));
            }

            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            await this.context.Client.GetDeleteApi().Delete(dateTimeRange.From, dateTimeRange.To, null, dataSourceIdentification.Bucket, dataSourceIdentification.Organization);
        }
示例#6
0
        public async Task WriteAll(IEnumerable <TModel> model, DataSourceIdentification dataSourceIdentification)
        {
            if (model is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(model));
            }

            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            WriteApiAsync writeContext = this.context.Client.GetWriteApiAsync();
            await writeContext.WriteMeasurementsAsync(dataSourceIdentification.Bucket, dataSourceIdentification.Organization, WritePrecision.Ns, model).ConfigureAwait(false);
        }
示例#7
0
        public async Task <List <TModel> > GetPastDaysData(DataSourceIdentification dataSourceIdentification, int days)
        {
            if (dataSourceIdentification is null)
            {
                throw new ArgumentException(ParameterErrorMessage, nameof(dataSourceIdentification));
            }

            FluxQueryBuilder queryBuilder = new FluxQueryBuilder();
            string           query        = queryBuilder.From(dataSourceIdentification.Bucket)
                                            .RangePastDays(days)
                                            .AddMeasurementFilter(this.measurementName)
                                            .CreateQuery();

            List <FluxTable> data = await this.context.Client.GetQueryApi().QueryAsync(query, dataSourceIdentification.Organization);

            return(this.ParseData(data));
        }