예제 #1
0
 /// <summary>
 /// 执行SQL
 /// </summary>
 public void Commit(Microsoft.Practices.EnterpriseLibrary.Data.Database dbinstance)
 {
     if (_buf.Length > 0 && dbinstance != null)
     {
         dbinstance.ExecuteNonQuery(System.Data.CommandType.Text, _buf.ToString());
     }
 }
예제 #2
0
        public static void buildParameter(Microsoft.Practices.EnterpriseLibrary.Data.Database db, DbCommand dbCommand, string name, object value)
        {
            DbParameter p = dbCommand.CreateParameter();

            p.Value = value;
            db.AddInParameter(dbCommand, name, p.DbType, value);
        }
        private void button8_Click(object sender, EventArgs e)
        {
            string name  = "@Name";
            string name2 = "@Name";

            using (MB.Util.MethodTraceWithTime trace = new MB.Util.MethodTraceWithTime("")) {
                Microsoft.Practices.EnterpriseLibrary.Data.Database db = MB.Orm.Persistence.DatabaseHelper.CreateDatabase();
                if (db is Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase)
                {
                    name = ":" + name.Substring(1, name.Length - 1);
                }

                double d1 = trace.GetExecutedTimes();
            }
            using (MB.Util.MethodTraceWithTime trace = new MB.Util.MethodTraceWithTime("")) {
                using (MB.Orm.Persistence.DatabaseConfigurationScope scop = new MB.Orm.Persistence.DatabaseConfigurationScope("SQL SERVER")) {
                    Microsoft.Practices.EnterpriseLibrary.Data.Database db2 = MB.Orm.Persistence.DatabaseHelper.CreateDatabase();
                    if (db2 is Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase)
                    {
                        name = ":" + name.Substring(1, name.Length - 1);
                    }
                    else if (db2 is Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase)
                    {
                        name = "@" + name.Substring(1, name.Length - 1);
                    }
                    else
                    {
                    }
                }
                double d2 = trace.GetExecutedTimes();
            }
        }
