Projekt

Obecné

Profil

Stáhnout (2.01 KB) Statistiky
| Větev: | Tag: | Revize:
1
using Parser.OutputInfo;
2
using ServerApp.Parser.InputData;
3
using ServerApp.Parser.OutputInfo;
4
using ServerApp.Parser.Parsers;
5
using System;
6
using System.Collections.Generic;
7
using System.Globalization;
8
using System.Threading;
9

    
10
namespace Parser.Parsers
11
{
12
    class CsvParser
13
    {
14

    
15
        string path;
16
        WeatherParser weatherParser;
17
        JisParser jisParser;
18
        LogInParser loginParser;
19

    
20
        public List<WeatherInfo> weatherList;
21
        public List<ActivityInfo> jisList;
22
        public List<ActivityInfo> loginList;
23

    
24
        public CsvParser()
25
        {
26
            TagInfo.CreateDictionaries();
27
            path = "data/";
28

    
29
            CsvDataLoader loader = new CsvDataLoader();
30

    
31
            weatherParser = new WeatherParser(loader);
32
            jisParser = new JisParser(loader);
33
            loginParser = new LogInParser(loader);
34
        }
35

    
36
        public void Parse()
37
        {
38
            var cultureInfo = CultureInfo.GetCultureInfo("en-GB");
39
            Thread.CurrentThread.CurrentCulture = cultureInfo;
40
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
41

    
42
            string pathWeather = path + "weather";
43
            string pathJis = path + "jis";
44
            string pathLogIn = path + "login";
45

    
46
            weatherList = weatherParser.ParseWeatherData(pathWeather);
47
            jisList = jisParser.ParseJisData(pathJis);
48
            loginList = loginParser.ParseLogInData(pathLogIn);
49

    
50
            Console.WriteLine("WEATHER");
51
            WriteToConsole(weatherList);
52
            Console.WriteLine("JIS");
53
            WriteToConsole(jisList);
54
            Console.WriteLine("LOGIN");
55
            WriteToConsole(loginList);
56
        }
57

    
58
        private void WriteToConsole<T>(List<T> list)
59
        {
60
            if (list == null)
61
            {
62
                Console.WriteLine("Unsuccessful parsing");
63
                return;
64
            }
65
            Console.WriteLine(list.Count);
66

    
67
            for (int i = 0; i < list.Count; i++)
68
                Console.WriteLine(list[i].ToString());
69
        }
70

    
71
    }
72
}
(1-1/6)