Ejemplo n.º 1
0
        /// <summary>
        /// Saves the timestamp, process name and window title into the database.
        ///
        /// In case the user doesn't want the window title to be stored (For privacy reasons),
        /// it is obfuscated.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="process"></param>
        internal static void InsertSnapshot(string window, string process)
        {
            if (Shared.Settings.AnonymizeSensitiveData)
            {
                var dto = new ContextDto {
                    Context = new ContextInfos {
                        ProgramInUse = process, WindowTitle = window
                    }
                };
                window = Dict.Anonymized + " " + ContextMapper.GetContextCategory(dto);  // obfuscate window title
            }

            Database.GetInstance().ExecuteDefaultQuery("INSERT INTO " + Settings.DbTable + " (time, window, process) VALUES (strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), " +
                                                       Database.GetInstance().Q(window) + ", " + Database.GetInstance().Q(process) + ")");
        }