private void UpdateAndSaveForegroundItems(ParsedWindow parsedWindow)
        {
            if (parsedWindow.ApplicationName != null)
            {
                _foregroundAppItem = _DBGateway.GetOrCreateApplicationItemFromDB(parsedWindow.ApplicationName, _foregroundProcess);

                if (parsedWindow.FileName != null)
                {
                    _foregroundFileItem = _DBGateway.GetOrCreateFileItemFromDB(parsedWindow.FileName, parsedWindow.FilePath, _foregroundAppItem.ApplicationId);
                }
            }

            int?   appId      = _foregroundAppItem != null ? _foregroundAppItem.ApplicationId : (int?)null;
            int?   fileId     = _foregroundFileItem != null ? _foregroundFileItem.FileId : (int?)null;
            string windowText = parsedWindow.WindowTitle;

            _foregroundWindowItem = _DBGateway.GetOrCreateWindowItemFromDB(appId, fileId, windowText);

            _DBGateway.InsertWindowHistoryItem(_lastUpdateTime, _foregroundWindowItem.WindowId);
        }