示例#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);
            }
        }
示例#2
0
        /// <summary>
        /// Add a bulk copy thread
        /// </summary>
        /// <param name="tempTableName">temporary tablename</param>
        /// <param name="dt">Datatable (buffer with rows to write to the temporary table)</param>
        /// <param name="useTableLock">Use tablock?</param>
        public void AddBulkCopyThread(string tempTableName, DataTable dt, bool useTableLock)
        {
            //Logging.Log(IsagEvents.IsagEventType.BulkInsert, string.Format("DataTable {0} created with {1} rows.", (_createdBulkCopyThreads + 1).ToString(), dt.Rows.Count.ToString()));
            _status.AddStatus(_createdBulkCopyThreads + 1, dt.Rows.Count, Status.StatusType.dataTableCreated, IsagEvents.IsagEventType.Status);
            UpdateStatus();

            string         templateCreateTempTable = SqlCreator.GetCreateTempTable(_isagCustomProperties, Constants.TEMP_TABLE_PLACEHOLDER_BRACKETS);
            ThreadBulkCopy thread = new ThreadBulkCopy(_dbCmdThread, tempTableName, dt, templateCreateTempTable, _timeoutDb, _reattempts, (_createdBulkCopyThreads + 1).ToString(),
                                                       _cstr, _conn, useTableLock, _isagCustomProperties.UseBulkInsert);
            bool showWaitMessage = true;

            while (WaitForFreeBulkCopyThread())
            {
                if (showWaitMessage)
                {
                    _events.Fire(IsagEvents.IsagEventType.BulkInsert, "Waiting ... Max Threat Count for BulkCopys has been reached. " + DateTime.Now.ToString());
                }
                showWaitMessage = false;
                Thread.Sleep(180); //TODO: Timeout?
                UpdateStatus();
            }

            if (!showWaitMessage)
            {
                _events.Fire(IsagEvents.IsagEventType.BulkInsert, "Waiting for free Bulkcopy Thread finished. " + DateTime.Now.ToString());
            }

            if (!HasError())
            {
                _bulkCopyThreads.Add(thread);
                _createdBulkCopyThreads++;

                _status.AddStatus(_createdBulkCopyThreads, dt.Rows.Count, Status.StatusType.bulkCopyThreadCreated, IsagEvents.IsagEventType.Status);
                //Logging.Log(IsagEvents.IsagEventType.BulkInsert, string.Format("BulkCopy Thread {0} created [Datatable {1}: {2} rows]",
                //    _createdBulkCopyThreads.ToString(), _createdBulkCopyThreads.ToString(), dt.Rows.Count.ToString()));

                thread.Start();
                Logging.Log(IsagEvents.IsagEventType.BulkInsert, string.Format("BulkCopyThread Status: {0} finished, {1} created",
                                                                               _finishedBulkCopyThreads.ToString(), _createdBulkCopyThreads.ToString()));
            }
        }