Ejemplo n.º 1
0
        /// <summary>
        /// Creates temporary table
        /// </summary>
        /// <param name="tempTableName">temporary table name</param>
        public void CreateTempTable(string tempTableName)
        {
            IDTSInput100 input = _componentMetaData.InputCollection[Constants.INPUT_NAME];
            string       templateCreateTempTable = SqlCreator.GetCreateTempTable(_IsagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS);
            string       sqlCreateTempTable      = templateCreateTempTable.Replace(Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS, tempTableName);

            if (!_IsagCustomProperties.UseBulkInsert)
            {
                SqlExecutor.ExecSql(sqlCreateTempTable, _bulkConn, _IsagCustomProperties.TimeOutDb, _dbTransaction);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Truncates table
        /// </summary>
        /// <param name="tempTableName"></param>
        public void TruncateTempTable(string tempTableName)
        {
            try
            {
                SqlExecutor.TruncateTable(tempTableName, _bulkConn, _IsagCustomProperties.TimeOutDb, _dbTransaction);

                _events.Fire(IsagEvents.IsagEventType.TempTableTruncate,
                             string.Format("Temporary Table [{0}] has been truncated [{1}].", tempTableName, DateTime.Now.ToString()));
            }
            catch (Exception ex)
            {
                _events.FireError(new string[] { string.Format("Cannot truncate tempory table {0} [{1}]. ", tempTableName, DateTime.Now.ToString()) + ex.ToString() });

                throw ex;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Drops temporary table
        /// </summary>
        /// <param name="tempTableName">temporary table name</param>
        /// <param name="eventType">Isag event type</param>
        public void DropTempTable(string tempTableName, IsagEvents.IsagEventType eventType)
        {
            try
            {
                SqlExecutor.DropTable(tempTableName, _bulkConn, _IsagCustomProperties.TimeOutDb, _dbTransaction);

                _events.Fire(eventType, string.Format("[Exec DbCommand: {0}]: Temporary Table has been dropped. ({1})",
                                                      eventType.ToString(), DateTime.Now.ToString()));
            }
            catch (Exception ex)
            {
                _events.Fire(eventType, string.Format("[Exec DbCommand: {0}]: Unable to drop temporary table. ({1})",
                                                      eventType.ToString(), DateTime.Now.ToString()));

                throw ex;
            }
        }
        /// <summary>
        /// Executes pre- oder post execute command
        /// </summary>
        /// <param name="cmdType"> Events.IsagEventType.PreSql oder Events.IsagEventType.PostSql </param>
        private void ExecPreOrPostExecuteStatement(IsagEvents.IsagEventType cmdType)
        {
            string sql         = "";
            string cmdTypeName = "";

            try
            {
                if (cmdType == IsagEvents.IsagEventType.PreSql && _IsagCustomProperties.HasPreSql)
                {
                    sql         = _dbCommand.GetExecuteStatementFromTemplate(_IsagCustomProperties.PreSql);
                    cmdTypeName = "PreSql";
                }
                else if (cmdType == IsagEvents.IsagEventType.PostSql && _IsagCustomProperties.HasPostSql)
                {
                    sql         = _dbCommand.GetExecuteStatementFromTemplate(_IsagCustomProperties.PostSql);
                    cmdTypeName = "PostSql";
                }
                else if (cmdType != IsagEvents.IsagEventType.PreSql && cmdType != IsagEvents.IsagEventType.PostSql)
                {
                    throw new Exception("Unknown CommandType in ExecPrePostExecuteStatement: " + cmdType);
                }

                // execute pre- oder post execute command

                if (sql.Length > 0)
                {
                    SqlTransaction transaction  = _IsagCustomProperties.UseMultiThreading ? null : _txAll.Transaction;
                    int            rowsAffected = SqlExecutor.ExecSql(sql, Conn, _IsagCustomProperties.TimeOutDb, transaction);
                    _events.Fire(IsagEvents.IsagEventType.Sql,
                                 "[ExecSql:" + cmdType.ToString() + "]: {0} rows were affected by the Sql Command.",
                                 new string[] { rowsAffected.ToString(), ((int)cmdType).ToString() });
                    _events.Fire(cmdType, cmdTypeName + " Statement has been executed.");
                }
            }
            catch (Exception ex)
            {
                _events.FireError(new string[] { cmdTypeName, ex.Message });
                throw;
            }
        }