Ejemplo n.º 1
0
        /// <summary>
        /// Saves a the user's logbook to Dropbox, if configured.
        /// </summary>
        /// <exception cref="MyFlightbookException"></exception>
        /// <exception cref="UnauthorizedAccessException"></exception>
        /// <exception cref="Dropbox.Api.AuthException"></exception>
        /// <exception cref="Dropbox.Api.BadInputException"></exception>
        /// <exception cref="Dropbox.Api.HttpException"></exception>
        /// <param name="activeBrand">The brand to use.  Current brand is used if null.</param>
        public async Task <Dropbox.Api.Files.FileMetadata> BackupToDropbox(Brand activeBrand = null)
        {
            if (String.IsNullOrEmpty(User.DropboxAccessToken))
            {
                throw new MyFlightbookException(Resources.Profile.errNotConfiguredDropBox);
            }

            if (activeBrand == null)
            {
                activeBrand = Branding.CurrentBrand;
            }

            return(await MFBDropbox.PutFile(User.DropboxAccessToken, BackupFilename(activeBrand), LogbookDataForBackup()).ConfigureAwait(true));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves a zip of the user's images to Dropbox, if configured.
        /// </summary>
        /// <exception cref="MyFlightbookException"></exception>
        /// <exception cref="UnauthorizedAccessException"></exception>
        /// <exception cref="Dropbox.Api.AuthException"></exception>
        /// <exception cref="Dropbox.Api.BadInputException"></exception>
        /// <exception cref="Dropbox.Api.HttpException"></exception>
        /// <param name="activeBrand">The brand to use.  Current brand is used if null.</param>
        public async Task <Dropbox.Api.Files.FileMetadata> BackupImagesToDropbox(Brand activeBrand = null)
        {
            if (activeBrand == null)
            {
                activeBrand = Branding.CurrentBrand;
            }

            if (String.IsNullOrEmpty(User.DropboxAccessToken))
            {
                throw new MyFlightbookException(Resources.Profile.errNotConfiguredDropBox);
            }

            using (MemoryStream ms = ZipOfImagesForUser(activeBrand))
            {
                Dropbox.Api.Files.FileMetadata result = await MFBDropbox.PutFile(User.DropboxAccessToken, ms, BackupImagesFilename(activeBrand));

                return(result);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Saves a zip of the user's images to Dropbox, if configured.
        /// </summary>
        /// <exception cref="MyFlightbookException"></exception>
        /// <exception cref="UnauthorizedAccessException"></exception>
        /// <exception cref="Dropbox.Api.AuthException"></exception>
        /// <exception cref="Dropbox.Api.BadInputException"></exception>
        /// <exception cref="Dropbox.Api.HttpException"></exception>
        /// <param name="activeBrand">The brand to use.  Current brand is used if null.</param>
        public async Task <Dropbox.Api.Files.FileMetadata> BackupImagesToDropbox(Brand activeBrand = null)
        {
            if (activeBrand == null)
            {
                activeBrand = Branding.CurrentBrand;
            }

            if (String.IsNullOrEmpty(User.DropboxAccessToken))
            {
                throw new MyFlightbookException(Resources.Profile.errNotConfiguredDropBox);
            }

            using (FileStream fs = new FileStream(Path.GetTempFileName(), FileMode.Open, FileAccess.ReadWrite, FileShare.None, Int16.MaxValue, FileOptions.DeleteOnClose))
            {
                WriteZipOfImagesToStream(fs, activeBrand);
                Dropbox.Api.Files.FileMetadata result = await MFBDropbox.PutFile(User.DropboxAccessToken, fs, BackupImagesFilename(activeBrand)).ConfigureAwait(true);

                return(result);
            }
        }