Пример #1
0
        public override void Execute(object parameter)
        {
            var deleteItems = parameter as string;

            AskUser.ConfirmationAsync("Confirm Delete", string.Format("Are you sure that you want to delete all " + deleteItems + " indexes?"))
            .ContinueWhenTrue(() => DeleteIndex(deleteItems));
        }
Пример #2
0
            public override void Execute(object parameter)
            {
                var name = model.ItemSelection.Name;

                AskUser.ConfirmationAsync("Confirm Delete", "Really delete '" + name + "' transformer?")
                .ContinueWhenTrue(() => DeleteTransformer(name));
            }
Пример #3
0
        public override void Execute(object parameter)
        {
            patchModel.ClearQueryError();

            AskUser.ConfirmationAsync("Patch Documents", "Are you sure you want to apply this patch to all selected documents?")
            .ContinueWhenTrueInTheUIThread(() =>
            {
                var values = patchModel.GetValues();
                if (values == null)
                {
                    return;
                }
                var request = new ScriptedPatchRequest {
                    Script = patchModel.Script.CurrentSnapshot.Text, Values = values
                };
                var selectedItems = patchModel.QueryResults.ItemSelection.GetSelectedItems();
                var commands      = new ICommandData[selectedItems.Count()];
                var counter       = 0;

                foreach (var item in selectedItems)
                {
                    commands[counter] = new ScriptedPatchCommandData
                    {
                        Patch = request,
                        Key   = item.Item.Id
                    };

                    counter++;
                }

                ApplicationModel.Database.Value.AsyncDatabaseCommands
                .BatchAsync(commands)
                .ContinueOnUIThread(t => { if (t.IsFaulted)
                                           {
                                               patchModel.HandlePatchError(t.Exception);
                                           }
                                    })
                .ContinueOnSuccessInTheUIThread(() => ApplicationModel.Database.Value
                                                .AsyncDatabaseCommands
                                                .GetAsync(patchModel.SelectedItem)
                                                .ContinueOnSuccessInTheUIThread(doc =>
                {
                    if (doc != null)
                    {
                        patchModel.OriginalDoc.SetText(doc.ToJson().ToString());
                        patchModel.NewDoc.SetText("");
                        patchModel.ShowAfterPrompt = true;
                    }
                    else
                    {
                        patchModel.OriginalDoc.SetText("");
                        patchModel.NewDoc.SetText("");
                        patchModel.ShowAfterPrompt          = true;
                        patchModel.ShowBeforeAndAfterPrompt = true;
                    }
                }));
            });
        }
Пример #4
0
        protected override void ExecuteOverride(IEnumerable <IndexItem> items)
        {
            var index = items
                        .Select(x => x.Name)
                        .FirstOrDefault();

            AskUser.ConfirmationAsync("Confirm Reset", string.Format("Are you sure that you want to reset this index? ({0})", index))
            .ContinueWhenTrue(() => ResetIndex(index));
        }
Пример #5
0
        public override void Execute(object parameter)
        {
            AskUser.ConfirmationAsync("Patch Documents", "Are you sure you want to apply this patch to all matching documents?")
            .ContinueWhenTrueInTheUIThread(() =>
            {
                var values = patchModel.GetValues();
                if (values == null)
                {
                    return;
                }
                var request = new ScriptedPatchRequest {
                    Script = patchModel.Script.CurrentSnapshot.Text, Values = values
                };

                switch (patchModel.PatchOn)
                {
                case PatchOnOptions.Document:
                    var commands = new ICommandData[1];
                    commands[0]  = new ScriptedPatchCommandData
                    {
                        Patch = request,
                        Key   = patchModel.SelectedItem
                    };

                    ApplicationModel.Database.Value.AsyncDatabaseCommands.BatchAsync(commands).Catch().
                    ContinueOnSuccessInTheUIThread(
                        () => ApplicationModel.Database.Value.AsyncDatabaseCommands.GetAsync(patchModel.SelectedItem).
                        ContinueOnSuccessInTheUIThread(
                            doc =>
                    {
                        patchModel.OriginalDoc.SetText(doc.ToJson().ToString());
                        patchModel.NewDoc.SetText("");
                        patchModel.ShowAfterPrompt = true;
                    }));
                    break;

                case PatchOnOptions.Collection:
                    ApplicationModel.Database.Value.AsyncDatabaseCommands.UpdateByIndex(PatchModel.CollectionsIndex,
                                                                                        new IndexQuery {
                        Query = "Tag:" + patchModel.SelectedItem
                    }, request)
                    .ContinueOnSuccessInTheUIThread(() => patchModel.UpdateCollectionSource())
                    .Catch();
                    break;

                case PatchOnOptions.Index:
                    ApplicationModel.Database.Value.AsyncDatabaseCommands.UpdateByIndex(patchModel.SelectedItem, new IndexQuery()
                    {
                        Query = patchModel.QueryDoc.CurrentSnapshot.Text
                    },
                                                                                        request)
                    .ContinueOnSuccessInTheUIThread(() => patchModel.UpdateCollectionSource())
                    .Catch();
                    break;
                }
            });
        }
