public IList <string> BackupProfile(User katushaUser, Guid guid, string folder = null) { var results = new List <string>(); try { var profile = _profileRepository.GetByGuid(guid); var extendedProfile = GetExtendedProfile(katushaUser, profile.Id); var obj = JsonConvert.SerializeObject(extendedProfile); var bytes = Encoding.UTF8.GetBytes(obj); using (var stream = new MemoryStream(bytes)) { _fileSystem.Add(string.Format("{0}/{1}.json", folder ?? Folders.ProfileBackups, guid), stream); } } catch (Exception ex) { results.Add(ex.Message); } return(results); }
private bool GeneratePhoto2(PhotoBackup photo, PhotoType photoType) { foreach (var suffix in PhotoTypes.Versions.Keys) { if ((byte)photoType != suffix) { continue; } byte[] bytes; using (var outputStream = new MemoryStream()) { using (var stream = new MemoryStream(photo.Data)) { ImageBuilder.Current.Build(stream, outputStream, new ResizeSettings(PhotoTypes.Versions[suffix].ToString()), false, true); bytes = outputStream.ToArray(); } } using (var stream = new MemoryStream(bytes)) { _fileSystem.Add(String.Format("{0}/{1}-{2}.jpg", Folders.Photos, (byte)photoType, photo.Guid), stream); } } return(true); }