Active min of that day + Not Active min of that day divided by 60
Code: Select all
#NoEnv
#SingleInstance, Force
myFile =
(
"Date","Username","Computername","State","Minutes at State","State Start time"
"12-17-2017","YATENDRA","YATENDRA-PC","Active","1","06:14 AM"
"12-29-2017","YATENDRA","YATENDRA-PC","Active","1","02:24 AM"
"12-29-2017","YATENDRA","YATENDRA-PC","Active","4","02:25 AM"
"12-17-2017","YATENDRA","YATENDRA-PC","Active","1","06:15 AM"
"12-17-2017","YATENDRA","YATENDRA-PC","Not Active","1","06:08 AM"
"12-17-2017","YATENDRA","YATENDRA-PC","Active","3","06:12 AM"
)
Gui, Add, Edit, w80 vID, 303016
Gui, Add, Button, x+10, Go
Gui, Add, ListView, xm w330 Grid, ID|Date|active|NotActive
LV_ModifyCol(1, "50")
LV_ModifyCol(2, "70")
LV_ModifyCol(3, "50 Center")
LV_ModifyCol(4, "80 Center")
Gui, Show
Return
GuiClose:
ExitApp
;-------------------------------------------------------------------------------
ButtonGo:
;-------------------------------------------------------------------------------
GuiControlGet, ID
;~ FileRead, myFile, D:\Network Drive\Timetracker\%ID%\Timetrack.csv
TT := new Timetrack(ID)
Loop, Parse, myFile, `n, `r
If (A_Index > 1) ; skip header
TT.add( toRecord(A_LoopField) )
LV_Delete()
For Date, AllRecords in TT
LV_Add("", ID, Date, AllRecords.Active, AllRecords.NotActive)
Return
;-------------------------------------------------------------------------------
toRecord(Line) {
;-------------------------------------------------------------------------------
Record := []
Loop, Parse, Line, CSV
If A_Index in 1,4,5
Record.Push(A_LoopField)
Return, Record
}
;-------------------------------------------------------------------------------
class Timetrack {
;-------------------------------------------------------------------------------
add(Record) {
Date := Record[1]
Bool := StrReplace(Record[2], A_Space)
Value := Record[3]
If Not this.hasKey(Date)
this[Date] := {Active: 0, NotActive: 0}
this[Date][Bool] += Value
}
}
Any kind of help will be or right direction is much appreciated.