Ejemplo n.º 1
0
        public async Task <IChildrenCollectionPage> GetChildrenByPathAsync(string path)
        {
            if (!isAuthenticated)
            {
                throw new Exception("Not authenticated");
            }

            IChildrenCollectionPage children = null;

            try
            {
                children = await oneDriveClient.Drive
                           .Root
                           .ItemWithPath(path)
                           .Children
                           .Request()
                           .GetAsync();
            }
            catch (Exception)
            {
                return(null);
            }

            return(children);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        public static void ShowContent(
            string title,
            Item item,
            IChildrenCollectionPage children,
            Action <string> showDialog)
        {
            Debug.WriteLine(title);

            Debug.WriteLine($"Folder name: {item.Name}");
            Debug.WriteLine($"Created on: {item.CreatedDateTime}");
            Debug.WriteLine($"Modified on: {item.LastModifiedDateTime}");
            Debug.WriteLine($"Size: {item.Size.ConvertSize()}");
            Debug.WriteLine($"Web URL: {item.WebUrl}");

            if (item.Folder != null)
            {
                Debug.WriteLine($"Child count: {item.Folder.ChildCount}");

                showDialog(
                    $"The folder {item.Name} has {item.Folder.ChildCount} children. More details in the Output window!");
            }
            else
            {
                showDialog($"Retrieved info for folder {item.Name}. More details in the Output window!");
            }

            if (children == null)
            {
                return;
            }

            foreach (var child in children)
            {
                Debug.WriteLine("----");
                Debug.WriteLine($"Child name: {child.Name}");
                Debug.WriteLine($"Created on: {child.CreatedDateTime}");
                Debug.WriteLine($"Modified on: {child.LastModifiedDateTime}");
                Debug.WriteLine($"Size: {child.Size.ConvertSize()}");
                Debug.WriteLine($"Web URL: {child.WebUrl}");

                if (child.Audio != null)
                {
                    Debug.WriteLine("AUDIO INFO");
                    Debug.WriteLine($"Album: {child.Audio.Album}");
                    Debug.WriteLine($"Album Artist: {child.Audio.AlbumArtist}");
                    Debug.WriteLine($"Duration [ms]: {child.Audio.Duration}");
                }

                if (child.Video != null)
                {
                    Debug.WriteLine("VIDEO INFO");
                    Debug.WriteLine($"Bitrate: {child.Video.Bitrate}");
                    Debug.WriteLine($"Width: {child.Video.Width}");
                    Debug.WriteLine($"Height: {child.Video.Height}");
                    Debug.WriteLine($"Duration [ms]: {child.Video.Duration}");
                }

                if (child.Photo != null)
                {
                    Debug.WriteLine("PHOTO INFO");
                    Debug.WriteLine($"Camera Model: {child.Photo.CameraModel}");
                    Debug.WriteLine($"Camera Make: {child.Photo.CameraMake}");
                }

                if (child.Image != null)
                {
                    Debug.WriteLine("IMAGE INFO");
                    Debug.WriteLine($"Width: {child.Image.Width}");
                    Debug.WriteLine($"Height: {child.Image.Height}");
                }

                if (child.Folder != null)
                {
                    Debug.WriteLine("FOLDER INFO");
                    Debug.WriteLine($"Child count: {child.Folder.ChildCount}");
                    // At this point we would need to populate the subfolder's children
                }
            }
        }