Пример #6
0
        public override void Execute(object parameter)
        {
            var index = SelectedItems
                        .Select(x => x.IndexName)
                        .FirstOrDefault();

            AskUser.ConfirmationAsync("Confirm Delete", string.Format("Are you sure that you want to delete this index? ({0})", index))
            .ContinueWhenTrue(() => DeleteIndex(index));
        }
Пример #7
0
        private void HandleDeleteDocument()
        {
            if (string.IsNullOrEmpty(DocumentKey))
            {
                return;
            }

            AskUser.ConfirmationAsync("Confirm Delete", string.Format("Are you sure you want do delete {0} ?", DocumentKey))
            .ContinueWhenTrueInTheUIThread(() => DoDeleteDocument(DocumentKey));
        }
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Lock Change",
                               string.Format(
                                   "Are you sure that you want to change the lock mode of this index? ({0})",
                                   name))
     .ContinueWhenTrue(() => ChangeLock(name))
     .Unwrap()
     .Catch();
 }
Пример #9
0
        public override void Execute(object parameter)
        {
            var collectionNames = SelectedItems
                                  .Select(x => x.Name)
                                  .ToList();

            AskUser.ConfirmationAsync("Confirm Delete", collectionNames.Count > 1
                                                                        ? string.Format("Are you sure you want to delete all of the documents of these {0} collections?", collectionNames.Count)
                                                                        : string.Format("Are you sure that you want to delete all of the documents of this collection? ({0})", collectionNames.First()))
            .ContinueWhenTrue(() => DeleteDocuments(collectionNames));
        }
