public void AddWeatherGraph(string cityName, string parameters, DateTime startTime, DateTime endTime, string graphName, WeatherType.ParameterEnum parameterType, int interval) { if (cityName == null || cityName == "") { throw new Exception("Please give a name of cities in Finland"); } Dictionary <string, IDataSeries> combined_graphs = new Dictionary <string, IDataSeries>(); try { TimeHandler.IsTimeValid(startTime, endTime); IsPlotNameValid(graphName); combined_graphs = FMI.GetAllData(startTime, endTime, interval, graphName, cityName, parameters, parameterType); } catch (AggregateException ae) { Console.WriteLine("FMIAction failed:"); foreach (var ex in ae.InnerExceptions) { Console.WriteLine(ex.Message); throw new Exception(ex.Message); } } foreach (var graph in combined_graphs) { graph.Value.Name = graphName + " (" + graph.Value.Name + ")"; DataPlot.Data.Add(graph.Value); } }
public void AddPowerGraphAction(PowerType powerType, DateTime startTime, DateTime endTime, string graphName) { if (powerType == null) { throw new Exception("Please choose the category"); } if (TimeHandler.DataTooBig(startTime, endTime, powerType.Interval)) { return; } startTime = TimeHandler.ConvertToLocalTime(startTime); endTime = TimeHandler.ConvertToLocalTime(endTime); try { TimeHandler.IsTimeValid(startTime, endTime); IsPlotNameValid(graphName); var series_task = Task.Run(() => Fingrid.Get(powerType, startTime, endTime)); try { series_task.Wait(); var series = series_task.Result; series.Name = graphName + " (" + powerType.Source + ")"; DataPlot.Data.Add(series); } catch (AggregateException e) { Console.WriteLine("Cannot add data to plot"); foreach (var ex in e.InnerExceptions) { Console.WriteLine(ex.Message); } throw new Exception("Cannot add data to plot"); } } catch (Exception e) { throw e; } }