Hi,
I have been stuck on this for a few days and can't seem to work out what I am doing wrong.
There could be 500+ events (strings) in a list, some will contain a start time and some strings will contain the end time. Think of it as a clock in/out.
I am trying to store this in a SQLite database.
The strings are formatted like the following:
1CLD13640011101808030015170049
1CLD - ignore
1364 - event
001 - user
1 - area (there are 8 areas)
10 - Hour
18 - Minute
08 - Month
03 - Day
001 - eventID
5 - day of week
17 - year
0049 - ignore
I need to work out the start and end times.
if the event from above is 1173 then it means clock on
if the event from above is 1174 then it means clock off
However..
If the event before the event 1173 is event 1239, or event 1239 is after 1173 then I need to put the light_mode in my SQLite database as 50.
If there is no event 1239 before or after event 1173, then it needs to put the light_mode as 100.
If the event is 1174 then it means that it has finished. (event 1239 doesn't need to be before or after 1174 event)
Each event has an area it belongs to. Area's 1 - 8.
In my code below, I am processing all the area 1 start events and then doing area 2 events etc.
Then when that is done it's then processing all the finish events. This way all the start times are in the database already.
There can be multiple area start and finish events but if the event starts then it must finish before it can start again.
Based on my code it seems to only do some of the events for some reason.
Based on my screenshot below, this is what the database ends up looking like.
EventId 9 and below are all missing the finishing times.
But something I noticed, eventid 7 the finish time is before the event start time.
I have been stuck on this for a few days and can't work out what I am doing wrong. I most likely overlooked this and missed something obvious.
I have attached the project I am using and hoping someone can help me out.