protected override bool ConditionsIsEnough(IContextMessage contextMessage) { if (_dbConnection == null) { contextMessage.AddError("数据库连接对象为空。"); return(false); } try { _dbConnection.Open(); } catch (Exception ex) { contextMessage.AddError(ex.Message); return(false); } try { _metadata = new BudGISMetadata(); } catch (Exception ex) { contextMessage.AddError(ex.Message); return(false); } return(true); }
public virtual void Build(IDbConnection connection, BudGISMetadata metadata, IProgressTracker tracker, params object[] args) { IDbTransaction tran = connection.BeginTransaction(); try { using (IDbCommand cmd = connection.CreateCommand()) { cmd.Transaction = tran; cmd.CommandType = CommandType.Text; // int steps = 0; if (tracker != null) { tracker.StartTracking("开始创建元数据表...", 3); } //Create Tables CreateTables(connection, metadata, cmd, tracker, ref steps); } // tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } }
public virtual void Clear(IDbConnection connection, BudGISMetadata metadata, bool isClearDataTables, IProgressTracker tracker) { IDbTransaction tran = connection.BeginTransaction(); try { using (IDbCommand cmd = connection.CreateCommand()) { cmd.Transaction = tran; cmd.CommandType = CommandType.Text; if (tracker != null) { tracker.StartTracking("开始清空空间数据库...", 4); } //Clear dataTables if (isClearDataTables) { if (tracker != null) { tracker.Tracking("正在清空数据表...", 0); } ClearDataTables(connection, cmd); } //drop BGIS_FeatureClass if (tracker != null) { tracker.Tracking("正在删除系统表\"BGIS_FeatureClass\"...", 1); } cmd.CommandText = "drop table BGIS_FeatureClass"; cmd.ExecuteNonQuery(); //drop BGIS_FeatureDataset if (tracker != null) { tracker.Tracking("正在删除系统表\"BGIS_FeatureDataset\"...", 2); } cmd.CommandText = "drop table BGIS_FeatureDataset"; cmd.ExecuteNonQuery(); //drop BGIS_Map if (tracker != null) { tracker.Tracking("正在删除系统表\"BGIS_Map\"...", 3); } cmd.CommandText = "drop table BGIS_Map"; cmd.ExecuteNonQuery(); } // tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } }
private void CreateTables(IDbConnection connection, BudGISMetadata metadata, IDbCommand cmd, IProgressTracker tracker, ref int steps) { if (metadata.Tables == null || metadata.Tables.Length == 0) { throw new ArgumentNullException("空间数据库元数据配置对象错误,元数据表为空。"); } foreach (SystemTable table in metadata.Tables) { if (tracker != null) { tracker.Tracking("正在创建\"" + table.Name + "...", steps); } CreateTables(connection, table, cmd); steps++; } }