protected BaseTableSourceInfo(IDatabaseServices databaseServices, IDatabaseInfo database, string name, string qualifiedName) { DatabaseServices = databaseServices; Database = database; Name = name; QualifiedName = qualifiedName; }
public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore) { string paramPrefix = DatabaseServices.ExecutionService.ParameterPrefix; IList <ITableSourceInfo> tables = new List <ITableSourceInfo>(); MySQLDatabaseInfo databaseInfo = database as MySQLDatabaseInfo; if (databaseInfo == null) { return(null); } using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { string sql = string.Format(@"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = {0} UNION SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = {0};", paramPrefix + "schema"); IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, sql); cmd.CommandTimeout = QueryTimeout; DatabaseServices.ExecutionService.CreateParameter(cmd, paramPrefix + "schema", DbType.String, databaseInfo.Name); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string tableName = (string)reader["TABLE_NAME"]; if (!isTableSourceToIgnore(tableName)) { string qualifiedTableName = GetQualifiedIdentifier(databaseInfo.Name, tableName); tables.Add(new MySQLTableSourceInfo(DatabaseServices, databaseInfo, tableName, qualifiedTableName)); } } } } return(tables); }
public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore) { IList <ITableSourceInfo> tables = new List <ITableSourceInfo>(); iDB2DatabaseInfo databaseInfo = database as iDB2DatabaseInfo; if (databaseInfo == null) { return(null); } using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { string sql = "SELECT TABLE_NAME " + "FROM QSYS2.SYSTABLES " + "WHERE SYSTEM_TABLE = 'N' and SYSTEM_TABLE_SCHEMA = '" + database.Identifier + "'"; IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, sql); cmd.CommandTimeout = QueryTimeout; using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string tableName = (string)reader["TABLE_NAME"]; if (!isTableSourceToIgnore(tableName) && DoesNotContainProblematicChars(tableName)) { string qualifiedTableName = GetQualifiedIdentifier(databaseInfo.Database, tableName); tables.Add(new iDB2TableSourceInfo(DatabaseServices, databaseInfo, tableName, qualifiedTableName)); } } } } return(tables); }
public string EscapeAndQualifyIdentifier(IDatabaseInfo database, string objectName) { string catalogName = ((DatabaseInfo)database).Catalog; // Only the dbo schema is supported for now return(EscapeIdentifier(catalogName) + ".DBO." + EscapeIdentifier(objectName)); }
public override IEnumerable <string> DropColumn(IPlatformTableSourceColumnInfo existingColumn) { var result = new List <string>(); if (existingColumn.IsAutoGenerated) { var columnInfo = (PlatformTableSourceColumnInfo)existingColumn; IDatabaseInfo databaseInfo = existingColumn.TableSource.Database; string triggerName = columnInfo.AutoNumberTriggerName; if (!String.IsNullOrEmpty(triggerName)) { result.Add(String.Format("DROP TRIGGER {0}", Identifiers.EscapeAndQualifyIdentifier(databaseInfo, triggerName))); } string sequenceName = columnInfo.AutoNumberSequenceName; if (!String.IsNullOrEmpty(sequenceName)) { result.Add(String.Format("DROP SEQUENCE {0}", Identifiers.EscapeAndQualifyIdentifier(databaseInfo, sequenceName))); } } result.AddRange(base.DropColumn(existingColumn)); return(result); }
public static IDialectProvider CreateDialectProvider(string databaseId) { databaseId.ThrowIfNullArgument(nameof(databaseId)); IORMConfig cfg = ORMConfig.ORMConfiguration; IDatabaseInfo info = cfg.GetDatabaseInfo(databaseId); if (string.IsNullOrEmpty(info.DialectProvider)) { switch (info.DialectId) { case Dialect.OLEDB: return(new RexToy.ORM.Dialect.OleDb.DialectProvider()); case Dialect.MSSQL: return(new RexToy.ORM.Dialect.MSSql.DialectProvider()); default: CoreFactoryExceptionHelper.ThrowNoDefaultDialectProvider(info.DialectId); return(null); } } else { try { return(Reflector.LoadInstance <IDialectProvider>(info.DialectProvider)); } catch (Exception ex) { throw ex.CreateWrapException <CoreFactoryException>(); } } }
public SolutionBuilder(IDatabaseInfo database, string solutionName, string dbname, string dbconnStr) { this._database = database; this.SolutionName = solutionName; this.DataBaseName = dbname; this.DBConnectionString = dbconnStr; this.solutionID = Guid.NewGuid(); this.entitiesProjID = Guid.NewGuid(); this.testProjID = Guid.NewGuid(); this.solutionFolder = System.IO.Path.Combine(Environment.CurrentDirectory, this.SolutionName); this.entitiesProjName = solutionName + ".DataAccess"; this.entitiesProjectFolder = System.IO.Path.Combine(solutionFolder, this.entitiesProjName); this.testProjName = solutionName + ".Test"; this.testProjectFolder = System.IO.Path.Combine(solutionFolder, this.testProjName); if (Directory.Exists(this.solutionFolder)) { Directory.Delete(this.solutionFolder, true); } Directory.CreateDirectory(this.solutionFolder); }
public override IGrid GetGrid(IDatabaseInfo db) { switch (GridType) { case GridTypes.Structured: return(Grid3D.Cartesian3DGrid( GenericBlas.Linspace(-2.0, 2.0, 2), GenericBlas.Linspace(-1.0, 1.0, 2), GenericBlas.Linspace(-1.0, 1.0, 2))); //return Grid3D.Cartesian3DGrid( // GenericBlas.Linspace(0.0, 2.0, 2), // GenericBlas.Linspace(-1.0, 1.0, 2), // GenericBlas.Linspace(-1.0, 1.0, 2)); //return Grid3D.Cartesian3DGrid( // GenericBlas.Linspace(0.0, 4.0, 2), // GenericBlas.Linspace(-1.0, 1.0, 3), // GenericBlas.Linspace(-1.0, 1.0, 4)); case GridTypes.Unstructured: throw new NotImplementedException(); default: throw new ArgumentException(); } }
public static async Task Async_Lambda() { IDatabaseInfo dbInfo = SampleApplication.OneAgentSdk.CreateDatabaseInfo("MyDb", "MyVendor", ChannelType.TCP_IP, "database.example.com:1234"); IDatabaseRequestTracer dbTracer = SampleApplication.OneAgentSdk.TraceSQLDatabaseRequest(dbInfo, "Select * From AA"); int res = await dbTracer.TraceAsync(() => ExecuteDbCallIntAsync()); }
/// <summary> /// Searches for an equivalent grid in the database and, if none is found /// saves a grid object to the database. /// </summary> /// <param name="grid"> /// On entry, the grid which should be saved to the database. /// On exit, either unchanged, or the equivalent grid. /// </param> /// <param name="EquivalentGridFound"> /// Indicates that an equivalent grid was found. /// </param> /// <param name="database"></param> public Guid SaveGridIfUnique(ref IGrid grid, out bool EquivalentGridFound, IDatabaseInfo database) { using (new FuncTrace()) { var Grids = database.Grids; foreach (var GrdInf in Grids) { IGrid gridInDatabase = (IGrid)this.LoadGridInfo(GrdInf.ID, database); IEqualityComparer <IGrid> cellComparer = grid.GridSerializationHandler.CellComparer; IEqualityComparer <IGrid> referenceComparer = grid.GridSerializationHandler.BasePropertiesComparer; if (referenceComparer.Equals(grid, gridInDatabase)) { gridInDatabase = LoadGridData(gridInDatabase); if (cellComparer.Equals(grid, gridInDatabase)) { grid = gridInDatabase; EquivalentGridFound = true; return(grid.ID); } } } EquivalentGridFound = false; var g = SaveGrid(grid, database); return(g); } }
/// <summary> /// loads the grid identified by <paramref name="uid"/> from the /// given <paramref name="database"/> /// </summary> /// <param name="uid">The unique identifier of the grid.</param> /// <param name="database"> /// The database that is associated with the grid. /// </param> /// <returns> /// The loaded grid /// </returns> public IGrid LoadGrid(Guid uid, IDatabaseInfo database) { IGridInfo gridInfo = LoadGridInfo(uid, database); IGrid grid = LoadGridData((IGrid)gridInfo); return(grid); }
public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore) { DatabaseInfo dbInfo = database as DatabaseInfo; if (dbInfo == null) { throw new IntrospectionServiceException("Expected " + typeof(DatabaseInfo).FullName + " type but found " + (database == null ? "NULL" : database.GetType().FullName)); } if (!CheckDatabaseExists(dbInfo)) { throw new IntrospectionServiceException("Database not found: " + dbInfo.Identifier); } using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { using (IDbCommand cmd = CreateListTableSourcesCommand(dbInfo, conn)) { cmd.CommandTimeout = QueryTimeout; using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string tableName = Convert.ToString(reader["TABLE_NAME"]); if (!dbInfo.IsLinkedServer && isTableSourceToIgnore(tableName)) { continue; } string tableSchema = Convert.ToString(reader["TABLE_SCHEM"]); yield return(new TableSourceInfo(DatabaseServices, dbInfo, tableName, tableSchema, GetQualifiedTableName(dbInfo, tableName, tableSchema))); } } } } }
public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore) { IList <ITableSourceInfo> tables = new List <ITableSourceInfo>(); DB2ZOSDatabaseInfo databaseInfo = database as DB2ZOSDatabaseInfo; if (databaseInfo == null) { return(null); } using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { string sql = "SELECT NAME as TABLE_NAME " + "FROM SYSIBM.SYSTABLES " + "WHERE TYPE in ('T', 'V', 'P') and CREATOR = '" + database.Identifier + "' "; //Console.WriteLine("ListTableSources SQL: " + sql); IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, sql); cmd.CommandTimeout = QueryTimeout; using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string tableName = (string)reader["TABLE_NAME"]; if (!isTableSourceToIgnore(tableName) && DoesNotContainProblematicChars(tableName)) { string qualifiedTableName = GetQualifiedIdentifier(databaseInfo.Database, tableName); tables.Add(new DB2ZOSTableSourceInfo(DatabaseServices, databaseInfo, tableName, qualifiedTableName)); } } } } return(tables); }
public DBDocBuilder(IDatabaseInfo database) { if (database == null) throw new Exception("数据库不能为空。"); this._database = database; Guid folderID = Guid.NewGuid(); this._targetFolder = Path.Combine(Path.GetTempPath(), folderID.ToString("P")); Directory.CreateDirectory(_targetFolder); try { if (!Directory.Exists(this._targetFolder)) { Directory.CreateDirectory(this._targetFolder); } else { Directory.Delete(this._targetFolder, true); Directory.CreateDirectory(this._targetFolder); } } catch (Exception) { throw new Exception("目标文件夹创建失败。"); } }
public static async Task Async_Exception_Lambda_And_Async_Exception_Lambda() { IDatabaseInfo dbInfo = SampleApplication.OneAgentSdk.CreateDatabaseInfo("MyDb", "MyVendor", ChannelType.TCP_IP, "database.example.com:1234"); IDatabaseRequestTracer dbTracer = SampleApplication.OneAgentSdk.TraceSQLDatabaseRequest(dbInfo, "Select * From AA"); try { await dbTracer.TraceAsync(() => ExecuteDbCallVoidExceptionAsync()); } catch (Exception e) { Console.WriteLine($"Exception in {nameof(Async_Exception_Lambda_And_Async_Exception_Lambda)}, Message: {e.Message}"); } IDatabaseInfo dbInfo2 = SampleApplication.OneAgentSdk.CreateDatabaseInfo("MyDb2", "MyVendor2", ChannelType.TCP_IP, "database.example.com:1234"); IDatabaseRequestTracer dbTracer2 = SampleApplication.OneAgentSdk.TraceSQLDatabaseRequest(dbInfo2, "Select2 * From AA"); try { int result = await dbTracer2.TraceAsync(() => ExecuteDbCallIntExceptionAsync()); } catch (Exception e) { Console.WriteLine($"Exception in {nameof(Async_Exception_Lambda_And_Async_Exception_Lambda)}, Message: {e.Message}"); } }
public string Build(IDatabaseInfo database, string tableName, string ns, string webns, string modalName) { try { if (!Directory.Exists(_targetFolder)) { Directory.CreateDirectory(_targetFolder); } else { Directory.Delete(_targetFolder, true); Directory.CreateDirectory(_targetFolder); } } catch (Exception) { throw new Exception("目标文件夹创建失败。"); } List<string> filePaths = new List<string>(); foreach (ITableInfo tInfo in database.Tables) { if (tInfo.LowerName != tableName.ToLower()) { continue; } Build(tInfo, ns, webns, modalName); } return _targetFolder; }
private void BindUI(IDatabaseInfo db) { this.Database = db; this.SelectedChildTable = null; this.SelectedParentTable = null; this.cbForeignKey.Items.Clear(); this.cbForeignKey.Text = ""; this.gvFields.Rows.Clear(); cbTablesForChild.Items.Clear(); cbTablesForParent.Items.Clear(); cbTablesForChild.Text = ""; cbTablesForParent.Text = ""; if (db != null) { foreach (var table in db.Tables) { cbTablesForChild.Items.Add(table.Name); cbTablesForParent.Items.Add(table.Name); } AspnetMVCSetting setting = SettingStore.Instance.Get<AspnetMVCSetting>(db.Name + "_aspnetmvc.xml"); if (setting != null) { txtNamespace.Text = setting.Namespace; txtWebProjNameSpace.Text = setting.WebProjNameSpace; } } }
public CreateDatabaseUserRequest( IDatabaseInfo database, long userId, string name) : this(database.Id, userId, name) { }
/// <summary> /// Returns a list of table sources (e.g. tables, views) that belong to a given database. /// The returned table sources must have different display names. /// </summary> /// <param name="database">Database from which we want to fetch the list of tables</param> /// <param name="isTableSourceToIgnore">The delegate to call to see if the table source should be ignored and excluded from the returned list</param> /// <returns>List of available table sources in the given database</returns> /// <exception cref="System.Data.Common.DbException">if an error occurs while accessing the database</exception> public override IEnumerable <ITableSourceInfo> ListTableSources(IDatabaseInfo database, IsTableSourceToIgnore isTableSourceToIgnore) { IList <ITableSourceInfo> tables = new List <ITableSourceInfo>(); CacheDatabaseInfo databaseInfo = database as CacheDatabaseInfo; if (databaseInfo == null) { return(null); } using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) { string sql = string.Format(@"SELECT SqlQualifiedNameQ, SqlTableName FROM %Dictionary.CompiledClass WHERE SqlSchemaName = '{0}' AND ClassType IN ('persistent', 'view')", databaseInfo.Identifier); IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, sql); cmd.CommandTimeout = QueryTimeout; using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string tableName = (string)reader["SqlTableName"]; string qualifiedTableName = (string)reader["SqlQualifiedNameQ"]; if (!isTableSourceToIgnore(tableName)) { tables.Add(new CacheTableSourceInfo(DatabaseServices, databaseInfo, tableName, qualifiedTableName)); } } } } return(tables); }
public void TestListDatabasesFindCurrentDatabase(DatabaseProviderTestCase tc) { var databaseServices = tc.Services; IEnumerable <IDatabaseInfo> databases = databaseServices.IntrospectionService.ListDatabases(); IDatabaseInfo currentDBInfo = databaseServices.ObjectFactory.CreateDatabaseInfo(GetDatabaseIdentifier(databaseServices)); Assert.IsNotNull(databases.FirstOrDefault(db => db.Equals(currentDBInfo)), "Current database (" + currentDBInfo.Identifier + ") not found in the list."); }
/// <summary> /// Counts the number of files that are associated with all grids in a /// database. For every grid there should be one .grid and one or more /// .data file(s) in the database. /// </summary> /// <param name="db">The database in question.</param> /// <returns>The number of files that belong to the database's grids.</returns> private int CountGridFiles(IDatabaseInfo db) { int fileCount = db.Controller.Grids.Distinct() .SelectMany(grd => db.Controller.GetGridFiles(grd)) .Count(); return(fileCount); }
public Task <IReadOnlyList <DatabaseUser> > ListAsync(IDatabaseInfo database) { Ensure.NotNull(database, nameof(database)); return(db.DatabaseUsers.QueryAsync( And(Eq("databaseId", database.Id), IsNull("deleted")) )); }
public string GetWorkingFolder(IDatabaseInfo dbInfo) { string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(OrganizationServiceContextGenerator)).Location); string hostname = new Uri(dbInfo.Server).Host; workingDirectory = Path.Combine(workingDirectory, hostname); return(workingDirectory); }
public static void TestLoadGrids() { IGrid grid = CreateVoronoiGrid(); Guid gridId = GridMethods.SaveGrid(grid); IGrid databaseGrid = GridMethods.LoadGrid(gridId); IDatabaseInfo database = databaseGrid.Database; IEnumerable <IGridInfo> grids = database.Grids; }
/// <summary> /// Loads the field with name <paramref name="fieldName"/> within the /// time-step with id <paramref name="timestepGuid"/> from the /// database. /// </summary> /// <param name="gridData"></param> /// <param name="timestepGuid"></param> /// <param name="fieldName"></param> /// <returns></returns> private static DGField GetStoredField(GridData gridData, Guid timestepGuid, string fieldName) { IDatabaseInfo database = gridData.Grid.Database; ITimestepInfo tsi = database.Controller.DBDriver.LoadTimestepInfo( timestepGuid, null, database); return(database.Controller.DBDriver.LoadFields(tsi, gridData, new[] { fieldName }).Single()); }
public async Task <bool> DeleteAsync(IDatabaseInfo database) { Ensure.NotNull(database, nameof(database)); return(await db.Databases.PatchAsync(database.Id, new[] { Change.Replace("deleted", Now) }, condition : IsNull("deleted")) > 0); }
public CreateDatabaseGrantRequest( IDatabaseInfo database, DbObject resource, string[] privileges, long userId) : this(database.Id, resource, privileges, userId) { }
public Task <IReadOnlyList <DatabaseBackup> > ListAsync(IDatabaseInfo database) { Ensure.NotNull(database, nameof(database)); var range = ScopedId.GetRange(database.Id); return(db.DatabaseBackups.QueryAsync(Between("id", range.Start, range.End), Order.Descending("id"))); }
public override bool Equals(IDatabaseInfo other) { DatabaseInfo dbi = other as DatabaseInfo; return(ReferenceEquals(this, other) || (dbi != null && Catalog.EqualsIgnoreCase(dbi.Catalog) && IsLinkedServer == dbi.IsLinkedServer && LinkedServer.EqualsIgnoreCase(dbi.LinkedServer))); }
/// <summary> /// Creates a proxy for the grid with id <paramref name="gridGuid"/> /// within the given <paramref name="database"/> /// </summary> /// <param name="gridGuid"></param> /// <param name="database"></param> public GridProxy(Guid gridGuid, IDatabaseInfo database) { this.ID = gridGuid; this.Database = database; realGrid = new ExpirableLazy <IGrid>( () => database.Controller.DBDriver.LoadGridInfo(gridGuid, database).Cast <IGrid>(), g => Utils.GetGridFileWriteTime(g) == g.WriteTime); }
public override IGrid GetGrid(IDatabaseInfo db) { IGrid grid; switch (GridType) { case GridTypes.Structured: int noOfCellsPerDirection; switch (GridSize) { case GridSizes.Tiny: noOfCellsPerDirection = 5; break; case GridSizes.Small: noOfCellsPerDirection = 10; break; case GridSizes.Normal: noOfCellsPerDirection = 20; break; case GridSizes.Large: noOfCellsPerDirection = 40; break; case GridSizes.Huge: noOfCellsPerDirection = 80; break; default: throw new Exception(); } grid = Grid2D.Cartesian2DGrid( GenericBlas.Linspace(-2.0, 2.0, noOfCellsPerDirection + 1), GenericBlas.Linspace(-2.0, 2.0, noOfCellsPerDirection + 1), CellType.Square_Linear, false, false, null, new BoundingBox(new double[, ] { { -0.2, -0.2 }, { 0.2, 0.2 } })); break; case GridTypes.Unstructured: grid = db.Controller.DBDriver.LoadGrid( new Guid("7a4cf525-76e0-44fc-add2-7ce683a082c3"), db); break; default: throw new Exception(); } return(grid); }
/// <summary> /// Creates a new instance of SessionInfo. /// </summary> /// <param name="uid">The unique identifier of the session.</param> /// <param name="database">The database where the session is stored.</param> public SessionInfo(Guid uid, IDatabaseInfo database) { ID = uid; Database = database; CreationTime = DateTime.Now; // initialize tags as empty list Tags = new List <string>(); }
public Task <IReadOnlyList <DatabaseGrant> > ListAsync(IDatabaseInfo database) { Ensure.NotNull(database, nameof(database)); var range = ScopedId.GetRange(database.Id); return(db.DatabaseGrants.QueryAsync( And(Between("id", range.Start, range.End), IsNull("deleted")) )); }
public void TestListTableSourcesFindAllExpectedTableSources(DatabaseProviderTestCase tc) { var databaseServices = tc.Services; IDatabaseInfo db = databaseServices.ObjectFactory.CreateDatabaseInfo(GetDatabaseIdentifier(databaseServices)); IEnumerable <ITableSourceInfo> tableSources = databaseServices.IntrospectionService.ListTableSourcesWithoutFilter(db); foreach (var tableSourceName in bootstrappedTableName) { Assert.IsNotNull(tableSources.FirstOrDefault(ts => ts.Name.Equals(tableSourceName, StringComparison.InvariantCultureIgnoreCase)), "Table source named '" + tableSourceName + "' not found in the database"); } }
private void BindUI(IDatabaseInfo db) { this.Database = db; lvMain.Items.Clear(); lvMain.Groups.Add("table", "表"); lvMain.Groups.Add("view", "视图"); lvMain.Groups.Add("proc", "存储过程"); lvMain.Columns.Add(new ColumnHeader() { Name = "Name", Width = 150 }); lvMain.HeaderStyle = ColumnHeaderStyle.Clickable; lvMain.Sorting = SortOrder.Ascending; if (this.Database != null) { txtProjName.Text = string.Format("{0}_{1:yyyyMMddHHmmss}", this.Database.Name, DateTime.Now); } }
public EntitiesBuilder(IDatabaseInfo database, string dbname, string nameSpace, string targetFoler) { if (database == null) throw new Exception("数据库不能为空。"); if (string.IsNullOrEmpty(targetFoler)) throw new Exception("目标文件夹不能为空。"); if (string.IsNullOrEmpty(nameSpace)) throw new Exception("命名空间不能为空。"); this._database = database; this._targetFolder = Path.Combine(targetFoler, ""); this._dbname = dbname; this._namespace = nameSpace; //OleDbConnection conn = new OleDbConnection(dbConnStr); //try //{ // conn.Open(); //} //catch (Exception) //{ // throw new Exception("数据库连接失败。"); //} //finally //{ // conn.Close(); //} try { if (!Directory.Exists(this._targetFolder)) { Directory.CreateDirectory(this._targetFolder); } else { Directory.Delete(this._targetFolder, true); Directory.CreateDirectory(this._targetFolder); } } catch (Exception) { throw new Exception("目标文件夹创建失败。"); } }
private void BindUI(IDatabaseInfo db) { this.Database = db; cbTables.Items.Clear(); cbTables.Text = ""; if (db != null) { foreach (var table in db.Tables) { cbTables.Items.Add(table.Name); } AspnetMVCSetting setting = SettingStore.Instance.Get<AspnetMVCSetting>(db.Name + "_aspnetmvc.xml"); if (setting != null) { txtNamespace.Text = setting.Namespace; txtWebProjNameSpace.Text = setting.WebProjNameSpace; } } }
/// <summary> /// 将新数据结构同步到本地 /// </summary> public static IDatabaseInfo SyncToLocal(IDatabaseInfo db) { XElement root = null; string filePath = GetStorePath(db); if (File.Exists(filePath)) { string txt = File.ReadAllText(filePath); root = XElement.Parse(txt); } if (root == null) { root = new XElement("database"); } UpdateTables(root, db.Tables); XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), root); xdoc.Save(filePath); return db; }
/// <summary> /// 保存说明 /// </summary> public static void SaveDesc(IDatabaseInfo db) { string filePath = GetStorePath(db); //save XElement root = new XElement("database"); foreach (ITableInfo tb in db.Tables) { XElement elTable = new XElement("table"); elTable.Add(new XAttribute("rawname", tb.RawName)); elTable.Add(new XAttribute("schema", tb.Schema)); string table_desc = tb.Description; if (!string.IsNullOrEmpty(tb["new_desc"])) { table_desc = tb["new_desc"]; tb.Description = table_desc; tb["local_desc"] = table_desc; tb["new_desc"] = ""; SQLHelper.SetTableDesc(App.Instance.DBLink.ConnectionString, tb.Schema, tb.RawName, table_desc); } elTable.Add(new XAttribute("desc", table_desc)); foreach (IColumnInfo col in tb.Columns) { string desc = col.Description; if (!string.IsNullOrEmpty(col["new_desc"])) { desc = col["new_desc"]; col.Description = desc; col["local_desc"] = desc; col["new_desc"] = ""; SQLHelper.SetColumnDesc(App.Instance.DBLink.ConnectionString, tb.Schema, tb.RawName, col.RawName, desc); } XElement elColumn = new XElement("column"); elColumn.Add(new XAttribute("rawname", col.RawName)); elColumn.Add(new XAttribute("dbtype", col.DBType)); elColumn.Add(new XAttribute("dbtargettype", col.DbTargetType)); elColumn.Add(new XAttribute("languagetype", col.LanguageType)); elColumn.Add(new XAttribute("desc", desc)); elColumn.Add(new XAttribute("nullable", col.Nullable)); elColumn.Add(new XAttribute("iskey", col.IsPrimaryKey)); elColumn.Add(new XAttribute("maxlength", col.MaxLength)); elColumn.Add(new XAttribute("precision", col.Precision)); elColumn.Add(new XAttribute("scale", col.Scale)); elColumn.Add(new XAttribute("identity", col.Identity)); elColumn.Add(new XAttribute("computed", col.Computed)); elTable.Add(elColumn); } root.Add(elTable); } XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), root); xdoc.Save(filePath); }
internal ProcedureInfo(DatabaseInfo database) { this._database = database; this.loader = database.Loader; }
private static string GetStorePath(IDatabaseInfo db) { return Path.Combine(Environment.CurrentDirectory, "Settings\\" + "db_" + App.Instance.DBName + ".xml"); }
bool IDatabaseInfo.IsEquivalent(IDatabaseInfo other) { if (other == null) { return false; } if ((this.CustomCxString.Length > 0) != (other.CustomCxString.Length > 0)) { return false; } if (this.CustomCxString.Length > 0) { return (this.CustomCxString.ToLowerInvariant() == other.CustomCxString.ToLowerInvariant()); } if (this.IsSqlCE != other.IsSqlCE) { return false; } if (this.IsSqlCE) { return (string.Equals(this.Provider, other.Provider, StringComparison.OrdinalIgnoreCase) && string.Equals(this.AttachFileName, other.AttachFileName, StringComparison.OrdinalIgnoreCase)); } if (!string.Equals(this.Server, other.Server, StringComparison.OrdinalIgnoreCase)) { return false; } if (this.SqlSecurity != other.SqlSecurity) { return false; } if (!(!this.SqlSecurity || string.Equals(this.UserName, other.UserName, StringComparison.OrdinalIgnoreCase))) { return false; } if (this.AttachFile != other.AttachFile) { return false; } if (!(!this.AttachFile || string.Equals(this.AttachFileName, other.AttachFileName, StringComparison.OrdinalIgnoreCase))) { return false; } if (!(this.AttachFile || string.Equals(this.Database, other.Database, StringComparison.OrdinalIgnoreCase))) { return false; } Repository repository = other as Repository; if (!(from d in this._linkedDbs orderby d select d).SequenceEqual<LinkedDatabase>((from d in repository._linkedDbs orderby d select d))) { return false; } return true; }
public void Reload(IDatabaseInfo db) { bool node0Expand = false; bool node1Expand = false; bool node2Expand = false; if(tvSchema.Nodes.Count > 0) { node0Expand = tvSchema.Nodes[0].IsExpanded; } if (tvSchema.Nodes.Count > 1) { node1Expand = tvSchema.Nodes[1].IsExpanded; } if (tvSchema.Nodes.Count > 2) { node2Expand = tvSchema.Nodes[2].IsExpanded; } this.DB = db; InitTree(); if (node0Expand) { tvSchema.Nodes[0].Expand(); } if (node1Expand) { tvSchema.Nodes[1].Expand(); } if (node2Expand) { tvSchema.Nodes[2].Expand(); } if (App.Instance.SelectedNode != null) { var txt = App.Instance.SelectedNode.Text; TreeNode node = null; if (App.Instance.SelectedNode.Tag is ITableInfo) { node = tvSchema.Nodes[0]; } else if (App.Instance.SelectedNode.Tag is IViewInfo) { node = tvSchema.Nodes[1]; } else if (App.Instance.SelectedNode.Tag is IProcedureInfo) { node = tvSchema.Nodes[2]; } if (!string.IsNullOrEmpty(txt) && node != null) { foreach (TreeNode item in node.Nodes) { if (item.Text == txt) { this.tvSchema.SelectedNode = item; break; } } } } this.SelectFirstNode(); }
internal ViewInfo(DatabaseInfo database) { this._database = database; this.loader = database.Loader; }