public IEnumerable <LogEvent> Read(TextReader reader)
        {
            var    itemParser = new EventsParser();
            var    fieldMap   = (FieldMapping)null;
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith("#", StringComparison.OrdinalIgnoreCase))
                {
                    ParseHeader(line, fieldsLine => { fieldMap = new FieldsParser().Parse(fieldsLine); });
                    continue;
                }

                if (fieldMap == null)
                {
                    continue;
                }

                yield return(itemParser.Parse(line, fieldMap));
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            EmailService       emailService = new EmailService();
            EventsParser       eventsParser = new EventsParser();
            DataBaseOperations dbOperations = new DataBaseOperations();

            var eventList = eventsParser.Parse(new ParseConfiguration()
            {
                City = ParseCity(ConfigurationManager.AppSettings["city"]),
                Type = ConfigurationManager.AppSettings["type"],
                Cost = ParseCost(ConfigurationManager.AppSettings["cost"])
            });

            var events = eventList as IList <Event> ?? eventList.ToList();

            ShowParsedList(events);

            Console.WriteLine();
            while (true)
            {
                Console.WriteLine("*** calling MyMethod *** ");
                dbOperations.Insert(events);

                try
                {
                    var eventsListFromDb = dbOperations.ReadAllToList();
                    emailService.Send(eventsListFromDb);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.WriteLine("\n All done");
                Thread.Sleep(60 * 1000 * int.Parse(ConfigurationManager.AppSettings["time"]));
            }
        }