public static DataLoader CreateDataLoader(string ConnectionStringName, DataFileInfo flFileInfo, int ThreadCount, ThreadPriority threadPriority, int CommitAfter)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName];

            switch (settings.ProviderName.ToUpper())
            {
            case "ORACLE":
                return(OracleDataLoader.CreateDataLoader(settings.ConnectionString, flFileInfo, ThreadCount, threadPriority, CommitAfter));

            case "SQLSERVER":
                return(SqlServerDataLoader.CreateDataLoader(settings.ConnectionString, flFileInfo, ThreadCount, threadPriority));
            }
            return(null);
        }
Пример #2
0
 private OracleDataLoader(string ConnectionString, DataFileInfo FileInfo, int ThreadsCount, ThreadPriority Priority, int CommitAfter)
 {
     this.lstSkippedLines  = new List <ErrorInfo>();
     this.strErrorFilePath = "";
     this.lstThreadInfo    = new List <ThreadInfo>();
     if (TestConnection(ConnectionString))
     {
         if (!File.Exists(FileInfo.FilePath))
         {
             this.strErrorMsg = "Input file does not exist.";
             this.intExitCode = 1;
         }
         else
         {
             this.strConnString    = ConnectionString;
             this.conn             = new OracleConnection(ConnectionString);
             this.flInfo           = FileInfo;
             this.strErrorFilePath = FileInfo.FilePath.Substring(0, FileInfo.FilePath.LastIndexOf(@"\")) + @"\Error_" + DateTime.Now.ToString("ddMMyyHHmmss") + "_" + new FileInfo(FileInfo.FilePath).Name;
             this.intThreadsCount  = ThreadsCount;
             this.intRecordsSaved  = new int[ThreadsCount];
             this.intCommitAfter   = CommitAfter;
             if (FileInfo.IsLengthDelimitedFile)
             {
                 this.strCommandText = PrepareInsertQuery(this.flInfo.StagingTableName, ConnectionString, this.flInfo.LengthDelimitedColMappingList, out this.intTotalCols, out this.strErrorMsg);
             }
             else if (FileInfo.ConsiderAllColumns)
             {
                 this.strCommandText = PrepareInsertQuery(this.flInfo.StagingTableName, ConnectionString, out this.intTotalCols, out this.strErrorMsg);
             }
             else
             {
                 this.strCommandText = PrepareInsertQuery(this.flInfo.StagingTableName, ConnectionString, this.flInfo.MappingList, out this.intTotalCols, out this.strErrorMsg);
             }
             if (this.strErrorMsg != "")
             {
                 this.intExitCode = 1;
             }
             else
             {
                 this.intExitCode = 0;
                 this.strErrorMsg = "";
                 this.strNulls    = new string[this.intTotalCols];
                 for (int i = 0; i < this.intTotalCols; i++)
                 {
                     this.strNulls[i] = "NULL";
                 }
                 this.threads = new Thread[this.intThreadsCount];
                 this.sr      = new StreamReader(this.flInfo.FilePath);
                 Thread.CurrentThread.Priority = Priority;
                 this.tPriority = Priority;
                 if (this.flInfo.LoadType == LoadTypes.Truncate)
                 {
                     TruncateData(this.flInfo.StagingTableName, ConnectionString);
                 }
             }
         }
     }
     else
     {
         this.strErrorMsg = "Connection Failed.";
         this.intExitCode = 1;
     }
 }
Пример #3
0
 public static DataLoader CreateDataLoader(string ConnectionString, DataFileInfo FileInfo, int ThreadsCount, ThreadPriority Priority, int CommitAfter) =>
 new OracleDataLoader(ConnectionString, FileInfo, ThreadsCount, Priority, CommitAfter);
Пример #4
0
 public static DataLoader CreateDataLoader(string ConnectionString, DataFileInfo FileInfo, int ThreadsCount, ThreadPriority Priority) =>
 new SqlServerDataLoader(ConnectionString, FileInfo, ThreadsCount, Priority);
        public static DataLoader CreateDataLoader(DbTypes DatabaseType, string ConnectionString, DataFileInfo flFileInfo, int ThreadCount, ThreadPriority threadPriority, int CommitAfter)
        {
            switch (DatabaseType)
            {
            case DbTypes.Oracle:
                return(OracleDataLoader.CreateDataLoader(ConnectionString, flFileInfo, ThreadCount, threadPriority, CommitAfter));

            case DbTypes.SqlServer:
                return(SqlServerDataLoader.CreateDataLoader(ConnectionString, flFileInfo, ThreadCount, threadPriority));
            }
            return(null);
        }