Пример #1
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (Parameters.TrackActivity == true)
     {
         ActivitySnapshot snapshot = monitor.GetActivitySnapshot();
         ActivityTracker.RegisterSnapshot(snapshot);
         this.RefreshStatus(snapshot);
     }
 }
Пример #2
0
 private void RefreshStatus(ActivitySnapshot snapshot)
 {
     statusLabel.Text      = snapshot.App.Name;
     applicationLabel.Text = snapshot.ApplicationTitle;
     if (snapshot.WindowTitle == snapshot.ApplicationTitle)
     {
         titleLabel.Text = "";
     }
     else
     {
         titleLabel.Text = snapshot.WindowTitle;
     }
     documentLabel.Text = snapshot.DocumentName;
     statsLabel.Text    = "keyboard: " + snapshot.KeyboardIntensity.ToString("F2") + ", mouse: " + snapshot.MouseIntensity.ToString("F2");
 }
Пример #3
0
 private void RefreshStatus(ActivitySnapshot snapshot)
 {
     processLabel.Text = snapshot.App.Name;
     titleLabel.Text   = snapshot.ApplicationTitle;
     if (snapshot.WindowTitle == snapshot.ApplicationTitle)
     {
         windowLabel.Text = "";
     }
     else
     {
         windowLabel.Text = snapshot.WindowTitle;
     }
     documentUrlLabel.Text = snapshot.DocumentUrl + " [" + SystemInfo.GetUrlRetrievalTime().ToString("F0") + " ms]";
     statsLabel.Text       = "keyboard: " + snapshot.KeyboardIntensity.ToString("F2") + ", mouse: " + snapshot.MouseIntensity.ToString("F2");
 }
Пример #4
0
        public ActivitySnapshot GetActivitySnapshot()
        {
            string path = SystemInfo.GetTopWindowPath();
            string windowTitle, applicationTitle;

            SystemInfo.GetTopWindowText(out windowTitle, out applicationTitle);

            // Prepare AppInfo object
            AppInfo appInfo = GetApp(path);

            string doc = "";;

            if (appInfo.Name == "chrome.exe")
            {
                doc = SystemInfo.GetChromeUrl();
            }

            if (appInfo.Name == "firefox.exe")
            {
                doc = SystemInfo.GetFirefoxUrl();
            }

            if (appInfo.Name == "devenv.exe")
            {
                //doc = SystemInfo.GetVSTab();
            }

            // Measure the time span since the previous snapshot
            DateTime end    = DateTime.Now;
            TimeSpan length = end - begin;

            // Create an activity data
            ActivitySnapshot data =
                new ActivitySnapshot
            {
                Time              = begin,
                App               = appInfo,
                ApplicationTitle  = applicationTitle,
                WindowTitle       = windowTitle,
                DocumentName      = doc,
                KeyboardIntensity = ActivitySnapshot.GetIntensity(keyPressCount, 6, length),
                MouseIntensity    = ActivitySnapshot.GetIntensity((int)mouseDistance, 1000, length)
            };

            Reset(end);

            return(data);
        }
Пример #5
0
        public static void RegisterSnapshot(ActivitySnapshot snapshot)
        {
            DateTime currTimePoint = GetTimePoint(snapshot.Time, Parameters.LogTimeUnit);

            if (snapshot.IsWarm)
            {
                lastActivityTime = snapshot.Time;
                SetUserStatus(UserStatus.Active);
                MaybeCommitSummary(currTimePoint);  // because a warm snapshot guarantees that none of the existing snapshots will be removed
            }
            else
            {
                TimeSpan inactivityTime = (snapshot.Time - lastActivityTime);
                if (inactivityTime.TotalSeconds >= Parameters.InactivityThreshold_Away)
                {
                    SetUserStatus(UserStatus.Away);

                    // ...and remove previous snapshots which also had no keyboard nor mouse actions
                    while (activeSnapshots.Count >= 1 && activeSnapshots.Last().IsWarm == false)
                    {
                        activeSnapshots.RemoveAt(activeSnapshots.Count - 1);
                    }

                    MaybeCommitSummary(currTimePoint);  // because no further snapshots will be removed (this is a delayed commit)
                }
                else if (inactivityTime.TotalSeconds >= Parameters.InactivityThreshold_Idle)
                {
                    SetUserStatus(UserStatus.Passive);
                }
            }

            if (userStatus == UserStatus.Active || userStatus == UserStatus.Passive)
            {
                activeSnapshots.Add(snapshot);
            }
        }