private void toolStripBtnExecute_Click(object sender, EventArgs e) { this.SetLoadingState(); if (string.Compare(this.currentCrudName, "Create documentCollection", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(this.currentCrudName, "Replace documentCollection", StringComparison.OrdinalIgnoreCase) == 0) { this.collectionToCreate.IndexingPolicy.IncludedPaths.Clear(); foreach (object item in lbIncludedPath.Items) { IncludedPath includedPath = item as IncludedPath; this.collectionToCreate.IndexingPolicy.IncludedPaths.Add(includedPath); } this.collectionToCreate.IndexingPolicy.ExcludedPaths.Clear(); foreach (object item in lbExcludedPath.Items) { String excludedPath = item as String; this.collectionToCreate.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath() { Path = excludedPath }); } this.collectionToCreate.Id = tbCollectionId.Text; this.currentOperation(null, collectionToCreate); } else if (this.currentCrudName.StartsWith("Create trigger", StringComparison.OrdinalIgnoreCase)) { Trigger trigger = new Documents.Trigger(); trigger.Body = this.tbCrudContext.Text; trigger.Id = this.textBoxforId.Text; trigger.TriggerOperation = Documents.TriggerOperation.All; if (rbPreTrigger.Checked) trigger.TriggerType = Documents.TriggerType.Pre; else if (rbPostTrigger.Checked) trigger.TriggerType = Documents.TriggerType.Post; this.currentOperation(null, trigger); } else { if (!string.IsNullOrEmpty(this.tbCrudContext.SelectedText)) { this.currentOperation(this.tbCrudContext.SelectedText, this.textBoxforId.Text); } else { if (this.currentCrudName.StartsWith("Execute StoredProcedure", StringComparison.Ordinal) && !this.tbCrudContext.Modified) { this.currentOperation(null, this.textBoxforId.Text); } else { this.currentOperation(this.tbCrudContext.Text, this.textBoxforId.Text); } } } }
async void AddTrigger(string body, string id) { try { Documents.Trigger trigger = new Documents.Trigger(); trigger.Body = body; trigger.Id = id; trigger.TriggerOperation = Documents.TriggerOperation.All; trigger.TriggerType = Documents.TriggerType.Pre; ResourceResponse<Documents.Trigger> newtrigger = await this.client.CreateTriggerAsync((this.Parent.Tag as Documents.DocumentCollection).SelfLink, trigger); this.Nodes.Add(new DocumentNode(this.client, newtrigger.Resource, ResourceType.Trigger)); // set the result window string json = newtrigger.Resource.ToString(); Program.GetMain().SetResultInBrowser(json, null, false, newtrigger.ResponseHeaders); } catch (AggregateException e) { Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true); } catch (Exception e) { Program.GetMain().SetResultInBrowser(null, e.ToString(), true); } }
private void toolStripBtnExecute_Click(object sender, EventArgs e) { this.SetLoadingState(); if (string.Compare(this.currentCrudName, "Create documentCollection", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(this.currentCrudName, "Replace documentCollection", StringComparison.OrdinalIgnoreCase) == 0) { this.collectionToCreate.IndexingPolicy.IncludedPaths.Clear(); foreach (object item in lbIncludedPath.Items) { IncludedPath includedPath = item as IncludedPath; this.collectionToCreate.IndexingPolicy.IncludedPaths.Add(includedPath); } this.collectionToCreate.IndexingPolicy.ExcludedPaths.Clear(); foreach (object item in lbExcludedPath.Items) { String excludedPath = item as String; this.collectionToCreate.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath() { Path = excludedPath }); } this.collectionToCreate.Id = tbCollectionId.Text; this.currentOperation(null, collectionToCreate); } else if (this.currentCrudName.StartsWith("Create trigger", StringComparison.OrdinalIgnoreCase)) { Trigger trigger = new Documents.Trigger(); trigger.Body = this.tbCrudContext.Text; trigger.Id = this.textBoxforId.Text; trigger.TriggerOperation = Documents.TriggerOperation.All; if (rbPreTrigger.Checked) { trigger.TriggerType = Documents.TriggerType.Pre; } else if (rbPostTrigger.Checked) { trigger.TriggerType = Documents.TriggerType.Post; } this.currentOperation(null, trigger); } else { if (!string.IsNullOrEmpty(this.tbCrudContext.SelectedText)) { this.currentOperation(this.tbCrudContext.SelectedText, this.textBoxforId.Text); } else { if (this.currentCrudName.StartsWith("Execute StoredProcedure", StringComparison.Ordinal) && !this.tbCrudContext.Modified) { this.currentOperation(null, this.textBoxforId.Text); } else { this.currentOperation(this.tbCrudContext.Text, this.textBoxforId.Text); } } } }