public override void Execute(object parameter)
{
AskUser.SelectItem("Load", "Choose saved patching to load",
() => ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession().Advanced.
LoadStartingWithAsync <PatchDocument>("Studio/Patch/").ContinueWith(
task =>
{
IList <string> objects = task.Result.Select(document => document.Id.Substring("Studio/Patch/".Length)).ToList();
return(objects);
}))
.ContinueOnSuccessInTheUIThread(result => ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession().
LoadAsync <PatchDocument>("Studio/Patch/" + result)
.ContinueOnSuccessInTheUIThread(patch =>
{
if (patch == null)
{
ApplicationModel.Current.Notifications.Add(new Notification("Could not find Patch document named " + result, NotificationLevel.Error));
}
else
{
patchModel.PatchOn = patch.PatchOnOption;
patchModel.QueryDoc.SetText(patch.Query);
patchModel.Script.SetText(patch.Script);
patchModel.SelectedItem = patch.SelectedItem;
patchModel.Values = new ObservableCollection <PatchValue>(patch.Values);
patchModel.UpdateDoc(result);
}
}));
}