예제 #4
0
 /// <summary>
 /// Method to initialize enterprise library database container instance
 /// </summary>
 private void InstantiateDatabaseAccess()
 {
     if (dataAccess == null)
     {
         dataAccess = EnterpriseLibraryContainer.Current.GetInstance <Microsoft.Practices.EnterpriseLibrary.Data.Database>(AppUtil.GetAppSettings(AspectEnums.ConfigKeys.SQLDBConnectionName)) as SqlDatabase;
     }
     else
     {
         dataAccess = EnterpriseLibraryContainer.Current.GetInstance <Microsoft.Practices.EnterpriseLibrary.Data.Database>(AppUtil.GetAppSettings(AspectEnums.ConfigKeys.SQLDBConnectionName)) as SqlDatabase;
     }
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of <see cref="FormattedDatabaseTraceListener"/>.
 /// </summary>
 /// <param name="database">The database for writing the log.</param>
 /// <param name="writeLogStoredProcName">The stored procedure name for writing the log.</param>
 /// <param name="addCategoryStoredProcName">The stored procedure name for adding a category for this log.</param>
 /// <param name="formatter">The formatter.</param>        
 public FormattedDatabaseTraceListener(
     Microsoft.Practices.EnterpriseLibrary.Data.Database database,
     string writeLogStoredProcName,
     string addCategoryStoredProcName,
     IMsgFormatter formatter)
     : base(formatter)
 {
     this.writeLogStoredProcName = writeLogStoredProcName;
     this.addCategoryStoredProcName = addCategoryStoredProcName;
     this.database = database;
 }
예제 #6
0
 public static void LoadDataSet(DbCommand command, string tableName, ref DataSet ds)
 {
     try
     {
         Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
         db.LoadDataSet(command, ds, tableName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
        public override DbCommandWrapper InitializeCommand(Microsoft.Practices.EnterpriseLibrary.Data.Database db, MN.Enterprise.Base.DataTransferObject criteria)
        {
            Issue issueDto = criteria as Issue;

            //Create a database command object within which T-SQL commands can
            //be executed.
            DbCommandWrapper cw = DbCommandFactory.GetStoredProcCommandWrapper(db, "spGetVolumeAndIssueName");

            cw.AddInParameter("VolumeIssueId", DbType.Int32, issueDto.VolumeIssueId);

            return(cw);
        }
예제 #8
0
        /// <summary>
        /// Default constructor for the DbCommand Manager class.
        /// It expects a DataAccessMgr class instance in the constructor.
        /// </summary>
        /// <param name="dataAccessManager">string entry in configuration file for connection string</param>
        public DbCommandMgr(DataAccessMgr dataAccessManager)
        {
            _daMgr      = dataAccessManager;
            _database   = dataAccessManager.Database;
            _loggingMgr = dataAccessManager.loggingMgr;

            _noOpDbCommandText = _daMgr.NoOpDbCommandText;
            _paramAliases      = new Dictionary <string, List <DbParameter> >(StringComparer.CurrentCultureIgnoreCase);
            _dbCommand         = _daMgr.BuildNoOpDbCommand();
            if (_daMgr.DatabaseType == DataAccessMgr.EnumDbType.Oracle)
            {
                _commandBlockReady = false;
            }
        }
예제 #9
0
 /// <summary>
 /// Execute a non query returning resultset as a datatable
 /// </summary>
 /// <param name="command"></param>
 /// <returns>DataTable</returns>
 public static DataSet LoadDataSet(DbCommand command, string tableName)
 {
     DataSet ds = new DataSet();
     try
     {
         Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
         db.LoadDataSet(command, ds, tableName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return ds;
 }
예제 #10
0
        /// <summary>
        /// Create new database.
        /// 1. Oracle
        /// 2. Sql Server
        /// 3. DB2
        /// </summary>
        /// <returns></returns>
        public void SelectDataBase()
        {
            try
            {
                string connString = string.Empty;

                #region Oracle

                XMLConfigurationClasses.GeneralConfiguration generalConfig = XMLConfigurationClasses.GeneralConfiguration.Deserialize();

                string plainText = Cryptography.Encryption.Decrypt(
                    generalConfig.DatabasePassword,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.passPhrase,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.saltValue,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.hashAlgorithm,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.passwordIterations,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.initVector,
                    VaaaN.MLFF.Libraries.CommonLibrary.Constants.keySize);

                connString    = "Data Source = " + generalConfig.DatabaseServer + ";User ID=" + generalConfig.DatabaseUser + "; Password = "******";Unicode=True";
                this.database = new Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase(connString);

                #endregion

                #region SQL Server

                //connString = @"Data Source=192.168.1.51\ATMS;Initial Catalog=vaaan-atms;User ID=vaaan; password=vaaan;";
                //VaaaN.ATMS.Libraries.CommonLibrary.XMLConfigurationClasses.GeneralConfiguration generalConfig = VaaaN.ATMS.Libraries.CommonLibrary.XMLConfigurationClasses.GeneralConfiguration.Deserialize();

                //string plainText = VaaaN.ATMS.Libraries.CommonLibrary.Cryptography.Encryption.Decrypt(
                //       generalConfig.DatabasePassword,
                //       VaaaN.ATMS.Libraries.CommonLibrary.Constants.passPhrase,
                //      VaaaN.ATMS.Libraries.CommonLibrary.Constants.saltValue,
                //       VaaaN.ATMS.Libraries.CommonLibrary.Constants.hashAlgorithm,
                //       VaaaN.ATMS.Libraries.CommonLibrary.Constants.passwordIterations,
                //       VaaaN.ATMS.Libraries.CommonLibrary.Constants.initVector,
                //       VaaaN.ATMS.Libraries.CommonLibrary.Constants.keySize);

                //connString = @"Data Source=" + generalConfig.DatabaseServer + ";Initial Catalog=" + generalConfig.DatabaseName + ";User ID=" + generalConfig.DatabaseUser + "; password="******";";
                //this.database = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(connString);

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #11
0
        /// <summary>
        /// Create sql string command.
        /// </summary>
        /// <param name="query">sql query.</param>
        /// <returns>Returns the Db command.</returns>
        public static DbCommand GetSqlStringCommand(string query)
        {
            DbCommand dbCommand = null;

            try
            {
                Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
                dbCommand = db.GetSqlStringCommand(query);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dbCommand;
        }
예제 #12
0
        /// <summary>
        /// Returns an object by executing a scalar function
        /// </summary>
        /// <param name="command"></param>
        /// <returns>Object</returns>
        public static Object ExecuteScalar(DbCommand command)
        {
            object obj = new object();

            try
            {
                Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
                obj = db.ExecuteScalar(command);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return obj;
        }
예제 #13
0
        /// <summary>
        /// Execute the non query like insert, delete and update.
        /// </summary>
        /// <param name="command"></param>
        /// <returns>Numbers of rows affected.</returns>
        public static int ExecuteNonQuery(DbCommand command)
        {
            int rowsAffected = 0;

            try
            {
                Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
                rowsAffected = db.ExecuteNonQuery(command);
            }
            catch (Exception ex)
            {
                VaaaN.MLFF.Libraries.CommonLibrary.Logger.Log.WriteGeneralLog("Failed to execute non query." + ex.Message);
                throw ex;
            }

            return rowsAffected;
        }
예제 #14
0
        public override decimal GetTaxRate(string zip)
        {
            decimal dOut = 0;

            //load the default db from the base class
            Microsoft.Practices.EnterpriseLibrary.Data.Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase();
            //specify the SP
            string cmd = "CSK_Tax_GetTaxRate";

            using (DbCommand dbCommand = db.GetStoredProcCommand(cmd)) {
                db.AddInParameter(dbCommand, "@zip", DbType.String, zip);
                //return a reader using the Ent Blocks
                using (IDataReader rdr = db.ExecuteReader(dbCommand)) {
                    if (rdr.Read())
                    {
                        dOut = (decimal)rdr["rate"];
                    }
                }
                //load routine closes the reader if flag is set to true;
                return(dOut);
            }
        }
예제 #15
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public DComCarLocation()
 {
     this._db = this.SystemStore;
 }
예제 #16
0
 public static DbConnection CreateConnection()
 {
     Microsoft.Practices.EnterpriseLibrary.Data.Database db = DBSelector.Instance.GetDataBase;
     return db.CreateConnection();
 }
예제 #17
0
 public DSingleService()
 {
     _db = base.SystemStore;
 }
예제 #18
0
 public IdentityManager(Microsoft.Practices.EnterpriseLibrary.Data.Database DB)
     : base(DB)
 {
 }
예제 #19
0
 public DTourOrderChange()
 {
     _db = base.SystemStore;
 }
예제 #20
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public DComCarType()
 {
     _db = this.SystemStore;
 }
 /// <summary>
 /// Duplicate the recipient list configuration in product level.
 /// </summary>
 public override void Duplicate(Microsoft.Practices.EnterpriseLibrary.Data.Database db, IDbTransaction transaction, int srcProductID, int srcDocID, int destProductID, int destDocID)
 {
     // This method is called when duplicating a product or a store in the uStore back office.
     // if you save additional settings outside of uStore, you can duplicate them here. Otherwise, you can leave this method empty.
 }
예제 #22
0
 /// <summary>
 /// 以 <paramref name="database"/> 作为 <seealso cref="PrimitiveDatabase"/> 值初始化 <see cref="NDF.Data.Common.Database"/> 对象。
 /// </summary>
 /// <param name="database">指定的 <see cref="Microsoft.Practices.EnterpriseLibrary.Data.Database"/> 对象,表示微软企业库提供的一个数据库访问组件。</param>
 protected Database(Microsoft.Practices.EnterpriseLibrary.Data.Database database)
 {
     this.PrimitiveDatabase = database;
 }