public TimeTrackerService() { try { InitializeComponent(); eventLog = new EventLog { Source = ServiceName, Log = "Application" }; systemActivityService = new SystemActivityService(); windowActivityService = new WindowActivityService(); dbContext = new TimeTrackerDbContext(); dbContext.Database.EnsureCreated(); userSystemEventRepository = new UserSystemEventRepository(dbContext); userWindowEventRepository = new UserWindowEventRepository(dbContext); windowsAppRepository = new WindowsAppRepository(dbContext); } catch (Exception ex) { Log(ex.ToString()); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow = new MainWindow(userSystemEventRepository, userWindowEventRepository, windowsAppRepository); MainWindow.Closing += MainWindow_Closing; _notifyIcon = new SWF.NotifyIcon(); _notifyIcon.DoubleClick += (s, args) => ShowMainWindow(); _notifyIcon.Icon = BackgroundApp.Properties.Resources.time; _notifyIcon.Visible = true; systemActivityService = new SystemActivityService(); windowActivityService = new WindowActivityService(); dbContext = new TimeTrackerDbContext(); dbContext.Database.EnsureCreated(); userSystemEventRepository = new UserSystemEventRepository(dbContext); userWindowEventRepository = new UserWindowEventRepository(dbContext); windowsAppRepository = new WindowsAppRepository(dbContext); systemActivityService.SystemActivitySnapshot += SystemActivityService_SystemActivitySnapshot; windowActivityService.WindowActivitySnapshot += WindowActivityService_WindowActivitySnapshot; systemActivityService.Start(); windowActivityService.Start(); CreateContextMenu(); }
public MainWindow(UserSystemEventRepository userSystemEventRepository, UserWindowEventRepository userWindowEventRepository, WindowsAppRepository windowsAppRepository) { ViewModel = new MainWindowViewModel(userSystemEventRepository, userWindowEventRepository, windowsAppRepository); DataContext = ViewModel; InitializeComponent(); }
public MainWindowViewModel(UserSystemEventRepository userSystemEventRepository, UserWindowEventRepository userWindowEventRepository, WindowsAppRepository windowsAppRepository) { _userSystemEventRepository = userSystemEventRepository; _userWindowEventRepository = userWindowEventRepository; _windowsAppRepository = windowsAppRepository; EndDate = DateTime.Now; BeginDate = DateTime.Now; UpdateDataClick = new SimpleCommand(o => true, o => { }); }
static void Main(string[] args) { SystemActivityService systemActivityService = new SystemActivityService(); WindowActivityService windowActivityService = new WindowActivityService(); dbContext = new TimeTrackerDbContext(); dbContext.Database.EnsureCreated(); userSystemEventRepository = new UserSystemEventRepository(dbContext); userWindowEventRepository = new UserWindowEventRepository(dbContext); windowsAppRepository = new WindowsAppRepository(dbContext); systemActivityService.SystemActivitySnapshot += SystemActivityService_SystemActivitySnapshot; windowActivityService.WindowActivitySnapshot += WindowActivityService_WindowActivitySnapshot; systemActivityService.Start(); windowActivityService.Start(); while (true) { Thread.Sleep(10); } }