예제 #1
0
        public async Task <bool> Remove()
        {
            bool result = false;

            try
            {
                await AuthenticateAsync();

                IItemRequestBuilder builder = client.Drive.Special.AppRoot.ItemWithPath(FILENAME);
                Item file = await builder.Request().GetAsync();

                await client.Drive.Items[file.Id].Request().DeleteAsync();

                result = true;
            }
            catch (OneDriveException e)
            {
                if (e.IsMatch(OneDriveErrorCode.ItemNotFound.ToString()))
                {
                    result = true;
                }
                else
                {
                    throw new NetworkException();
                }
            }

            return(result);
        }
예제 #2
0
        private async Task GetFileFromOneDrive()
        {
            try
            {
                await AuthenticateAsync();

                IItemRequestBuilder builder = client.Drive.Special.AppRoot.ItemWithPath(FILENAME);
                Item file = await builder.Request().GetAsync();

                Stream contentStream = await builder.Content.Request().GetAsync();

                content = "";

                using (var reader = new StreamReader(contentStream))
                {
                    content = await reader.ReadToEndAsync();
                }

                if (!string.IsNullOrWhiteSpace(content) && encrypter != null && encrypter.IsInitialized)
                {
                    decrypted = encrypter.Decrypt(content);

                    _isInitialSetup = false;
                }
            }
            catch (OneDriveException ex)
            {
                if (ex.IsMatch(OneDriveErrorCode.ItemNotFound.ToString()))
                {
                    _isInitialSetup = true;
                }
            }
        }
예제 #3
0
        private async Task GetFolder(IItemRequestBuilder builder, bool childrenToo)
        {
            ShowBusy(true);
            Exception error = null;
            IChildrenCollectionPage children = null;

            try
            {
                var root = await builder.Request().GetAsync();

                if (childrenToo)
                {
                    children = await builder.Children.Request().GetAsync();
                }

                DisplayHelper.ShowContent(
                    "SHOW FOLDER ++++++++++++++++++++++",
                    root,
                    children,
                    async message =>
                {
                    var dialog = new MessageDialog(message);
                    await dialog.ShowAsync();
                });

                ShowBusy(false);
            }
            catch (Exception ex)
            {
                error = ex;
            }

            if (error != null)
            {
                var dialog = new MessageDialog(error.Message, "Error!");
                await dialog.ShowAsync();

                ShowBusy(false);
                return;
            }
        }