public async Task <bool> Register([FromBody] UserViewModel user) { var newUser = new IdentityUser() { UserName = user.name, Email = user.email }; var reg = await this.manager.CreateAsync(newUser, user.password); if (!reg.Succeeded) { return(false); } var res = await this.signInManager.PasswordSignInAsync(user.name, user.password, false, false); if (!res.Succeeded) { return(false); } try { var model = new AskUser() { IdentityId = newUser.Id, email = newUser.Email, name = newUser.UserName }; await context.AskUsers.AddAsync(model); await context.SaveChangesAsync(); } catch (Exception e) { } return(res.Succeeded); }
void DeleteSelection(string operationName, AskUser askUser) { for (var i = 0; i < selection.Count; i++) { if (selection[i] is Edge removedEdge) { RemoveEdge(removedEdge); } else if (selection[i] is SequenceNode sequenceNode) { var matchingEdges = cachedEdges.Where(edge => edge.input.node == sequenceNode || edge.output.node == sequenceNode).ToArray(); foreach (var edge in matchingEdges) { RemoveEdge(edge); } var index = sequenceNode.index; RemoveNode(sequenceNode); foreach (var node in cachedNodes) { if (node.index > index) { node.index--; } } } } }
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)); }
private static async Task AskForMessageToReplyTo2(TelegramBotAbstract telegramBotAbstract, MessageEventArgs e, int identity) { //ask link var question = new Language(new Dictionary <string, string> { { "it", "Inserisci il link del messaggio a cui vuoi rispondere" } }); var r = await AskUser.AskAsync(e.Message.From.Id, question, telegramBotAbstract, e.Message.From.LanguageCode, e.Message.From.Username); var tuple = GetMessageReply(r); if (r == null) { var l2 = new Language(new Dictionary <string, string> { { "it", "Errore, non siamo riusciti a comprendere il link che hai inviato\n" + "Operazione annullata." } }); } await PlaceMessageInQueue(telegramBotAbstract, new MessaggeAnonToSendInQueue(e), identity, tuple); }
public override void Execute(object parameter) { var name = model.ItemSelection.Name; AskUser.ConfirmationAsync("Confirm Delete", "Really delete '" + name + "' transformer?") .ContinueWhenTrue(() => DeleteTransformer(name)); }
public override void Execute(object parameter) { AskUser.QuestionAsync("Create New Database", "Database name?") .ContinueWith(task => { if (task.IsCanceled) { return; } var databaseName = task.Result; if (string.IsNullOrEmpty(databaseName)) { return; } if (Path.GetInvalidPathChars().Any(databaseName.Contains)) { throw new ArgumentException("Cannot create a database with invalid path characters: " + databaseName); } ApplicationModel.Current.AddNotification(new Notification("Creating database: " + databaseName)); DatabaseCommands.EnsureDatabaseExistsAsync(databaseName) .ContinueOnSuccess(() => DatabaseCommands.ForDatabase(databaseName).EnsureSilverlightStartUpAsync()) .ContinueOnSuccessInTheUIThread(() => { ApplicationModel.Current.Server.Value.Databases.Add(new DatabaseModel(databaseName, DatabaseCommands.ForDatabase(databaseName))); ApplicationModel.Current.AddNotification(new Notification("Database " + databaseName + " created")); }) .Catch(); }); }
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); } })); }
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; } })); }); }
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; } }); }
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)); }
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)); }
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 bool CanLeavePage() { if (HasUnsavedChanges) { return(AskUser.Confirmation("Edit Document", "There are unsaved changes to this document. Are you sure you want to continue?")); } return(true); }
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(); }
protected void DeleteSelectionOperation(string operationName, AskUser askUser) { if (deleteSelection != null) { deleteSelection(operationName, askUser); } else { DeleteSelection(); } }
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)); }
private static async Task DetectMessageAsync(TelegramBotAbstract telegramBotAbstract, MessageEventArgs e) { ; var botId = telegramBotAbstract.GetId(); if (AskUser.UserAnswers.ContainsUser(e.Message.From.Id, botId)) { if (AskUser.UserAnswers.GetState(e.Message.From.Id, botId) == AnswerTelegram.State.WAITING_FOR_ANSWER) { AskUser.UserAnswers.RecordAnswer(e.Message.From.Id, botId, e.Message.Text); return; } } var question = new Language(new Dictionary <string, string> { { "it", "Vuoi postare questo messaggio?" }, { "en", "Do you want to post this message?" } }); var l1 = new Language(new Dictionary <string, string> { { "it", "Si" } }); var l2 = new Language(new Dictionary <string, string> { { "it", "No" } }); var options = new List <List <Language> > { new List <Language> { l1, l2 } }; var r = await AskUser.AskBetweenRangeAsync(e.Message.From.Id, question, telegramBotAbstract, e.Message.From.LanguageCode, options, e.Message.From.Username, true, e.Message.MessageId); if (l1.Matches(r)) { //yes await AskIdentityForMessageToSend2(telegramBotAbstract, e); return; } var l3 = new Language(new Dictionary <string, string> { { "it", "Va bene. Se ti serve aiuto usa /help" }, { "en", "Ok. If you need any help, use /help" } }); await telegramBotAbstract.SendTextMessageAsync(e.Message.From.Id, l3, ChatType.Private, e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username); }
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(); }
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)); }
public override void Execute(object parameter) { if (string.IsNullOrWhiteSpace(index.Name)) { ApplicationModel.Current.AddNotification(new Notification("Index must have a name!", NotificationLevel.Error)); return; } if (index.Maps.All(item => string.IsNullOrWhiteSpace(item.Text))) { ApplicationModel.Current.AddNotification(new Notification("Index must have at least one map with data!", NotificationLevel.Error)); return; } if (index.IsNewIndex == false && index.OriginalName != index.Name) { if (AskUser.Confirmation("Can not rename and index", "If you wish to save a new index with this new name press OK, to cancel the save command press Cancel") == false) { ApplicationModel.Current.Notifications.Add(new Notification("Index Not Saved")); return; } } index.UpdateIndex(); if (index.Reduce == "") { index.Reduce = null; } if (index.TransformResults == "" || index.ShowTransformResults == false) { index.TransformResults = null; } var mapIndexes = (from mapItem in index.Maps where mapItem.Text == "" select index.Maps.IndexOf(mapItem)).ToList(); mapIndexes.Sort(); for (int i = mapIndexes.Count - 1; i >= 0; i--) { index.Maps.RemoveAt(mapIndexes[i]); } ApplicationModel.Current.AddNotification(new Notification("saving index " + index.Name)); DatabaseCommands.PutIndexAsync(index.Name, index.index, true) .ContinueOnSuccess(() => { ApplicationModel.Current.AddNotification( new Notification("index " + index.Name + " saved")); index.hasUnsavedChanges = false; PutIndexNameInUrl(index.Name); }) .Catch(); }
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); }); }
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) { if (ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Statistics.Value.CountOfDocuments != 0) { AskUser.ConfirmationWithEvent("Override Docuements?", "There are documents in the database :" + ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name + "." + Environment.NewLine + "This operation can override those documents.", ExecuteInternal); } else { ExecuteInternal(); } }
protected override async Task <DatabaseTaskOutcome> RunImplementation() { if (ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Statistics.Value != null && ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Statistics.Value.CountOfDocuments != 0) { return (await AskUser.ConfirmationWithContinuation("Override Documents?", "There are documents in the database :" + ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name + "." + Environment.NewLine + "This operation can override those documents.", ExecuteInternal, () => TaskEx.FromResult(DatabaseTaskOutcome.Abandoned))); } return(await ExecuteInternal()); }
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)); }
public override void Execute(object parameter) { transformer.ClearDefinitionErrors(); if (string.IsNullOrWhiteSpace(transformer.Transformer.Name)) { transformer.ReportDefinitionError("Transformer must have a name"); return; } if (string.IsNullOrWhiteSpace(transformer.Transformer.TransformResults)) { transformer.ReportDefinitionError("Transform must contain a C# LINQ query or Query expression"); return; } if (transformer.IsNewTransformer == false && transformer.OriginalName != transformer.Transformer.Name) { if (AskUser.Confirmation("Can not rename and transformer", "If you wish to save a new transformer with this new name press OK, to cancel the save command press Cancel") == false) { ApplicationModel.Current.Notifications.Add(new Notification("Transformer Not Saved")); return; } } ApplicationModel.Current.AddNotification(new Notification("saving transformer " + transformer.Transformer.Name)); DatabaseCommands.PutTransformerAsync(transformer.Transformer.Name, transformer.Transformer) .ContinueOnSuccess(() => { ApplicationModel.Current.AddNotification( new Notification("transformer " + transformer.Transformer.Name + " saved")); PutTransformerNameInUrl(transformer.Transformer.Name); transformer.IsShowingErrors = false; }) .Catch(ex => { var indexException = ex.ExtractSingleInnerException() as TransformCompilationException; if (indexException != null) { transformer.ReportDefinitionError(indexException.Message); return(true); } return(false); });; }
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); } }); }
public override void Execute(object parameter) { AskUser.QuestionAsync("Save", "Please enter a name").ContinueOnSuccessInTheUIThread(name => { var doc = new PatchDocument { PatchOnOption = patchModel.PatchOn, Query = patchModel.QueryDoc.CurrentSnapshot.GetText(LineTerminator.Newline), Script = patchModel.Script.CurrentSnapshot.GetText(LineTerminator.Newline), SelectedItem = patchModel.SelectedItem, Id = "Studio/Patch/" + name, Values = patchModel.Values.ToList() }; var session = ApplicationModel.Current.Server.Value.DocumentStore.OpenAsyncSession(); session.Store(doc); session.SaveChangesAsync().ContinueOnSuccessInTheUIThread(() => patchModel.UpdateDoc(name)); }); }
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)); } }