private void BuildManagement_Load(object sender, EventArgs e) { using (AssetInventoryContext context = new AssetInventoryContext()) { serverFilter_ToolStripComboBox.ComboBox.DataSource = FrameworkServerType.SelectAll(context); } }
/// <summary> /// Adds a new Framework Server with Print properties and retrieves it's print queues. /// </summary> private bool AddNewServer(string serverName, Guid serverId) { // The server doesn't exist in configuration, so try to query it and load // that information so it can be reviewed and edited by the user. Cursor = Cursors.WaitCursor; string error = string.Empty; FrameworkServerProxy proxy = new FrameworkServerProxy(serverName); bool success = _controller.QueryServer(proxy, out error); Cursor = Cursors.Default; // If there is a failure reading server and/or the user doesn't want to continue, then return if (!success && !ContinueEditing(proxy, error)) { return(false); } FrameworkServer server = new FrameworkServer() { FrameworkServerId = serverId }; // Add Print as a server type for this server before editing FrameworkServerType serverType = _controller.GetServerType(ServerType.Print); proxy.ServerTypes.Add(serverType); using (FrameworkServerEditForm form = new FrameworkServerEditForm(_controller, proxy)) { if (form.ShowDialog() != DialogResult.OK) { return(false); } proxy.CopyTo(server); //Save the new server to the database at this point. If there is an error getting //print queues, the server data will be preserved. _controller.AddNewServer(server); _printServers.Add(server); SaveChanges(); } // Scan the server for queues. AddServerQueues(server); return(true); }
/// <summary> /// Adds a new <see cref="FrameworkServerType"/> to the system. /// </summary> private void toolStripButton_Add_Click(object sender, EventArgs e) { if (ValidateInput()) { FrameworkServerType newType = new FrameworkServerType() { FrameworkServerTypeId = SequentialGuid.NewGuid(), Name = toolStripTextBox_Name.Text, Description = toolStripTextBox_Descr.Text }; _serverTypes.Add(newType); toolStripTextBox_Name.Text = string.Empty; toolStripTextBox_Descr.Text = string.Empty; } }
/// <summary> /// Adds a new <see cref="FrameworkServerType"/> /// </summary> /// <param name="serverType">Type of the server.</param> public void AddServerType(FrameworkServerType serverType) { _context.FrameworkServerTypes.Add(serverType); }