Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 99e5517e

Přidáno uživatelem Alex Konig před téměř 4 roky(ů)

re #8842 Start testing

Zobrazit rozdíly:

Server/ServerApp/Parser/Parsers/DataParser.cs
17 17
    /// Data parsed from 7am (included) to 18pm (included)
18 18
    /// </summary>
19 19
    /// <author>A. Konig</author>
20
    class DataParser : IDataParser
20
    public class DataParser : IDataParser
21 21
    {
22 22
        /// <summary> Data downloader </summary>
23 23
        DataDownloader downloader;
......
29 29
        /// <summary> Login data parser </summary>
30 30
        LogInParser loginParser;
31 31

  
32
        /// <summary> WeatherInfo </summary>
33
        List<WeatherInfo> weatherList;
34
        public new List<WeatherInfo> WeatherList { get => weatherList; }
35
        /// <summary> ActivityInfo repersenting overall activity </summary>
36
        List<ActivityInfo> attendanceList;
37
        public new List<ActivityInfo> AttendanceList { get => attendanceList; }
38

  
39 32
        /// <summary> ActivityInfo representing jis activity </summary>
40 33
        List<ActivityInfo> jisList;
41 34
        /// <summary> ActivityInfo representing login activity</summary>
......
89 82
            var jisFiles = downloader.GetData(pathJis, start, end);
90 83
            var loginFiles = downloader.GetData(pathLogIn, start, end);
91 84

  
92
            weatherList = weatherParser.ParseWeatherData(weatherFiles, startTime, endTime, wholeDay, interval);
85
            WeatherList = weatherParser.ParseWeatherData(weatherFiles, startTime, endTime, wholeDay, interval);
93 86
            jisList = jisParser.ParseJisData(jisFiles, startTime, endTime, wholeDay, interval);
94 87
            loginList = loginParser.ParseLogInData(loginFiles, startTime, endTime, wholeDay, interval);
95 88

  
......
102 95

  
103 96
            //WriteToConsole(AddListToOne(jisList));
104 97

  
105
            MergeAttendance();
98
            AttendanceList = MergeAttendance(jisList, loginList);
106 99

  
107 100
            //Console.WriteLine("MERGED IN ONE LIST");
108 101
            //WriteToConsole(attendanceList);
109 102

  
110
            if (weatherList.Count == 0 || attendanceList.Count == 0)
103
            if (WeatherList.Count == 0 || AttendanceList.Count == 0)
111 104
                return false;
112 105

  
113 106
            return true;
114 107
        }
115 108

  
109

  
116 110
        /// <summary>
117
        /// Merges ActivityInfo lists with jis and login activity into one
111
        /// Merges two lists into one
118 112
        /// Adds information from the same time period together, doesn't change the rest
119 113
        /// </summary>
120
        private void MergeAttendance()
114
        /// <param name="jisList">List to merge</param>
115
        /// <param name="loginList">List to merge</param>
116
        /// <returns>Merged list</returns>
117
        private List<ActivityInfo> MergeAttendance(List<ActivityInfo> jisList, List<ActivityInfo> loginList)
121 118
        {
122
            attendanceList = new List<ActivityInfo>();
119
            List<ActivityInfo> res = new List<ActivityInfo>();
120

  
121
            if (jisList == null && loginList == null)
122
                return res;
123
            else if (jisList == null)
124
                return loginList;
125
            else if (loginList == null)
126
                return jisList;
123 127

  
124 128
            int indexJis = 0, indexLogin = 0;
125 129
            while (true)
......
139 143
                    if (jisTag == loginTag)
140 144
                    {
141 145
                        jis.amount += login.amount;
142
                        attendanceList.Add(jis);
146
                        res.Add(jis);
143 147
                        indexJis++; indexLogin++;
144 148
                    }
145 149

  
146
                    if (jisTag < loginTag)
150
                    else if (jisTag < loginTag)
147 151
                    {
148 152
                        indexJis++;
149
                        attendanceList.Add(jis);
153
                        res.Add(jis);
150 154
                    }
151 155

  
152
                    if (jisTag > loginTag)
156
                    else if (jisTag > loginTag)
153 157
                    {
154 158
                        indexLogin++;
155
                        attendanceList.Add(login);
159
                        res.Add(login);
156 160
                    }
157 161

  
158 162
                }
159 163

  
160 164
                // if jis time is smaller -> add jis and move
161
                if (jis.startTime < login.startTime)
165
                else if (jis.startTime < login.startTime)
162 166
                {
163 167
                    indexJis++;
164
                    attendanceList.Add(jis);
168
                    res.Add(jis);
165 169
                }
166 170

  
167 171
                // if login time is smaller -> add login and move
168
                if (login.startTime < jis.startTime)
172
                else if (login.startTime < jis.startTime)
169 173
                {
170 174
                    indexLogin++;
171
                    attendanceList.Add(login);
175
                    res.Add(login);
172 176
                }
173 177

  
174 178
            }
175 179

  
180
            return res;
176 181
        }
177 182

  
178 183
        /// <summary>

Také k dispozici: Unified diff