private async Task <LcKbsDto> DownloadDateRange(DateTime dateFrom, DateTime dateTo) { //TODO zmenit na povodne var webClient = new HttpClient(); var allData = new LcKbsDto(); var date = dateFrom; while (date.Year <= dateTo.Year && date.Month <= dateTo.Month) { var url = new Uri(string.Format("{0}/?mesiac={1}&format=xml", LinkUrl, date.ToString("yyyyMM"))); var text = await webClient.GetStringAsync(url); var tempData = await CoreParser.Instance.MapStringData(text); foreach (var item in tempData.Days) { allData.Days.Add(item.Key, item.Value); } date = date.AddMonths(1); } return(allData); }
public void Load() { //TODO zmenit na povodne if (Application.Current.Properties.ContainsKey("DataStorage")) { var serializedStorage = Application.Current.Properties["DataStorage"] as string; if (string.IsNullOrEmpty(serializedStorage)) { return; } var serializer = new XmlSerializer(typeof(Storer[]), new XmlRootAttribute() { ElementName = "items" }); using (var reader = new StringReader(serializedStorage)) { var ser = new XmlSerializer(typeof(LcDayDto)); Data = new LcKbsDto(); Data.Days = (serializer.Deserialize(reader) as Storer[]).ToDictionary(i => i.Key, i => { var res = new LcDayDto(); using (var readerStorer = new StringReader(i.LcDay)) { res = ser.Deserialize(readerStorer) as LcDayDto; } return(res); }); } } else { Data = new LcKbsDto(); } }
private CoreStorage() { Data = new LcKbsDto(); Data.Days = new Dictionary <DateTime, LcDayDto>(); LinkUrl = "https://lc.kbs.sk"; }