Ejemplo n.º 1
0
        private static List <ReuterCurrency> ExtractReutersCurs()
        {
            StringBuilder ReutersSoap = GenerateReutersSoap();
            XmlDocument   document    = GetDocument(ReutersSoap.ToString());

            if (document == null)
            {
                return(null);
            }
            List <ReuterCurrency> reuterCurrencies = new List <ReuterCurrency>();
            XmlNode rs = document.ChildNodes[1].FirstChild.FirstChild.FirstChild.FirstChild;

            foreach (XmlNode node in rs.ChildNodes)
            {
                ReuterCurrency reuterCur = new ReuterCurrency();
                foreach (XmlNode childNode in node)
                {
                    switch (childNode.Name)
                    {
                    case ("num_code"):
                        int code = Convert.ToInt32(childNode.InnerText.Trim());
                        reuterCur.Code = code.ToString("000");
                        break;

                    case ("val"):
                        reuterCur.Price = childNode.InnerText.Trim();
                        break;

                    case ("dir"):
                        reuterCur.Dir = childNode.InnerText.Trim();
                        break;
                    }
                }
                reuterCurrencies.Add(reuterCur);
            }
            ReuterCurrency eur = new ReuterCurrency
            {
                Code  = "978",
                Dir   = "0",
                Price = "1"
            };
            ReuterCurrency usd = new ReuterCurrency
            {
                Code  = "840",
                Dir   = "0",
                Price = "1"
            };

            reuterCurrencies.Add(eur);
            reuterCurrencies.Add(usd);
            return(reuterCurrencies);
        }
Ejemplo n.º 2
0
 private static void Write(StreamWriter fileWriter, ReuterCurrency reutCurrency)
 {
     if (!string.IsNullOrEmpty(reutCurrency.ISOCode) && !string.IsNullOrEmpty(reutCurrency.Name))
     {
         string date1 = reqDate.ToString("M/d/yyyy", CultureInfo.InvariantCulture);
         fileWriter.Write($"{reutCurrency.ISOCode},");
         fileWriter.Write($"{reutCurrency.Price},");
         fileWriter.Write($"{reutCurrency.Price},");
         fileWriter.Write($"{DateTime.Now.TimeOfDay:hh\\:mm\\:ss},", CultureInfo.InvariantCulture);
         fileWriter.Write($"{date1},");
         fileWriter.Write($"{reutCurrency.Name}\r\n");
     }
 }