/// <summary> /// Initializes the AME for an SQL Server EXPRESS DB /// Example catalog would be ".\\SQLEXPRESS" for SQLEXPRESS running on one's own machine /// Working directory should be a path that contains the Config directory /// The controller string is the name of a Controller to fetch /// Could also use GMEManager.Get after initializing for other controllers /// </summary> /// <param name="SQLServerCatalog"></param> /// <param name="Database"></param> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public static IController InitializeAMESQLServer(String model, String WorkingDirectory, String SQLServerCatalog, String Database, String Username, String Password, String Controller) { try { // paths, controller, model initialization String configPath = WorkingDirectory + @"\Config"; String docPath = WorkingDirectory + @"\Doc"; String licPath = WorkingDirectory + @"\License"; AMEManager.DatabaseConfiguration config = new AMEManager.DatabaseConfiguration(); config.Server = SQLServerCatalog; config.Username = Username; config.Password = Password; config.Database = Database; AMEManager cm = AMEManager.Instance; cm.CreateModel(AME.AMEManager.DataModelTypes.SqlServerExpress, config, model); return cm.Get(Controller); } catch (Exception e) { MessageBox.Show(e.Message, "Error communicating with model!"); return null; } }
private Boolean dbSetup() { SqlServerExpressSetupForm setup = new SqlServerExpressSetupForm(); setup.ServerHost = System.Net.Dns.GetHostName() + @"\SQLEXPRESS"; setup.Username = "******"; setup.Database = "vsg"; setup.StartPosition = FormStartPosition.CenterParent; setup.ShowDialog(this); // If click OK. if (setup.DialogResult == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; // Need these for the db dump server = setup.ServerHost; username = setup.Username; password = setup.Password; database = setup.Database; try { AMEManager gme = AMEManager.Instance; AMEManager.DatabaseConfiguration dbConfiguration = new AMEManager.DatabaseConfiguration(); dbConfiguration.Server = setup.ServerHost; dbConfiguration.Database = setup.Database; dbConfiguration.Username = setup.Username; dbConfiguration.Password = setup.Password; gme.CreateModel(AME.AMEManager.DataModelTypes.SqlServerExpress, dbConfiguration, "vsg"); projectController = (RootController)gme.Get("Project"); vsgController = (VSGController)gme.Get("VSG"); //vsgController.ValidateAllSchemaLinks(); vsgController.RegisterForUpdate(this); // Allow empty string as a legal value for all parameters // do not return parameters that are empty string projectController.IgnoreEmptyString = true; vsgController.IgnoreEmptyString = true; // Close any previously open projects (e.g. did someone already connect to a database?) // to do... // Create screens. createViewComponentPanels(); //InitializeScenario(scenarioId); return true; } catch (Exception e) { MessageBox.Show(e.Message, "DB setup failed"); return false; } finally { this.Cursor = Cursors.Default; } } else if (setup.DialogResult == DialogResult.Cancel) { Application.Exit(); return false; } else { return false; } }