public ActivityLogger(ILogDatabase logDatabase) { this.logDatabase = logDatabase; programUse = logDatabase.OpenProgramUses(); inputs = logDatabase.OpenInputs(); var hidMonitor = Debugger.IsAttached ? null : new HumanInterfaceDeviceMonitor(); // var hidMonitor = new HumanInterfaceDeviceMonitor(); var winEventHook = new WinEventHook(); var timer = Observable.Interval(this.inputLoggingInterval); inputAggregator = new InputAggregator(); subscriptions = new System.Reactive.Disposables.CompositeDisposable(new IDisposable[] { ObservableTimeInterval.Get(inputLoggingInterval).Subscribe(inputAggregator.Time), hidMonitor == null ? null : hidMonitor.KeyDown.Subscribe(inputAggregator.KeyDown), hidMonitor == null ? null : hidMonitor.Mouse.Subscribe(inputAggregator.Mouse), inputAggregator.Input.SubscribeOn(System.Reactive.Concurrency.TaskPoolScheduler.Default).Subscribe(_ => { inputs.Add(_); log.DebugFormat("Input: {0} clicks, {1} keys", _.Clicks, _.KeyDown); }), inputAggregator, inputs, programUse, hidMonitor, winEventHook }.Where(_ => _ != null)); workDayBegin = DateTime.Now.Date; }
public void ProgramUse() { using (var pu = logDatabase.OpenProgramUses()) { var t = TimeIntervalExtensions.LastDays(60); var programs = pu.Query(p => p.Begin > t.Begin && p.Begin < t.End) .GroupBy(x => x.File) .Select(x => new { File = x.Key, KeyDown = x.Sum(i => i.KeyDown) }) .ToList(); var tm = CreateTreeMap(programs); tm.GetLineage = x => Regex.Split(x.File.ToLower(), @"\\"); tm.GetSize = x => x.KeyDown; tm.RunFullScreen(); } }