Exemple #1
0
        public void GetCurrentExchangeRates()
        {
            var mnbService = new MNBArfolyamServiceSoapClient();
            var request    = new GetCurrentExchangeRatesRequestBody();
            var response   = mnbService.GetCurrentExchangeRates(request);
            var result     = response.GetCurrentExchangeRatesResult;

            var xml = new XmlDocument();

            xml.LoadXml(result);

            foreach (XmlElement element in xml.DocumentElement)
            {
                //DocumentElement - MNBCurrentExchangeRates
                //element         - Day (has only 1 attribute (current date))
                // element childNodes - Rate (every Rate is a node with attributes )

                foreach (XmlElement item in element.ChildNodes)
                {
                    var rate = new RateData();
                    Rates.Add(rate);

                    rate.Currency = item.GetAttribute("curr");

                    var unit  = decimal.Parse(item.GetAttribute("unit"));
                    var value = decimal.Parse(item.InnerText.ToString().Replace(',', '.')); //default separator conflict
                    if (unit != 0)
                    {
                        rate.Value = value / unit;
                    }
                }
            }
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            client = new MNBArfolyamServiceSoapClient();
            string result = client.GetInfo();

            ProcessInfo(result);
            result = client.GetCurrentExchangeRates();
            ProcessRates(result);
            atvaltandoosszeg.Content = osszeg;
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e) //Mai
        {
            string    answer = client.GetCurrentExchangeRates();
            XDocument xml    = XDocument.Parse(answer);     //xml-ezés

            //Rate (új osztály, az árfolyam adatokról)

            DataGrid.ItemsSource = ProcessCurrentExchangeRates(xml);        //a Grid auto kinyeri hogy milyen oszlopain lesznek.
            //a mai dátumot lekérdeztük
            //De az is kell, hogy adott idő közöttit kapjunk vissza.
        }
        public string GetCurrentRates()
        {
            using (var client = new MNBArfolyamServiceSoapClient())
            {
                var result = client.GetCurrentExchangeRates(new GetCurrentExchangeRatesRequestBody());

                var converter = new Converter <MNBCurrentExchangeRates>();

                var subject = converter.Deserialize(result.GetCurrentExchangeRatesResult);

                return(converter.Serialize(subject));
            }
        }
        static void Main(string[] args)
        {
            MNBArfolyamServiceSoapClient client = new MNBArfolyamServiceSoapClient();

            try
            {
                var resp       = client.GetCurrentExchangeRates(new GetCurrentExchangeRatesRequestBody());
                var respString = resp.GetCurrentExchangeRatesResult;
                Console.WriteLine(resp.GetCurrentExchangeRatesResult);

                XDocument xdoc = XDocument.Parse(respString);
                Console.WriteLine(xdoc);

                // megjeleníti a XML tag-ek nélkül
                var Rates = xdoc.Descendants("Rate");
                foreach (var item in Rates)
                {
                    string[] row = new string[3];
                    row[0] = item.Attribute("curr").Value;
                    row[1] = item.Attribute("unit").Value;
                    row[2] = item.Value;
                    Console.WriteLine(row[0] + row[1] + row[2]);
                }

                // Nap kinyérése az XML-ből
                var Day = xdoc.Descendants("Day");
                foreach (var item in Day)
                {
                    Console.WriteLine("Aktuális nap: {0}", item.Attribute("date").Value);
                }

                // EURÓ kinyerése az XML-ből
                var euro = xdoc.Descendants("Rate");
                foreach (var item in euro)
                {
                    if (item.Attribute("curr").Value == "EUR")
                    {
                        Console.WriteLine("Euró mai árfolyama {0}", item.Value);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.ReadLine();
        }
Exemple #6
0
        private static void Main(string[] args)
        {
            MNBArfolyamServiceSoapClient client = new MNBArfolyamServiceSoapClient();
            String currentExchangeRates = client.GetCurrentExchangeRates();
            XDocument doc = XDocument.Parse(currentExchangeRates);
            // Console.WriteLine(doc.ToString());
            XElement currentDay = doc.Root.Descendants("Day").First();
            // Console.WriteLine(currentDay.ToString());
            XElement eurEchangeRate = currentDay.Descendants("Rate").Where(x => ((String)x.Attribute("curr")).Equals("EUR") ).First();
            // Console.WriteLine(eurEchangeRate.ToString());
            double eur2huf = Double.Parse(eurEchangeRate.Value);
            Console.WriteLine("EUR 2 HUF: " + eur2huf);
            String value = doc.Root.Descendants("Rate").Where(x => ((String)x.Attribute("curr")).Equals("EUR")).First().Value;
            Console.WriteLine("EUR 2 HUF: " + value);

            String demo = client.GetExchangeRates("2004-07-14", "2004-07-16", "EUR,USD");
            XDocument docDemo = XDocument.Parse(demo);
            Console.WriteLine(docDemo.ToString());
        }