public static void Generate(CheevoUser user, Stream output) { RssFeed feed = new RssFeed(); feed.Channel.Link = new Uri(Link); feed.Channel.Title = Title; feed.Channel.Description = Description; // the last build date must correspond to the 'newest' cheevo feed.Channel.LastBuildDate = user.GetLastUpdateTime(); feed.Channel.PublicationDate = user.GetLastUpdateTime(); foreach (var cheevo in user.ObtainedCheevos) { RssItem item = new RssItem(); item.Title = cheevo.Title; item.Link = new Uri(Link); item.Description = cheevo.Points.ToString(); item.PublicationDate = cheevo.Awarded; feed.Channel.AddItem(item); } feed.Save(output); }
public static Dictionary<string, CheevoUser> LoadPoppedCheevos() { var dbCheevos = new Dictionary<string, CheevoUser>(); const string loadCheevos = "select Title,Description,Category,Points,AwardedTime,User,available_cheevos.ID " + "from popped_cheevos inner join available_cheevos on available_cheevos.ID = popped_cheevos.ID where AwardedTime is not null"; bool dbOpened = false; lock (Database.sqliteCon) { try { Database.sqliteCon.Open(); dbOpened = true; using (SQLiteCommand selectCommand = new SQLiteCommand(loadCheevos, Database.sqliteCon)) using (SQLiteDataReader dataReader = selectCommand.ExecuteReader()) { while (dataReader.HasRows && dataReader.Read()) { var myDate = new DateTime(dataReader.GetInt64(4)); var user = new CheevoUser(dataReader.GetString(5)); if (!dbCheevos.ContainsKey(user.Username.ToLower())) { dbCheevos.Add(user.Username.ToLower(), user); } dbCheevos[user.Username.ToLower()].Add( new Cheevo( dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2), dataReader.GetInt32(3), myDate, dataReader.GetInt32(6))); } } } catch (Exception ex) { Debug.WriteLine(ex.Message + " " + ex.StackTrace); } finally { if (dbOpened) { Database.sqliteCon.Close(); } } } return dbCheevos; }