Esempio n. 1
0
        public void Start(TextWriter inputWriter)
        {
            var settingsFileInfo = new FileInfo(Path.Combine(App.StoragePath, "lastScan.txt"));
            var query            = $"SELECT * FROM {TableOrViewName}";
            var stringBuilder    = new SqlConnectionStringBuilder()
            {
                DataSource     = ServerInstance,
                InitialCatalog = InitialCatalog
            };

            if (IntegratedSecurity)
            {
                stringBuilder.IntegratedSecurity = true;
            }
            else
            {
                stringBuilder.UserID   = DatabaseUsername;
                stringBuilder.Password = DatabasePassword;
            }

            if (!TimePeriodHelper.IsStringValid(TimePeriod))
            {
                Log.Warning("Defined TimePeriod {TimePeriod} is not valid. Use default {DefaultValue}.", TimePeriod, DefaultTimePeriod);
                TimePeriod = DefaultTimePeriod;
            }

            var executor = new Executor(Log, inputWriter, settingsFileInfo, stringBuilder.ToString(), query, AdditionalFilterClause, ColumnNameTimeStamp, ColumnNameMessage, ColumnNamesInclude, ApplicationName, LogEventLevel);

            _executorTask = new ExecutorTask(Log, TimeSpan.FromSeconds(QueryEverySeconds), TimePeriod, executor);
        }
Esempio n. 2
0
        public void Start(TextWriter inputWriter)
        {
            var settingsFileInfo = new FileInfo(Path.Combine(App.StoragePath, "lastScan.txt"));
            var query            = $"SELECT * FROM {TableOrViewName}";
            var stringBuilder    = new SqlConnectionStringBuilder
            {
                DataSource      = SqlConfig.ServerInstance,
                InitialCatalog  = SqlConfig.InitialCatalog,
                ConnectTimeout  = SqlConfig.ConnectTimeout,
                CommandTimeout  = SqlConfig.CommandTimeout,
                ApplicationName = SqlConfig.ApplicationName
            };

            if (SqlConfig.Encrypt)
            {
                stringBuilder.Encrypt = SqlConfig.Encrypt;
                stringBuilder.TrustServerCertificate = SqlConfig.TrustCertificate;
            }

            if (SqlConfig.IntegratedSecurity)
            {
                stringBuilder.IntegratedSecurity = true;
            }
            else
            {
                stringBuilder.UserID   = DatabaseUsername;
                stringBuilder.Password = DatabasePassword;
            }

            if (!TimePeriodHelper.IsStringValid(TimePeriod))
            {
                Log.Warning("Defined TimePeriod {TimePeriod} is not valid. Use default {DefaultValue}.", TimePeriod,
                            DefaultTimePeriod);
                TimePeriod = DefaultTimePeriod;
            }

            var executor = new Executor(Log, inputWriter, settingsFileInfo, stringBuilder.ToString(), query);

            _executorTask = new ExecutorTask(Log, TimeSpan.FromSeconds(QueryEverySeconds), TimePeriod, executor);
        }
 public void IsStringValid_Test(string timePeriod, bool expectedResult)
 {
     Assert.True(TimePeriodHelper.IsStringValid(timePeriod) == expectedResult);
 }