public bool AddMember(CodeProjectMember member)
		{
			var connection = new SqliteConnection ("Data Source=" + dbPath);
			connection.Open ();

			using (var command = connection.CreateCommand ()) {
				command.CommandText = "SELECT [Key] FROM [Member] WHERE [Key]=" + member.Id;
				var r = command.ExecuteReader ();
				if (r.HasRows) {
					using (var uc = connection.CreateCommand ()) {
						uc.CommandText = "UPDATE [Member] SET " +
							" [Name] = '" + member.Name + "'," +
							" [ArticleCnt] = '" + member.ArticleCount + "'," +
							" [BlogCnt] = '" + member.BlogCount + "'," +
							" [Reputation] = '" + member.Reputation + "'," +
							" WHERE [Key]=" + member.Id;
						uc.ExecuteNonQuery ();
					}
				} else {
					using (var ic = connection.CreateCommand ()) {
						ic.CommandText = "INSERT INTO [Member] ([Key], [Name], [ArticleCnt], [BlogCnt], [Reputation])"
							+ " VALUES(" + member.Id + ", '" + member.Name + "', '" + member.ArticleCount + "', '" + member.BlogCount + "', '" + member.Reputation + "')";
						ic.ExecuteNonQuery ();
					}
				}
			}	

			connection.Close ();

			FileStorageService storage = new FileStorageService ();
			if(member.Avatar != null) {
				storage.WriteBytes(member.Avatar, member.Id.ToString());
			}

			return true;
		}
        public void DeleteMember(int memberId)
        {
            var connection = new SqliteConnection("Data Source=" + dbPath);
            connection.Open();
            using (var ic = connection.CreateCommand())
            {
                ic.CommandText = "DELETE FROM [Member] " +
                                " WHERE [Key]=" + memberId;
                ic.ExecuteNonQuery();
            }

            connection.Close();

            FileStorageService storage = new FileStorageService();
            storage.DeleteFile(memberId.ToString());
        }
		public byte[] GetGravatar(int memberId)
		{
            FileStorageService storage = new FileStorageService();
            if (storage.FileExists(memberId.ToString()))
            {
                return storage.ReadBytes(memberId.ToString());
            }
            else
            {
                return null;
            }
        }
示例#4
0
        public byte[] ReadBytes(string filename)
        {
            var filePath = Path.Combine(BaseFolder, filename);

            return(FileStorageService.ReadAllBytes(filePath));
        }
示例#5
0
        public void WriteBytes(byte[] data, string filename)
        {
            var filePath = Path.Combine(BaseFolder, filename);

            FileStorageService.WriteAllBytes(filePath, data);
        }