public static Schema CreateFromConnection(ConnectionInfo conInfo) { Schema schema = new Schema(); schema.CatalogName = conInfo.Catalog; schema.Name = conInfo.Schema; IConnectionFactory fac = null; ISqlConf sqlConf = null; if (conInfo.Type == ConnectionType.SqlServer) { fac = new SqlServerConnectionFactory(); sqlConf = new SQLServerDefaultConf(); schema.Platform = "SQLSERVER"; } else if (conInfo.Type == ConnectionType.MySql) { fac = new MySqlConnectionFactory(); sqlConf = new MySqlDefaultConf(); schema.Platform = "MYSQL"; } using (IDbConnection conn = fac.CreateConnection(conInfo)) { conn.Open(); IDatabaseExplorer dbExplorer = new DatabaseExplorer(conn, sqlConf); schema.Tables = dbExplorer.GetTables(schema).ToList<Table>(); schema.StoredProcedures = dbExplorer.GetStoredProcedures(schema).ToList<StoredProcedure>(); } return schema; }
public ShellViewModel( IServer server, ServerUriProvider uriProvider, NavigationViewModel navigation, NotificationsViewModel notifications, BusyStatusViewModel busyStatus, SelectDatabaseViewModel start, DatabaseExplorer databaseScreen, IKeyboardShortcutBinder binder, IEventAggregator events) { this.navigation = navigation; this.notifications = notifications; this.busyStatus = busyStatus; navigation.SetGoHome(() => { this.TrackNavigationTo(start, events); navigation.Breadcrumbs.Clear(); }); this.databaseScreen = databaseScreen; this.binder = binder; this.events = events; this.server = server; events.Subscribe(this); Items.Add(start); Items.Add(databaseScreen); serverUri = new Uri(uriProvider.GetServerUri()); events.Publish(new WorkStarted("Connecting to server")); server.Connect(serverUri, () => { events.Publish(new WorkCompleted("Connecting to server")); switch (server.Databases.Count()) { case 0: //NOTE: perhaps we should display a retry button? break; case 1: ActivateItem(databaseScreen); break; default: ActivateItem(start); break; } }); }
public override void Execute(IDictionary<string, object> scope) { try { this.Status = OperationStatus.RUNNING; SqlConnection conn = scope["CONNECTION"] as SqlConnection; Schema schema = scope["SCHEMA"] as Schema; DatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf()); INamingAdapter adapter = null; if (useCSNaming) { adapter = new CSNamingAdapter(); } else { adapter = new SameNamingAdapter(); } GeneratorOptions options = new GeneratorOptions() { SupportsReturnValue = true, NamingAdapter = new CSNamingAdapter() }; ResourceManager resMan = new ResourceManager(); List<TypeMap> tts = resMan.GetDataAccessTypeMaps(); TypeMap tm = resMan.GetDataAccessTypeMaps().Where<TypeMap>(t => t.Name == "SqlServer -> C# Standard Type Map").FirstOrDefault<TypeMap>(); CSharpDataAccessGenerator gen = new CSharpDataAccessGenerator(tm, options); string entitiesCode = gen.GenerateEntities(schema); string entityFile = Path.Combine(dalLocation, "Entities.cs"); saveToFile(entityFile, entitiesCode); string interfaceCode = gen.GenerateInterface(schema); string interfaceFile = Path.Combine(dalLocation, "IDataStore.cs"); saveToFile(interfaceFile, interfaceCode); string storeCode = gen.GenerateClass(schema); string storeFile = Path.Combine(dalLocation, "DataStore.cs"); saveToFile(storeFile, storeCode); this.Status = OperationStatus.COMPLETED; } catch (Exception ex) { this.Exception = ex; this.Status = OperationStatus.FAILED; throw ex; } }
public override void Execute(IDictionary<string, object> scope) { try { this.Status = OperationStatus.RUNNING; SqlConnection conn = scope["CONNECTION"] as SqlConnection; DatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf()); Schema schema = new Schema(); schema.Name = this.schemaName; schema.Tables = exp.GetTables(schema).ToList<Table>(); schema.StoredProcedures = exp.GetStoredProcedures(schema).ToList<StoredProcedure>(); scope["SCHEMA"] = schema; this.Status = OperationStatus.COMPLETED; } catch (Exception ex) { this.Exception = ex; this.Status = OperationStatus.FAILED; throw ex; } }
public override void Execute(IDictionary<string, object> scope) { try { this.Status = OperationStatus.RUNNING; SqlConnection conn = scope["CONNECTION"] as SqlConnection; DatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf()); Schema schema = scope["SCHEMA"] as Schema; SqlServerCrudGenerator gen = new SqlServerCrudGenerator(null); string script = gen.Generate(schema); Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(new ServerConnection(conn)); server.ConnectionContext.ExecuteNonQuery(script); Status = OperationStatus.COMPLETED; } catch (Exception ex) { this.Exception = ex; this.Status = OperationStatus.FAILED; throw ex; } }
public DesignMainViewModel() { ProgressStatus = "Status example in progress..."; ProgressValue = 50; ProgressTotal = 100; ProgressVisible = true; var database = new InMemoryGameDatabase(); Game.DatabaseReference = database; GameDatabase.GenerateSampleData(database); var designGame = database.Games.First(); designGame.CoverImage = "pack://application:,,,/Playnite;component/Resources/Images/DesignCover.jpg"; designGame.BackgroundImage = "pack://application:,,,/Playnite;component/Resources/Images/DesignBackground.jpg"; designGame.Icon = "pack://application:,,,/Playnite;component/Resources/Images/DesignIcon.png"; AppSettings = new PlayniteSettings(); AppSettings.ExplorerPanelVisible = true; AppSettings.GridViewSideBarVisible = true; AppSettings.ShowNamesUnderCovers = true; AppSettings.ShowNameEmptyCover = true; AppSettings.ViewSettings.SelectedExplorerField = GroupableField.LastActivity; Extensions = new ExtensionFactory(database, new GameControllerFactory()); GamesView = new DesktopCollectionView(database, AppSettings, Extensions); SelectedGame = GamesView.Items[0]; SelectedGames = new List <GamesCollectionViewEntry>() { SelectedGame }; SelectedGameDetails = new GameDetailsViewModel(GamesView.Items[0], AppSettings); DatabaseExplorer = new DatabaseExplorer(database, Extensions, AppSettings); PlayniteApi = new PlayniteAPI(null, null, null, null, null, null, null, new NotificationsAPI(), null, null); PlayniteApi.Notifications.Add(new NotificationMessage("1", "Some testing notification message.", NotificationType.Info)); PlayniteApi.Notifications.Add(new NotificationMessage("2", "Some really long testing notification message that should be on more lines of text.", NotificationType.Error)); }
public OpenErrorsScreen(DatabaseExplorer database, ErrorsViewModel errors) { this.database = database; this.errors = errors; }
public OpenErrorsScreen(DatabaseExplorer database, ErrorsViewModel errors) { this.database = database; this.errors = errors; }
public DatabaseExplorerNavigator(DatabaseExplorer databaseExplorer) { this.databaseExplorer = databaseExplorer; }
public DatabaseExplorerNavigator(DatabaseExplorer databaseExplorer) { this.databaseExplorer = databaseExplorer; }
private void cmbDatabase_DropDown(object sender, EventArgs e) { try { cmbDatabase.DataSource = null; SqlServerConnectionFactory fac = new SqlServerConnectionFactory(); using (IDbConnection conn = fac.CreateConnection(getConInfo())) { IDatabaseExplorer exp = new DatabaseExplorer(conn, new SQLServerDefaultConf()); conn.Open(); List<Catalog> catalogs = exp.GetCatalogs().ToList<Catalog>(); cmbDatabase.DataSource = catalogs; cmbDatabase.DisplayMember = "Name"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }