Ejemplo n.º 1
0
        async Task ExecuteTapContainerCommandAsync(ASECloudBlobContainer container)
        {
            if (container == null)
            {
                return;
            }
            MessagingService.Current.Subscribe <MessageArgsDeleteContainer>(MessageKeys.DeleteContainer, async(m, argsDeleteContainer) =>
            {
                Console.WriteLine("Delete containerX: " + argsDeleteContainer.ContainerName);
                Navigation.PopAsync();
                IProgressDialog deletingDialog = UserDialogs.Loading("Deleting Container");
                deletingDialog.Show();
                try
                {
                    var aseContainer = Containers.Where(c => c.ContainerName == argsDeleteContainer.ContainerName &&
                                                        c.StorageAccountName == argsDeleteContainer.StorageAccountName).FirstOrDefault();
                    if (aseContainer == null)
                    {
                        return;
                    }

                    await aseContainer.BaseContainer.DeleteAsync();

                    App.Logger.Track(AppEvent.DeleteContainer.ToString());

                    Containers.Remove(aseContainer);
                    SortContainers();
                    var realm = App.GetRealm();
                    await realm.WriteAsync(temprealm =>
                    {
                        temprealm.Remove(temprealm.All <RealmCloudBlobContainer>()
                                         .Where(c => c.ContainerName == argsDeleteContainer.ContainerName &&
                                                c.StorageAccountName == argsDeleteContainer.StorageAccountName).First());
                    });
                }
                catch (Exception ex)
                {
                    Logger.Report(ex, "Method", "HandleMessageArgsDeleteContainer");
                    MessagingService.Current.SendMessage(MessageKeys.Error, ex);
                }
                finally
                {
                    if (deletingDialog != null)
                    {
                        if (deletingDialog.IsShowing)
                        {
                            deletingDialog.Hide();
                        }
                        deletingDialog.Dispose();
                    }
                }
            });

            var blobsPage = new BlobsPage(container);

            App.Logger.TrackPage(AppPage.Blobs.ToString());
            await NavigationService.PushAsync(Navigation, blobsPage);
        }
Ejemplo n.º 2
0
        public BlobsPage(ASECloudBlobContainer container)
        {
            InitializeComponent();
            BindingContext = new BlobsViewModel(Navigation, UserDialogs.Instance, container);

            Title = container.BaseContainer.Name;
            ViewModel.LoadBlobsCommand.Execute(false);

            if (Device.RuntimePlatform == Device.Android)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Order   = ToolbarItemOrder.Secondary,
                    Text    = "Add Blob",
                    Command = vm.AddBlobCommand
                });
                ToolbarItems.Add(new ToolbarItem
                {
                    Order   = ToolbarItemOrder.Secondary,
                    Text    = "Delete Container",
                    Command = vm.DeleteContainerCommand
                });
            }
            else if (Device.RuntimePlatform == Device.iOS)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "More",
                    Icon    = "toolbar_overflow.png",
                    Command = new Command(async() =>
                    {
                        string[] items = new[] { "Add Blob", "Delete Container" };

                        var action = await DisplayActionSheet("Options", "Cancel", null, items);
                        if (action == items[0])
                        {
                            vm.AddBlobCommand.Execute(null);
                        }
                        else if (action == items[1])
                        {
                            vm.DeleteContainerCommand.Execute(null);
                        }
                    })
                });
            }

            lvBlobs.ItemSelected += (sender, e) =>
            {
                lvBlobs.SelectedItem = null;
            };
        }
Ejemplo n.º 3
0
 public BlobsViewModel(INavigation navigation, IUserDialogs userDialogs, ASECloudBlobContainer container) : base(navigation, userDialogs)
 {
     Container           = container;
     NoBlobsFoundMessage = "No Blobs Found";
 }
Ejemplo n.º 4
0
 public void AddContainer(ASECloudBlobContainer aseCloudBlobContainer)
 {
     Containers.Add(aseCloudBlobContainer);
     SortContainers();
 }