public static void Initialize()
        {
            if (logger != null)
            {
                logger.Close();
            }

            //logger = new Logger.Logger(GFXDConfigManager.GetClientSetting("logDir"),
            //    String.Format("{0}.log", typeof(DbHelper).FullName));
            logger = new Logger.Logger(Environment.GetEnvironmentVariable("GFXDADOOUTDIR"),
                                       String.Format("{0}.log", typeof(DbHelper).FullName));
            locker = new object();

            try
            {
                GFXDServerMgr.Initialize();
                DbDefault.CreateDB(String.Empty, DbCreateType.Replicate);
            }
            catch (Exception e)
            {
                Log(GetExceptionDetails(e, new StringBuilder()).ToString());
                throw new Exception(
                          "Encountered exception in Helper.Initialize(). Check log for detail.");
            }
        }
Beispiel #2
0
        private void PrepareInsert(TableName tableName)
        {
            IList <DbField> fields = DbDefault.GetTableStructure(tableName).Columns;
            StringBuilder   sql    = new StringBuilder();

            sql.Append("INSERT INTO " + tableName.ToString() + "(");

            for (int j = 0; j < fields.Count; j++)
            {
                sql.Append(fields[j].FieldName + ", ");
            }

            sql = sql.Remove(sql.Length - 2, 1).Append(")");

            sql.Append(" VALUES(");

            for (int k = 0; k < fields.Count; k++)
            {
                sql.Append("?, ");
            }

            sql = sql.Remove(sql.Length - 2, 1).Append(")");

            Command.CommandType = CommandType.Text;
            Command.CommandText = sql.ToString();
            Command.Prepare();
        }
Beispiel #3
0
        protected DataRow Select(TableName tableName, long identity)
        {
            String condition = String.Format("{0} = {1}",
                                             DbDefault.GetTableStructure(tableName).PKColumns[0], identity);

            return(Select(tableName, condition).Rows[0]);
        }
 public static void Cleanup()
 {
     try
     {
         DbDefault.DropDB(String.Empty);
     }
     catch (Exception e)
     {
         Log(GetExceptionDetails(e, new StringBuilder()).ToString());
         throw new Exception(
                   "Encountered exception in Helper.Cleanup(). Check log for detail.");
     }
     finally
     {
         GFXDServerMgr.Cleanup();
     }
 }
Beispiel #5
0
        protected int[] Insert(TableName tableName, int numRows)
        {
            IList <DbField> fields = DbDefault.GetTableStructure(tableName).Columns;

            int[] result = new int[numRows];

            PrepareInsert(tableName);
            for (int i = 0; i < numRows; i++)
            {
                foreach (DbField field in fields)
                {
                    Command.Parameters.Add(
                        DbRandom.GetRandomFieldData(field));
                }

                Command.AddBatch();
            }

            return(Command.ExecuteBatch());
        }
Beispiel #6
0
 public static String GetAddressQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.ADDRESS)));
 }
Beispiel #7
0
 public static String GetTableName(String schemaName, TableName tbEnum)
 {
     return(QualifyTableName(schemaName, DbDefault.GetTableName(tbEnum)));
 }
Beispiel #8
0
 public static String GetDropTableStatement(String schemaName, TableName tableName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetDropTableStatement(tableName)));
 }
Beispiel #9
0
 public static String GetDeleteStatement(String schemaName, TableName tableName, long[] primaryKey)
 {
     return(QualifyTableName(schemaName, DbDefault.GetDeleteStatement(tableName, primaryKey)));
 }
Beispiel #10
0
 public static String GetOrderDetailQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.ORDERDETAIL)));
 }
Beispiel #11
0
 public static String GetProductQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.PRODUCT)));
 }
Beispiel #12
0
 public static String GetInnerJoinSelectStatement(String schemaName, Relation relation, long[] pKey)
 {
     return(QualifyTableName(schemaName, DbDefault.GetInnerJoinSelectStatement(relation, pKey)));
 }
Beispiel #13
0
 public static String GetCreateTableFKPartitionColocateStatement(String schemaName, Relation relation)
 {
     return(QualifyTableName(schemaName, DbDefault.GetCreateTableFKPartitionColocateStatement(relation)));
 }
Beispiel #14
0
 public static String GetCreateTablePartitionByPKeyReplicateStatement(String schemaName, TableName tableName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetCreateTableReplicateStatement(tableName)));
 }
Beispiel #15
0
 public static String GetSupplierQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.SUPPLIER)));
 }
Beispiel #16
0
 public static String GetCategoryQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.CATEGORY)));
 }
Beispiel #17
0
 public static String GetLeftOuterJoinSelectStatement(String schemaName, Relation relation, String condition)
 {
     return(QualifyTableName(schemaName, DbDefault.GetLeftOuterJoinSelectStatement(relation, condition)));
 }
Beispiel #18
0
 public static String GetCustomerQuery(String schemaName)
 {
     return(QualifyTableName(schemaName, DbDefault.GetSelectStatement(TableName.CUSTOMER)));
 }
Beispiel #19
0
 public static String GetInsertStatement(String schemaName, TableName tableName, long[] pKey)
 {
     return(QualifyTableName(schemaName, DbDefault.GetInsertStatement(tableName, pKey)));
 }
 public int CreateView(Relation relation)
 {
     return(GFXDDbi.Create(Connection, DbDefault.GetCreateViewStatement(relation)));
 }
Beispiel #21
0
 public static String GetDeleteStatement(String schemaName, TableName tableName, String condition)
 {
     return(QualifyTableName(schemaName, DbDefault.GetDeleteStatement(tableName, condition)));
 }