예제 #1
0
        private async Task StartUpload(Forecast forecast)
        {
            var historicalForecast = await _weatherService.GetHistoricalForecast();

            var intervalForecast = await _weatherService.GetIntervalForecast(historicalForecast);

            var model = _faultService.CalculateFaults(historicalForecast, intervalForecast);

            var fileStream = FileManager.GetXlsx(model);  //_faultService.GetFileWithFaults(model);

            try
            {
                await _storage.Upload(fileStream);

                forecast.FaultUpdateLastDate = DateTimeOffset.Now;
            }
            catch (Exception ex)
            {
                //if updating document is opened by user in browser, it will cause I.O block exception
            }
            finally
            {
                fileStream.Dispose();
            }
        }
예제 #2
0
        public async Task <IActionResult> ShowChart()
        {
            var currentForecast = await _weatherService.GetCurrentForecast();

            var current = JsonConvert.SerializeObject(currentForecast["current"]);
            var daily   = JsonConvert.SerializeObject(currentForecast["daily"]);

            _context.Forecasts.AsQueryable <Forecast>().AddOrUpdateByCityName(_context, current, daily);

            var historicalForecast = await _weatherService.GetHistoricalForecast();

            var intervalForecast = await _weatherService.GetIntervalForecast(historicalForecast);

            var model = _faultService.CalculateFaults(historicalForecast, intervalForecast);

            return(View("ShowChart", model));
        }