/// <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);
				}
			}
		}
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
        /// <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);
                }
            }
        }
예제 #4
0
        /// <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);
                }
            }
        }
예제 #5
0
		/// <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);
				}
			}
		}
		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();
				}
			}
		}