Esempio n. 1
0
        public BigSqlRunnerConfig(
            string connectionString, string bigSqlFilePath,
            bool enableLogging = false, string logFilePath   = null, bool compactLog = true, int maxLogItemCount = 10000,
            int batchSize      = 1, string sqlUnitEndingLine = "GO",
            bool continueFromLastSessionWhenStarted = true, SessionSaveTypeEnum sessionSaveType = SessionSaveTypeEnum.SqlUnitIndex,
            int retryIntervalWhenError_Seconds      = 3, int retryNumberWhenError = 9
            )
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentException($"{nameof(connectionString)} cannot be null or whitespace", nameof(connectionString));
            }
            if (string.IsNullOrWhiteSpace(bigSqlFilePath))
            {
                throw new ArgumentException($"{nameof(bigSqlFilePath)} cannot be null or whitespace", nameof(bigSqlFilePath));
            }
            if (enableLogging && string.IsNullOrWhiteSpace(logFilePath))
            {
                throw new ArgumentException($"{nameof(logFilePath)} cannot be null or whitespace", nameof(logFilePath));
            }
            if (batchSize <= 0)
            {
                throw new ArgumentException($"{nameof(batchSize)} must be >= 1", nameof(batchSize));
            }
            if (string.IsNullOrWhiteSpace(sqlUnitEndingLine))
            {
                throw new ArgumentException($"{nameof(sqlUnitEndingLine)} cannot be null or whitespace", nameof(sqlUnitEndingLine));
            }
            if (retryIntervalWhenError_Seconds < 0)
            {
                throw new ArgumentException($"{nameof(retryIntervalWhenError_Seconds)} must be >= 0", nameof(retryIntervalWhenError_Seconds));
            }
            if (retryNumberWhenError < 0)
            {
                throw new ArgumentException($"{nameof(retryNumberWhenError)} must be >= 0", nameof(retryNumberWhenError));
            }

            ConnectionString = connectionString;
            BigSqlFilePath   = bigSqlFilePath;

            EnableLogging   = enableLogging;
            LogFilePath     = logFilePath;
            CompactLog      = compactLog;
            MaxLogItemCount = maxLogItemCount;

            BatchSize         = batchSize;
            SqlUnitEndingLine = sqlUnitEndingLine;

            ContinueFromLastSessionWhenStarted = continueFromLastSessionWhenStarted;
            SessionSaveType = sessionSaveType;

            RetryIntervalWhenError = TimeSpan.FromSeconds(retryIntervalWhenError_Seconds);
            RetryNumberWhenError   = retryNumberWhenError;
        }
Esempio n. 2
0
        public SessionLevelDb(string sessionDbPath, SessionSaveTypeEnum sessionSaveType)
        {
            SessionDb       = new JsonLevelDb <string, string>(sessionDbPath);
            SessionSaveType = sessionSaveType;

            var currentSaveType = SessionDb[nameof(SessionSaveType)];

            if (null == currentSaveType)
            {
                SessionDb[nameof(SessionSaveType)] = SessionSaveType.ToString();
            }
            else if (currentSaveType != SessionSaveType.ToString())
            {
                throw new ArgumentException($"value({sessionSaveType}) of specified {nameof(sessionSaveType)} mismatches with the one in session db: {sessionDbPath}", nameof(sessionSaveType));
            }
        }
Esempio n. 3
0
 public BigSqlRunner(
     string connectionString, string bigSqlFilePath,
     bool enableLogging = false, string logFilePath   = null,
     int batchSize      = 1, string sqlUnitEndingLine = "GO",
     bool continueFromLastSessionWhenStarted = true, SessionSaveTypeEnum sessionSaveType = SessionSaveTypeEnum.SqlUnitIndex,
     int retryIntervalWhenError_Seconds      = 3, int retryNumberWhenError = 9
     ) : this(
         new BigSqlRunnerConfig(
             connectionString, bigSqlFilePath,
             enableLogging, logFilePath,
             batchSize, sqlUnitEndingLine,
             continueFromLastSessionWhenStarted, sessionSaveType,
             retryIntervalWhenError_Seconds, retryNumberWhenError
             )
         )
 {
 }