public GraphStepProxy GetStep(int id) { GraphStep step = GraphModel.GetStep(id); GraphStepProxy proxy = new GraphStepProxy(step); return(proxy); }
public GraphStepProxy FindStepByName(string name) { GraphStep step = GraphModel.FindStepByName(name); GraphStepProxy proxy = new GraphStepProxy(step); return(proxy); }
public GraphStepProxy FindStepByNumber(int number) { GraphStep step = GraphModel.FindStepByNumber(number); GraphStepProxy proxy = new GraphStepProxy(step); return(proxy); }
public GraphStepProxy FindStepByNumber(int number) { GraphStep step = GraphSequence.FindStepByNumber(number); return(new GraphStepProxy(step)); }
internal GraphStepProxy(GraphStep step) { GraphStep = step; }
internal static GraphStepProxy GraphStepProxy(GraphStep step) { return(new GraphStepProxy(step)); }
public static IList <IJsonResult> GetWeatherData(DateTime start, DateTime end, GraphStep step) { string key = GenerateJson("../../../WeatherAPI.txt", start, end, step); using (var webClient = new System.Net.WebClient()) { var json = webClient.DownloadString(key); JObject search = JObject.Parse(json); IList <JToken> results = search["data"].Children().ToList(); switch (step) { case GraphStep.Day: { return(new List <IJsonResult>(results .Select(result => JsonConvert.DeserializeObject <DayResult>(result.ToString())).ToList())); } case GraphStep.Week: { List <IJsonResult> list = new List <IJsonResult>(results.Select(result => JsonConvert.DeserializeObject <WeekResult>(result.ToString())).ToList()); return(GetWeekResults(list)); } case GraphStep.Month: { return(new List <IJsonResult>(results.Select(result => JsonConvert.DeserializeObject <MonthResult>(result.ToString())).ToList())); } case GraphStep.Year: { List <IJsonResult> list = new List <IJsonResult>(results.Select(result => JsonConvert.DeserializeObject <YearResult>(result.ToString())).ToList()); return(GetYearResults(list)); } default: throw new Exception("Wrong step of change"); } } }
private static string GenerateJson(string keyPath, DateTime start, DateTime end, GraphStep step) { string _step = ""; string startDate = ""; string endDate = ""; switch (step) { case GraphStep.Day: case GraphStep.Week: { _step = "daily"; startDate = start.ToString("yyyy-MM-dd"); endDate = end.ToString("yyyy-MM-dd"); break; } case GraphStep.Month: case GraphStep.Year: { _step = "monthly"; startDate = start.ToString("yyyy-MM"); endDate = end.ToString("yyyy-MM"); break; } } string id = File.ReadAllLines(keyPath)[0]; //id метеостанции string apiKey = File.ReadAllLines("../../../WeatherAPI.txt")[1]; // api Key return ($@"https://api.meteostat.net/v1/history/{_step}?station={id}&start={startDate}&end={endDate}&key={apiKey}"); }