Пример #1
0
 public Program(ILogDatabase logDatabase)
 {
     this.logDatabase = logDatabase;
     input            = logDatabase.OpenInputs();
     connection       = (System.Data.SQLite.SQLiteConnection)input.Connection;
     dataContext      = new DataContext(input.Connection);
 }
Пример #2
0
        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;
        }
Пример #3
0
        public DateTime?GetWorkBegin(DateTime time)
        {
            var workDayBegin = time.Date;

            using (var inputs = logDatabase.OpenInputs())
            {
                var r = inputs.Range(new TimeInterval(workDayBegin, time));
                var b = r.FirstOrDefault();
                if (b == null)
                {
                    return(null);
                }
                else
                {
                    return(b.Begin);
                }
            }
        }