Пример #10
0
            public override void Execute(object parameter)
            {
                if (document.Key != null && document.Key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
                {
                    AskUser.ConfirmationAsync("Confirm Edit", "Are you sure that you want to edit a system document?")
                    .ContinueWhenTrue(SaveDocument);
                    return;
                }

                SaveDocument();
            }
Пример #11
0
        protected override void ExecuteOverride(IList <ViewableDocument> realizedItems)
        {
            var documentsIds = realizedItems
                               .Select(x => x.Id)
                               .ToList();

            AskUser.ConfirmationAsync("Confirm Delete", documentsIds.Count > 1
                                                                        ? string.Format("Are you sure you want to delete these {0} documents?", documentsIds.Count)
                                                                        : string.Format("Are you sure that you want to delete this document? ({0})", documentsIds.First()))
            .ContinueWhenTrueInTheUIThread(() => ApplicationModel.Current.AddNotification(new Notification("Deleting documents...")))
            .ContinueWhenTrue(() => DeleteDocuments(documentsIds));
        }
Пример #12
0
 public override void Execute(object _)
 {
     if (parent.HasUnsavedChanges)
     {
         AskUser.ConfirmationAsync("Edit Document",
                                   "There are unsaved changes to this document. Are you sure you want to refresh?")
         .ContinueWhenTrueInTheUIThread(DoRefresh);
     }
     else
     {
         DoRefresh();
     }
 }
        public override void Execute(object parameter)
        {
            AskUser.ConfirmationAsync("Are you sure?", "Meddling with the system database could cause irreversible damage")
            .ContinueWith(task =>
            {
                if (!task.Result)
                {
                    return;
                }

                ExecuteCommand(new ChangeDatabaseCommand(true), Constants.SystemDatabase);
            });
        }
Пример #14
0
 private void HandleDeleteMatchingResults()
 {
     AskUser.ConfirmationAsync("Delete Items",
                               "Are you sure you want to delete all documents matching the query?")
     .ContinueWhenTrueInTheUIThread(
         () =>
     {
         ApplicationModel.Current.AddInfoNotification("Deleting documents");
         DatabaseCommands.DeleteByIndexAsync(IndexName, CreateTemplateQuery(), false)
         .ContinueOnSuccess(
             () => ApplicationModel.Current.AddInfoNotification("Documents successfully deleted"))
         .Catch();
     });
 }
        public override void Execute(object parameter)
        {
            var documentsIds = SelectedItems
                               .Select(x => x.Id)
                               .ToList();

            AskUser.ConfirmationAsync("Confirm Delete", documentsIds.Count > 1
                                                                        ? string.Format("Are you sure you want to delete these {0} documents?", documentsIds.Count)
                                                                        : string.Format("Are you sure that you want to delete this document? ({0})", documentsIds.First()))
            .ContinueWhenTrueInTheUIThread(() =>
            {
                ((DocumentsModel)Context).IsLoadingDocuments = true;
                ApplicationModel.Current.AddNotification(new Notification("Deleting documents..."));
            })
            .ContinueWhenTrue(() => DeleteDocuments(documentsIds));
        }
Пример #16
0
        public override void Execute(object parameter)
        {
            var documentsIds = Items
                               .Select(x => x.Id)
                               .ToList();

            AskUser.ConfirmationAsync("Confirm Delete", documentsIds.Count > 1
                                                                        ? string.Format("Are you sure you want to delete these {0} documents?", documentsIds.Count)
                                                                        : string.Format("Are you sure that you want to delete this document? ({0})", documentsIds.First()))
            .ContinueWhenTrue(() => DeleteDocuments(documentsIds))
            .ContinueWhenTrueInTheUIThread(() =>
            {
                var model = (DocumentsModel)Context;
                foreach (var document in Items)
                {
                    model.Documents.Remove(document);
                }
            });
        }
Пример #17
0
        public override void Execute(object parameter)
        {
            var group = model.SelectedGroup;

            if (group != null)
            {
                var ravenDocumentsByEntityNameIndexName = new RavenDocumentsByEntityName().IndexName;
                AskUser.ConfirmationAsync("Confirm Delete",
                                          string.Format("Are you sure that you want to delete all indexes in the group {0}?", group.GroupName))
                .ContinueWhenTrue(() => DeleteIndexes(group.Items.Select(item => item.Name).Where(indexName => indexName != ravenDocumentsByEntityNameIndexName)));
            }
            else
            {
                var deleteItems = parameter as string;
                AskUser.ConfirmationAsync("Confirm Delete",
                                          string.Format("Are you sure that you want to delete all " + deleteItems + " indexes?"))
                .ContinueWhenTrue(() => DeleteIndex(deleteItems));
            }
        }
Пример #18
0
            private void ConfirmSave()
            {
                if (!parentModel.IsDocumentValid())
                {
                    this.parentModel.IsShowingErrors = true;
                }

                if (parentModel.Key != null && parentModel.Key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
                {
                    AskUser.ConfirmationAsync("Confirm Edit", "Are you sure that you want to edit a system document?")
                    .ContinueWhenTrueInTheUIThread(SaveDocument);
                    return;
                }

                if (parentModel.EditingDatabase)
                {
                    AskUser.ConfirmationAsync("Confirm Edit", "Are you sure that you want to change the database document? This could cause irreversible damage")
                    .ContinueWhenTrueInTheUIThread(SaveDatabaseDocument);
                    return;
                }

                SaveDocument();
            }
Пример #19
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", "Really delete '" + index.Name + "' index?")
     .ContinueWhenTrue(DeleteIndex);
 }
Пример #20
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", string.Format("Really delete {0} ?", key))
     .ContinueWhenTrue(DeleteDocument);
 }
Пример #21
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete",
                               "Really delete all transformers in group: '" + model.SelectedGroup.GroupName + "?")
     .ContinueWhenTrue(DeleteTransformers);
 }
Пример #22
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", "Really delete " + key + " ?")
     .ContinueWhenTrue(DeleteDocument);
 }
Пример #23
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", string.Format("Are you sure that you want to delete this index? ({0})", model.ItemSelection.Name))
     .ContinueWhenTrue(() => DeleteIndex(model.ItemSelection.Name));
 }
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", "Really delete '" + model.Transformer.Name + "' transformer?")
     .ContinueWhenTrue(DeleteTransformer);
 }
Пример #25
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", string.Format("Are you sure that you want to delete all indexes?"))
     .ContinueWhenTrue(DeleteIndex);
 }
Пример #26
0
 public override void Execute(object parameter)
 {
     AskUser.ConfirmationAsync("Confirm Delete", "Are you sure you want to delete index '" + index.Name + "'?")
     .ContinueWhenTrue(DeleteIndex);
 }