Exemplo n.º 1
0
        private static void ParseEvents(string eventFile, string outputFolder)
        {
            using (StreamReader reader = new StreamReader(eventFile))
            {
                RawEvents       rawEvents       = RawEvents.FromJson(reader.ReadToEnd());
                ProcessedEvents processedEvents = new ProcessedEvents();

                foreach (RawEvent rawEvent in rawEvents.Events)
                {
                    if (int.Parse(rawEvent.Price) < 0)
                    {
                        continue;
                    }

                    if (IsIgnoredEvent(rawEvent.Name))
                    {
                        continue;
                    }

                    if (HasVariablePrice(rawEvent.Name))
                    {
                        rawEvent.Price = "Varies";
                    }

                    ProcessedEvent processedEvent = ProcessedEvent.FromRawEvent(rawEvent);
                    processedEvents.Events.Add(processedEvent);
                }

                string outputFileEvents = Path.Combine(outputFolder, "StoreEvents.json");

                GenerateEventsOutput(processedEvents, outputFileEvents);
            }
        }
Exemplo n.º 2
0
        private static void GenerateEventsOutput(ProcessedEvents events, string outputFile)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(outputFile));

            using (StreamWriter writer = new StreamWriter(outputFile))
            {
                writer.WriteLine(events.ToJson());
            }
        }