private void OnCreateDbLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.EntryText = "Enter a name for the new database:"; Label_0017: if (dialog.ShowDialog() == DialogResult.OK) { string s = dialog.EntryValue.Trim(); string message = string.Empty; if (s.Length == 0) { message = "The name must not be empty."; } else if (s.Length > 0x7c) { message = "The name cannot be longer than 124 characters."; } else if (!SqlHelper.IsValidIdentifier(s)) { message = "The name is not valid. Check that it contains valid characters and is not too long."; } if (message.Length > 0) { this.ReportError(message, "Unable to create a database with that name."); goto Label_0017; } this.CollectConnectionSettings(); SqlDatabase database = new SqlDatabase(this.ConnectionSettings); try { database.Connect(); database.CreateDatabase(SqlHelper.RemoveDelimiters(s)); this._connectionSettings.Database = s; base.DialogResult = DialogResult.OK; base.Close(); } catch (Exception exception) { this.ReportError(exception, "Could not create a new database."); goto Label_0017; } finally { database.Disconnect(); } } }
protected override DocumentProjectItem CreateDocumentInternal(FolderProjectItem parentItem) { if (!(parentItem is StoredProcedureGroupProjectItem)) { if (!(parentItem is TableGroupProjectItem)) { throw new NotSupportedException(); } TableGroupProjectItem item2 = (TableGroupProjectItem) parentItem; PromptDialog dialog2 = new PromptDialog(base.ServiceProvider); dialog2.Text = "Create New Table"; dialog2.EntryText = "Enter the name of the new table:"; IMxUIService service2 = (IMxUIService) base.GetService(typeof(IMxUIService)); Label_015E: if (service2.ShowDialog(dialog2) == DialogResult.OK) { string itemName = dialog2.EntryValue.Trim(); string identifierPart = this.GetIdentifierPart(itemName); if (!this.ValidateProjectItemName(identifierPart)) { service2.ReportError("The name '" + itemName + "' contains invalid characters or is too long.", "Create New Table", false); goto Label_015E; } try { this.Database.Connect(); TableCollection tables = this.Database.Tables; if (tables.Contains(identifierPart)) { service2.ReportError("A table with the name '" + itemName + "' already exists.", "Create New Table", false); goto Label_015E; } tables.AddNew(identifierPart); return new TableProjectItem(identifierPart); } catch (Exception exception2) { service2.ReportError(exception2, "Error adding table.", false); goto Label_015E; } finally { this.Database.Disconnect(); } } return null; } StoredProcedureGroupProjectItem item1 = (StoredProcedureGroupProjectItem) parentItem; PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.Text = "Create New Stored Procedure"; dialog.EntryText = "Enter the name of the new stored procedure:"; IMxUIService service = (IMxUIService) base.GetService(typeof(IMxUIService)); Label_004A: if (service.ShowDialog(dialog) == DialogResult.OK) { string str = dialog.EntryValue.Trim(); string str2 = this.GetIdentifierPart(str); if (!this.ValidateProjectItemName(str2)) { service.ReportError("The name '" + str + "' contains invalid characters or is too long.", "Create New Stored Procedure", false); goto Label_004A; } try { this.Database.Connect(); StoredProcedureCollection storedProcedures = this.Database.StoredProcedures; if (storedProcedures.Contains(str2)) { service.ReportError("A stored procedure with the name '" + str + "' already exists.", "Create New Stored Procedure", false); goto Label_004A; } storedProcedures.AddNew(str2); return new StoredProcedureProjectItem(str2); } catch (Exception exception) { service.ReportError(exception, "Error adding stored procedure.", false); goto Label_004A; } finally { this.Database.Disconnect(); } } return null; }
protected internal override FolderProjectItem CreateFolderInternal(FolderProjectItem parentItem) { IMxUIService service = (IMxUIService) base.GetService(typeof(IMxUIService)); PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.Text = "Create New Folder"; dialog.EntryText = "Enter the name of the new folder:"; if (service.ShowDialog(dialog) != DialogResult.OK) { return null; } string entryValue = dialog.EntryValue; if (!this.ValidateProjectItemName(entryValue)) { service.ReportError("The name, '" + entryValue + "' contains invalid characters.", "Create New Folder", false); return null; } string path = this.CombinePath(parentItem.Path, entryValue); if (Directory.Exists(path)) { throw new ArgumentException("A folder with the path '" + path + "' already exists."); } Directory.CreateDirectory(path); return new DirectoryProjectItem(entryValue); }
private string GetProjectItemRunUrl(Document document) { try { DocumentProjectItem projectItem = document.ProjectItem; if (projectItem == null) { throw new ArgumentException("Document does not have an associated project item", "document"); } Project project = projectItem.Project; if (project != this) { throw new ArgumentException("Unable to run the specified document", "document"); } string httpUrl = this.HttpUrl; if (httpUrl.Length == 0) { IUIService service = (IUIService) base.GetService(typeof(IUIService)); DialogResult cancel = DialogResult.Cancel; if (service != null) { string displayName = project.ProjectItem.DisplayName; if (this.HttpRoot.Length != 0) { displayName = displayName + this.HttpRoot; } PromptDialog form = new PromptDialog(base.ServiceProvider); form.EntryText = "Enter the URL for your FTP connection's Web directory '" + displayName + "':"; cancel = service.ShowDialog(form); if (cancel == DialogResult.OK) { httpUrl = form.EntryValue; if (httpUrl.EndsWith("/")) { httpUrl = httpUrl.Substring(0, httpUrl.Length - 1); } this.HttpUrl = httpUrl; } } if (cancel == DialogResult.Cancel) { return string.Empty; } } string path = projectItem.Path; if (this.HttpRoot.Length != 0) { if (!path.StartsWith(this.HttpRoot)) { IUIService service2 = (IUIService) base.GetService(typeof(IUIService)); if (service2 != null) { service2.ShowMessage("'" + projectItem.Caption + "' exists outside the Web directory, and cannot be run."); } return string.Empty; } path = path.Substring(this.HttpRoot.Length + 1); } return (httpUrl + "/" + path); } catch (Exception) { } return null; }
protected override FolderProjectItem CreateFolderInternal(FolderProjectItem parentItem) { string str2; IMxUIService service = (IMxUIService) base.GetService(typeof(IMxUIService)); PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.Text = "Create New Folder"; dialog.EntryText = "Enter the name of the new folder:"; if (service.ShowDialog(dialog) != DialogResult.OK) { return null; } string entryValue = dialog.EntryValue; if (!this.ValidateProjectItemName(entryValue)) { service.ReportError("The name, '" + entryValue + "' contains invalid characters.", "Create New Folder", false); return null; } if (parentItem == this._rootItem) { str2 = entryValue; } else { str2 = this.CombinePath(parentItem.Path, entryValue); } this._connection.CreateDirectory(str2); return new DirectoryProjectItem(entryValue); }
public override DocumentProjectItem GetSaveAsProjectItem(DocumentProjectItem item) { DocumentProjectItem item2 = null; PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.Text = "Save Document As"; dialog.EntryText = "Enter the full path to the new FTP location for the document:\n"; dialog.EntryValue = item.Path; dialog.RequiresNewValue = true; ICommandManager service = (ICommandManager) base.GetService(typeof(ICommandManager)); if (service != null) { service.SuspendCommandUpdate(); } try { if (dialog.ShowDialog() != DialogResult.OK) { return item2; } string entryValue = dialog.EntryValue; if (!this.ValidateProjectItemPath(entryValue, false)) { throw new Exception("'" + entryValue + "' is not a valid file path."); } string caption = entryValue; int num = entryValue.LastIndexOf('/'); if (num > 0) { caption = entryValue.Substring(num + 1); } item2 = new MiscFileProjectItem(caption, entryValue, this); } finally { if (service != null) { service.ResumeCommandUpdate(); } } return item2; }