Example #1
0
        public BigSqlRunner(BigSqlRunnerConfig config)
        {
            if (null == config)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Config  = config;
            LogPool = new LogPool(config.MaxLogItemCount, config.CompactLog);
        }
Example #2
0
        public static void ToFile(BigSqlRunnerConfig config, string configFilePath)
        {
            var configJson = ToJson(config);

            var parentDir = Path.GetDirectoryName(configFilePath);

            if (false == Directory.Exists(parentDir))
            {
                Directory.CreateDirectory(parentDir);
            }

            File.WriteAllText(configFilePath, configJson);
        }
Example #3
0
        public bool LoadConfig(string configFilePath)
        {
            if (string.IsNullOrWhiteSpace(configFilePath))
            {
                throw new ArgumentException($"{nameof(configFilePath)} cannot be null or whitespace", nameof(configFilePath));
            }
            else if (false == NetPatch.FileExists(configFilePath))
            {
                return(false);
            }

            Config = BigSqlRunnerConfig.FromFile(configFilePath);
            return(true);
        }
Example #4
0
        public static BigSqlRunner FromConfig(string configFilePath)
        {
            if (string.IsNullOrWhiteSpace(configFilePath))
            {
                throw new ArgumentException($"{nameof(configFilePath)} cannot be null or whitespace", nameof(configFilePath));
            }
            else if (false == NetPatch.FileExists(configFilePath))
            {
                return(null);
            }

            var config       = BigSqlRunnerConfig.FromFile(configFilePath);
            var bigSqlRunner = new BigSqlRunner(config);

            return(bigSqlRunner);
        }
Example #5
0
 public static string ToJson(BigSqlRunnerConfig config) => JsonConvert.SerializeObject(config, Formatting.Indented);