// Converting of raw data to managable form private ExchangeRateTicket ParseDayTicket(string text, DateTime date) { byte[] bytes = Encoding.UTF8.GetBytes(text); ExchangeRate er = null; ExchangeRateTicket ticket = new ExchangeRateTicket(); List <ICurrencyData> data = new List <ICurrencyData>(); using (MemoryStream ms = new MemoryStream(bytes)) { XmlSerializer serializer = new XmlSerializer(typeof(ExchangeRate)); er = (ExchangeRate)serializer.Deserialize(ms); } if (er.Country != null) { foreach (var cur in er.Country) { data.Add(new ERDataBase(cur.ID, null, cur.Country, cur.quota, (float)cur.FXcashless.Buy, (float)cur.FXcashless.Sale)); ticket.AddExchangeRateData(data[data.Count - 1]); } ticket.TicketDate = date; return(ticket); } else { return(null); } }
private ExchangeRateTicket ParseYearExchangeRateData(string[] section, List <ICurrencyMetada> currencyInfos) { ExchangeRateTicket ticket = new ExchangeRateTicket(); for (int i = 1; i < section.Length; i++) { float buy = float.Parse(section[i], CultureInfo.GetCultureInfo("cs-CZ")); ICurrencyMetada metada = currencyInfos[i - 1]; ERDataBase data = new ERDataBase(metada, buy, null); ticket.AddExchangeRateData(data); } return(ticket); }
// Converting of raw data to managable form private ExchangeRateTicket ParseDayTicket(string text, DateTime date) { List <RootObject> obj = JsonConvert.DeserializeObject <List <RootObject> >(text); ExchangeRateTicket ticket = new ExchangeRateTicket(); List <ICurrencyData> data = new List <ICurrencyData>(); foreach (var cur in obj[0].exchangeRates) { data.Add(new ERDataBase(cur.currencyISO, cur.currencyFullName, cur.country, cur.currencyUnit, cur.cashBuy, cur.cashSell)); ticket.AddExchangeRateData(data[data.Count - 1]); } ticket.TicketDate = date; return(ticket); }
private void ParseDayTicketBody(string[] body, ref ExchangeRateTicket ticket) { foreach (string line in body) { string[] sections = line.Split('|', StringSplitOptions.RemoveEmptyEntries); string country = sections[0]; string name = sections[1]; int quantity = int.Parse(sections[2]); string isoName = sections[3]; float buy = float.Parse(sections[4], CultureInfo.GetCultureInfo("cs-CZ")); ICurrencyData data = new ERDataBase(isoName, name, country, quantity, buy, null); ticket.AddExchangeRateData(data); } }