Esempio n. 1
0
        private async void LogoutByInactivity(object state)
        {
            _timer       = null;
            _updateTimer = null;

            // Close all event editing session
            var openedEvents = await _workspaceDataUnit.EventsRepository.GetLightEventsAsync(x => x.LockedUserID == AccessService.Current.User.ID);

            openedEvents.ForEach(x => x.LockedUserID = null);
            await _workspaceDataUnit.SaveChanges();

            // Close all opened windows
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                var allWindows = Application.Current.Windows.OfType <Window>().ToList();

                foreach (var window in allWindows)
                {
                    if (window != Application.Current.MainWindow)
                    {
                        window.Close();
                    }
                }

                var mainWindow = (MainWindow)Application.Current.MainWindow;
                mainWindow.ViewModel.Logout();
            }));
        }