Example #1
0
        private static void UploadTableInSqlServer(ImportTable importTable)
        {
            ImportTable _importTable = (ImportTable)importTable;

            // ----- DEBUG
            Log.Log.Write("Start upload - table "
                          + _importTable.DestinationNameTable
                          + " (" + _importTable.DataTable.Rows.Count + ")");
            // ------

            using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(_importTable.ConnectionString))
            {
                foreach (DataColumn dataColumn in _importTable.DataTable.Columns)
                {
                    sqlBulkCopy.ColumnMappings.Add(dataColumn.ColumnName, dataColumn.ColumnName);
                }
                sqlBulkCopy.BulkCopyTimeout      = 100;
                sqlBulkCopy.DestinationTableName = _importTable.DestinationNameTable;

                sqlBulkCopy.WriteToServer(_importTable.DataTable);
            }

            // ----- DEBUG
            Log.Log.Write("End upload - table "
                          + _importTable.DestinationNameTable
                          + " (" + _importTable.DataTable.Rows.Count + ")");
            // ------
        }
Example #2
0
 public bool ScheduleBefore(ISchedulerOrdering s)
 {
     if (s is ImportTable)
     {
         ImportTable importTable = (ImportTable)s;
         return(this.Time < importTable.Time);
     }
     return(false);
 }
Example #3
0
        public void UploadTableInSqlServer(DataTable dataTable, string connectionString,
                                           string destinationNameTable = "",
                                           int timeout = 100)
        {
            if (destinationNameTable == "")
            {
                destinationNameTable = dataTable.TableName;
            }
            ImportTable importTable = new ImportTable(dataTable, connectionString, destinationNameTable, timeout);

            ImporterInSqlServer.UploadTableInSqlServer(importTable);
        }
Example #4
0
        public void UploadTableInSqlServerNewThread(DataTable dataTable, string connectionString,
                                                    string destinationNameTable = "",
                                                    int timeout  = 100,
                                                    bool shedule = false)
        {
            if (destinationNameTable == "")
            {
                destinationNameTable = dataTable.TableName;
            }
            ImportTable importTable = new ImportTable(dataTable, connectionString, destinationNameTable, timeout);

            if (shedule)
            {
                new Thread(this.ImportBySheduller).Start(importTable);
            }
            else
            {
                new Thread(this.ImportWithoutSheduller).Start(importTable);
            }
        }
Example #5
0
        private void ImportBySheduller(object importTable)
        {
            ImportTable _importTable = (ImportTable)importTable;

            try
            {
                _scheduler.Enter(_importTable);
                try
                {
                    ImporterInSqlServer.UploadTableInSqlServer(_importTable);
                }
                finally
                {
                    _scheduler.Done();
                }
            }
            catch (Exception e)
            {
                int i;
                //throw new AbandonedMutexException();
            }
        }
Example #6
0
        private void ImportWithoutSheduller(object importTable)
        {
            ImportTable _importTable = (ImportTable)importTable;

            ImporterInSqlServer.UploadTableInSqlServer(_importTable);
        }