Esempio n. 1
0
        private StationsLevelReportViewModel GetStationsReportViewModel(CommandLineViewModel commandLine)
        {
            try
            {
                var reportView = new StationsLevelReportViewModel
                {
                    ReportType = string.IsNullOrEmpty(commandLine.Parameter) ?
                                 _config.GetDefaultParameter() : commandLine.Parameter.ToLower()
                };

                var stations = _monitor.GetStationReferencesAndNamesForRiver(commandLine.RiverName).Result;

                if (stations != null && stations.Any())
                {
                    reportView.RiverBasedStationNames = string.Join(", ", stations.Values);

                    var stationReferences = stations.Keys.ToList();

                    foreach (var stationRef in stationReferences)
                    {
                        reportView.StationBasedRiverLevels.Add(
                            _monitor.GetRiverWaterLevelDataAtStation(stationRef, commandLine).Result);
                    }
                }

                return(reportView);
            }
            catch (Exception ex)
            {
                _logger.LogException(ex, _config.GetDefaultLoggingPath());
                return(null);
            }
        }
Esempio n. 2
0
        private string JoinFilters(CommandLineViewModel commandObj)
        {
            var joinedFilters = new StringBuilder();

            joinedFilters.Append("-");

            joinedFilters.Append(string.IsNullOrEmpty(commandObj.Parameter) ?
                                 _config.GetDefaultParameter() : commandObj.Parameter.ToLower());

            joinedFilters.Append("-");
            joinedFilters.Append(commandObj.Limit);
            joinedFilters.Append("-");
            joinedFilters.Append(commandObj.Days);

            return(joinedFilters.ToString());
        }