Exemplo n.º 1
0
        public async Task ForecastStartsNewSession()
        {
            var dataSetName = $"testDataSet-{DateTime.Now:s}";
            var dataSet     = DataSetGenerator.Run(DateTime.Parse("2016-08-01"), DateTime.Parse("2017-03-26"), "instances");
            await fixture.Client.DataSets.Create(DataSet.From(dataSetName, dataSet));

            var sessionRequest = new ForecastSessionRequest()
            {
                DataSourceName = dataSetName,
                Columns        = new Dictionary <string, ColumnMetadata>()
                {
                    ["instances"] =
                        new ColumnMetadata()
                    {
                        DataType = ColumnType.NumericMeasure, Role = ColumnRole.Target
                    }
                },
                StartDate      = DateTimeOffset.Parse("2017-03-26"),
                EndDate        = DateTimeOffset.Parse("2017-04-25"),
                ResultInterval = ResultInterval.Day
            };

            var actual = await fixture.Client.Sessions.CreateForecast(sessionRequest);

            Assert.NotNull(actual.SessionId);
            await fixture.Client.DataSets.Remove(new DataSetRemoveCriteria(dataSetName) { Options = DataSetDeleteOptions.CascadeAll });
        }
Exemplo n.º 2
0
        public Task <SessionResponse> CreateForecast(ForecastSessionRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            Argument.IsNotNullOrEmpty(request?.DataSourceName, "dataSourceName");
            Argument.IsNotNullOrEmpty(request?.TargetColumn, "targetColumn");

            return(apiConnection.Post <SessionResponse>("/sessions/forecast", null, request, HttpMessageTransformer, cancellationToken));
        }
        public async Task <SessionResponse> CreateForecast(ForecastSessionRequest request)
        {
            try
            {
                var result = await SessionRepository.CreateForecast(request);

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error("SessionService.CreateForecast failed", this, ex);
            }

            return(null);
        }
        public async Task <SessionResponse> CreateForecast(ForecastSessionRequest request)
        {
            Argument.IsNotNullOrEmpty(request?.DataSourceName, "dataSourceName");

            return(await Client.Post <SessionResponse>($"{ApiKeys.Endpoint}sessions/forecast", ApiKeys.ApiToken, null, request));
        }
Exemplo n.º 5
0
        public static ForecastSessionRequest Forecast(string dataSourceName, DateTimeOffset startDate, DateTimeOffset endDate, ResultInterval resultInterval, string targetColumn = null, ForecastSessionRequest options = null)
        {
            var request = options ?? new ForecastSessionRequest();

            request.DataSourceName = dataSourceName;
            if (targetColumn != null)
            {
                request.TargetColumn = targetColumn;
            }
            request.StartDate      = startDate;
            request.EndDate        = endDate;
            request.ResultInterval = resultInterval;
            return(request);
        }