예제 #1
0
        public void InsertTest()
        {
            DataTable dt = GetSampleData();

            cmmDao.Insert(dt, "ETL_TEST", null);

            DataTable result = cmmDao.Query(new string[] { "ID", "NAME" }, "ETL_TEST");

            Assert.AreEqual(dt.Rows.Count, result.Rows.Count);
        }
예제 #2
0
        public override DataTable GetData()
        {
            logger.Info("----- OracleDbSource.GetData start -----");
            DataTable dt = null;

            try
            {
                if (string.IsNullOrEmpty(setting.DbColumn))
                {
                    throw new Exception("Query [DbColumn] no setting. can't to query db.");
                }

                if (string.IsNullOrEmpty(setting.DbTable))
                {
                    throw new Exception("Query DB [Table] no setting. can't to query db.");
                }

                if (stTime.HasValue)
                {
                    logger.DebugFormat("Column : [{0}], Table : [{1}], Time Column : [{2}], Start : [{3}], End : [{4}]"
                                       , setting.DbColumn, setting.DbTable, setting.DbTimeColumn, stTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), endTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));

                    dt = comDao.Query(setting.DbColumn.Split(','), setting.DbTable, setting.DbTimeColumn, stTime.Value, endTime.Value);
                }
                else
                {
                    logger.DebugFormat("Column : [{0}], Table : [{1}]"
                                       , setting.DbColumn, setting.DbTable);

                    dt = comDao.Query(setting.DbColumn.Split(','), setting.DbTable);
                }

                logger.InfoFormat("Data count : {0}", dt.Rows.Count);
            }
            catch (Exception ex)
            {
                logger.Error("Query db fail.", ex);
                throw ex;
            }

            logger.Info("----- OracleDbSource.GetData end -----");
            return(dt);
        }