예제 #1
0
        /// <summary>
        /// Method take Kolejki type as parameter and serialize it to JSON string
        /// </summary>
        /// <param name="data"></param>
        /// <returns>string type with JSON</returns>
        public string Execute(Kolejki data)
        {
            var result = JsonConvert.SerializeObject(data);

            Console.WriteLine(result);
            return(result);
        }
예제 #2
0
        /*
         * public string Execute(Kolejki data)
         * {
         *  StringBuilder result = new StringBuilder();
         *  foreach (var item in data.Okienka)
         *  {
         *      //Correction Required - Need to equalize column => .PadRight() and correct unit tests
         *      result.AppendLine($"{item.NazwaGrupy.Trim()}: Liczba osób w kolejce: {item.LiczbaOsobWKolejce}, Czas Oczekiwania: {item.CzasOczekiwania}min");
         *  }
         *
         *  return result.ToString();
         * }
         */
        public string Execute(Kolejki data)
        {
            StringBuilder result = new StringBuilder();

            foreach (var item in data.Okienka)
            {
                //Correction Required - Need to equalize column => .PadRight() and correct unit tests
                result.AppendLine($"{item.NazwaGrupy.Trim()}: Liczba osób w kolejce: {item.LiczbaOsobWKolejce}, Czas Oczekiwania: {item.CzasOczekiwania}min");
            }

            return(result.ToString());
        }
예제 #3
0
        /// <summary>
        /// Geting data from website
        /// </summary>
        /// <param name="zomNumber">Numer zespołu obsługi klienta</param>
        /// <returns>Kolejki</returns>
        public Kolejki GetData(int zomNumber)
        {
            if (zomNumber < 0 || zomNumber > 4)
            {
                throw new Exception("Zly numer ZOM");
            }
            var           client     = new HttpClient();
            XmlSerializer serializer = new XmlSerializer(typeof(Kolejki));
            var           xmlStream  = client.GetStreamAsync($"http://www.gdansk.pl/files/xml/qmatic-zom{zomNumber}.xml").Result;
            Kolejki       result     = (Kolejki)serializer.Deserialize(xmlStream);

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Data filter
        /// </summary>
        /// <param name="data"></param>
        /// <returns>Filtered data where queue > 1</returns>
        public Kolejki Filter(Kolejki data)
        {
            //How to do with LINQ???
            //var moreThenOne = data.Grupa.Where<Grupa>(x => int.Parse(x.LiczbaOsobWKolejce) > 1);
            Kolejki kolejki = new Kolejki
            {
                Okienka = new List <Okienko>()
            };

            foreach (var item in data.Okienka)
            {
                if (int.Parse(item.LiczbaOsobWKolejce) > 1)
                {
                    kolejki.Okienka.Add(item);
                }
            }
            return(kolejki);
        }