Projekt

Obecné

Profil

« Předchozí | Další » 

Revize d39750f3

Přidáno uživatelem Alex Konig před více než 3 roky(ů)

re #8682 Modified parser to aggregate data according to buildings. Also added a method that merges information about jis and webauth activity into one list.

Zobrazit rozdíly:

Server/ServerApp/Parser/Parsers/LogInParser.cs
73 73
            List<LogInInstance> list = loader.LoadLoginFile(path);
74 74

  
75 75
            // data for each faculty
76
            int[] recordedAmount = new int[TagInfo.faculties.Length];
76
            int[] recordedAmount = new int[TagInfo.buildings.Length];
77 77
            // min/max hour taken into account
78 78
            int[] minmaxHour = new int[] { 7, 18 };
79 79
            // interval length
......
93 93
                if (!date.Equals(lastStartDay))
94 94
                {
95 95
                    // data for each faculty separate
96
                    for (int k = 0; k < TagInfo.faculties.Length; k++)
96
                    for (int k = 0; k < TagInfo.buildings.Length; k++)
97 97
                    {
98
                        ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartDay, range); 
98
                        ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartDay, range); 
99 99
                        loginInfo.Add(dayInfo);
100 100
                    }
101 101

  
102
                    recordedAmount = new int[TagInfo.faculties.Length];
102
                    recordedAmount = new int[TagInfo.buildings.Length];
103 103
                    lastStartDay = date;
104 104
                }
105 105

  
......
107 107
                if (TagInfo.buildingTags.ContainsKey(place))
108 108
                {
109 109
                    int index = TagInfo.buildingTags[place];
110
                    //Console.WriteLine(place + " " + index);
111

  
110 112
                    // to all
111 113
                    if (index == -1)
112
                        for (int l = 0; l < TagInfo.faculties.Length; l++)
114
                        for (int l = 0; l < TagInfo.buildings.Length; l++)
113 115
                            recordedAmount[l] += list[i].amount;
114
                    // to first two
115
                    else if (index == -2)
116
                    {
117
                        recordedAmount[0] += list[i].amount;
118
                        recordedAmount[1] += list[i].amount;
119
                    }
120 116
                    else
121 117
                        recordedAmount[index] += list[i].amount;
122 118

  
123 119
                }
124 120
                else
125 121
                {
126
                    // TODO uknown code handling
127
                    Console.WriteLine("Unknown code " + list[i].building);
122
                    // TODO uknown code handling -> to file?
123
                    // Console.WriteLine("Unknown code " + list[i].building);
128 124
                }
129 125

  
130 126
            }
131 127

  
132 128
            // last day
133
            for (int k = 0; k < TagInfo.faculties.Length; k++)
129
            for (int k = 0; k < TagInfo.buildings.Length; k++)
134 130
            {
135
                ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartDay, range);
131
                ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartDay, range);
136 132
                loginInfo.Add(dayInfo);
137 133
            }
138 134

  
......
166 162
            for (int i = 0; i < to.Length; i++)
167 163
            {
168 164
                to[i] = minmaxHour[0] + interval * (i + 1);
169
                data[i] = new int[TagInfo.faculties.Length];
165
                data[i] = new int[TagInfo.buildings.Length];
170 166
            }
171 167
            
172 168
            // first day
......
191 187
                        DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0);
192 188

  
193 189
                        // data for each faculty separate
194
                        for (int l = 0; l < TagInfo.faculties.Length; l++)
190
                        for (int l = 0; l < TagInfo.buildings.Length; l++)
195 191
                        {
196
                            ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[l], data[k][l], stTime, interval);
192
                            ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[l], data[k][l], stTime, interval);
197 193
                            loignInfo.Add(dayInfo);
198 194
                        }
199 195

  
200
                        data[k] = new int[TagInfo.faculties.Length];
196
                        data[k] = new int[TagInfo.buildings.Length];
201 197
                    }
202 198
                    lastStartTime = date;
203 199
                }
......
219 215
                    int faculty = TagInfo.buildingTags[place];
220 216
                    // to all
221 217
                    if (faculty == -1)
222
                        for (int l = 0; l < TagInfo.faculties.Length; l++)
218
                        for (int l = 0; l < TagInfo.buildings.Length; l++)
223 219
                            data[index][l] += list[i].amount;
224 220
                    // to first two
225 221
                    else if (faculty == -2)
......
233 229
                }
234 230
                else
235 231
                {
236
                    // TODO uknown code handling
237
                    Console.WriteLine("Unknown code " + list[i].building);
232
                    // TODO uknown code handling -> write to file?
233
                    // Console.WriteLine("Unknown code " + list[i].building);
238 234
                }
239 235

  
240 236
            }
......
244 240
                DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0);
245 241

  
246 242
                // data for each faculty separate
247
                for (int l = 0; l < TagInfo.faculties.Length; l++)
243
                for (int l = 0; l < TagInfo.buildings.Length; l++)
248 244
                {
249
                    ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[l], data[k][l], stTime, interval);
245
                    ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[l], data[k][l], stTime, interval);
250 246
                    loignInfo.Add(dayInfo);
251 247
                }
252 248
            }

Také k dispozici: Unified diff