Exemple #1
0
        public void Render_WhenOneValueInJanuary_RendersTheValue()
        {
            // Arrange
            var ts = new Timeseries {
                m_Tvqs.Tvq20160101
            };

            // Act
            m_Renderer.Render(new [] { ts }, m_Writer);

            // Assert
            var tokensWithoutNewlines = GetTokensAfterHeader(m_Writer);

            Assert.Equal("1", tokensWithoutNewlines[0]);
            Assert.Equal(m_Tvqs.Tvq20160101.V.ToString(CultureInfo.InvariantCulture), tokensWithoutNewlines[1]);
        }
Exemple #2
0
        public string MonthlyValues(string registerId)
        {
            var monthlyAverages = GetMonthlyAverages(registerId);
            var splitPerYear    = new Splitter().SplitPerYear(monthlyAverages);

            var writer   = new StringWriter();
            var renderer = new MonthlyValueTextRenderer(CultureInfo.InvariantCulture);

            renderer.Render(splitPerYear, writer);

            return(writer.ToString());
        }
Exemple #3
0
        public async Task <ContentResult> MonthlyValues()
        {
            var command         = new GetMonthlyAveragesCommand(User.Identity.Name); // Ignoring the registerId parameter for now
            var monthlyAverages = await _mediator.Send(command);

            var splitPerYear = new Splitter().SplitPerYear(monthlyAverages);

            var writer   = new StringWriter();
            var renderer = new MonthlyValueTextRenderer(CultureInfo.InvariantCulture);

            renderer.Render(splitPerYear, writer);

            var result = writer.ToString();

            return(Content(result, "text/csv"));
        }
        public HttpResponseMessage MonthlyValues()
        {
            var monthlyAverages = GetMonthlyAverages(User.Identity.Name); // Ignoring the registerId parameter for now
            var splitPerYear    = new Splitter().SplitPerYear(monthlyAverages);

            var writer   = new StringWriter();
            var renderer = new MonthlyValueTextRenderer(CultureInfo.InvariantCulture);

            renderer.Render(splitPerYear, writer);

            var result   = writer.ToString();
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(result)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/csv");
            return(response);
        }
        private void SplitMonthlyClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var ts           = TsParser.ParseTimeseries(tbSource.Text);
                var tsMonthly    = new Periodizer().MonthlyAverage(ts);
                var splitPerYear = new Splitter().SplitPerYear(tsMonthly);

                var writer = new StringWriter();

                var renderer = new MonthlyValueTextRenderer(CultureInfo.CurrentCulture, ColumnSeparator);
                renderer.Render(splitPerYear, writer);

                tbResult.Text = writer.ToString();
            }
            catch (Exception ex)
            {
                tbResult.Text = ex.ToString();
            }
        }