public FileStatsViewModel(IUIBaseService windowService, FileStats fileStats)
 {
     this.windowService = windowService;
     this.fileStats = fileStats;
     this.fileStats.PropertyChanged += (obj, e) =>
     {
         // Raise all properties changed
         OnPropertyChanged(string.Empty);
     };
 }
Beispiel #2
0
        /// <summary>
        /// Removes the stats of the given file from the DB.
        /// </summary>
        /// <param name="file"></param>
        public void RemoveFileStats(FileStats file)
        {
            SQLiteParameter path = new SQLiteParameter("@path");
            path.Value = file.FilePath;
            path.DbType = System.Data.DbType.String;

            using (SQLiteCommand cmd = new SQLiteCommand(dbConn))
            {
                cmd.Parameters.Add(path);
                // Remove words related to file.
                cmd.CommandText = "DELETE FROM Words WHERE file=@path";
                cmd.ExecuteNonQuery();
                // Remove the stats for file
                cmd.CommandText = "DELETE FROM Files WHERE path=@path";
                cmd.ExecuteNonQuery();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Adds new stats into pending to DB state.
 /// </summary>
 /// <param name="stats"></param>
 public void UpdateStats(FileStats stats)
 {
     statList.Add(stats);
 }
Beispiel #4
0
        /// <summary>
        /// Provides the list of unknown words and quantities for given
        /// language, project and file.
        /// </summary>
        /// <param name="fs">FileStats</param>
        /// <returns></returns>
        public Dictionary<string, int> GetUnknownWords(FileStats fs)
        {
            Dictionary<string, int> words = new Dictionary<string, int>();

            SQLiteParameter fileParam = new SQLiteParameter("@file");
            fileParam.Value = fs.FilePath;
            fileParam.DbType = System.Data.DbType.String;
            string sql = "SELECT word, quantity FROM Words " +
                "WHERE file=@file ORDER BY quantity DESC";
            using (SQLiteCommand cmd = new SQLiteCommand(sql, dbConn))
            {
                cmd.Parameters.Add(fileParam);
                SQLiteDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    words[dr.GetString(0)] = dr.GetInt32(1);
                }
                dr.Close();
            }
            return words;
        }