/// <summary> /// Synchronize database. /// </summary> /// <param name="businessModel">Business model.</param> public override void Sync(APGenBusinessModelSection businessModel) { using (APDatabase db = new APDatabase(this)) { try { db.BeginTrans(); foreach (APGenTable table in GetAllTables(businessModel)) { _setScanTable(table.TableName); DbCommand dbCmd = db.CreateSqlCommand("select table_name from user_tables where temporary = 'N' and table_name = '{0}'", table.TableName.ToUpper()); object id = dbCmd.ExecuteScalar(); if (id == null) CreateTable(db, table); else ModifyTable(db, table); } SyncSequence(db, businessModel); db.Commit(); } catch(Exception ex) { db.Rollback(); throw new ProviderException(String.Format("Table: {0}, Column: {1}", scanTableName, scanColumnName), ex); } } }
private void _tempSql(string sql) { DbCommand dbCmd; using (APDatabase dbtemp = new APDatabase(this)) { try { dbtemp.BeginTrans(); dbCmd = dbtemp.CreateSqlCommand(sql); dbCmd.ExecuteNonQuery(); dbtemp.Commit(); } catch { dbtemp.Rollback(); } } }
/// <summary> /// Synchronize database. /// </summary> /// <param name="businessModel">Business model.</param> public override void Sync(APGenBusinessModelSection businessModel) { using (APDatabase db = new APDatabase(this)) { try { db.BeginTrans(); foreach (APGenTable table in GetAllTables(businessModel)) { _setScanTable(table.TableName); DbCommand dbCmd = db.CreateSqlCommand("select id from sysobjects where type = 'U' and name = '{0}'", table.TableName); object id = dbCmd.ExecuteScalar(); if (id == null) { CreateTable(db, table); } else { ModifyTable(db, table); } } SyncCurrentId(db, businessModel); //_createCurrentIdProc(db); db.Commit(); } catch (Exception ex) { db.Rollback(); throw new ProviderException(String.Format("Table: {0}, Column: {1}", scanTableName, scanColumnName), ex); } } }
/// <summary> /// Synchronize database. /// </summary> /// <param name="businessModel">Business model.</param> public override void Sync(APGenBusinessModelSection businessModel) { using (APDatabase db = new APDatabase(this)) { try { db.BeginTrans(); foreach (APGenTable table in GetAllTables(businessModel)) { _setScanTable(table.TableName); DbCommand dbCmd = db.CreateSqlCommand("select table_name from user_tables where temporary = 'N' and table_name = '{0}'", table.TableName.ToUpper()); object id = dbCmd.ExecuteScalar(); if (id == null) { CreateTable(db, table); } else { ModifyTable(db, table); } } SyncSequence(db, businessModel); db.Commit(); } catch (Exception ex) { db.Rollback(); throw new ProviderException(String.Format("Table: {0}, Column: {1}", scanTableName, scanColumnName), ex); } } }
/// <summary> /// Synchronize database. /// </summary> /// <param name="businessModel">Business model.</param> public override void Sync(APGenBusinessModelSection businessModel) { using (APDatabase db = new APDatabase(this)) { try { db.BeginTrans(); foreach (APGenTable table in GetAllTables(businessModel)) { _setScanTable(table.TableName); DbCommand dbCmd = db.CreateSqlCommand("select id from sysobjects where type = 'U' and name = '{0}'", table.TableName); object id = dbCmd.ExecuteScalar(); if (id == null) CreateTable(db, table); else ModifyTable(db, table); } SyncCurrentId(db, businessModel); //_createCurrentIdProc(db); db.Commit(); } catch (Exception ex) { db.Rollback(); throw new ProviderException(String.Format("Table: {0}, Column: {1}", scanTableName, scanColumnName), ex); } } }