static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(o => { var sqls = new Dictionary <string, string>(); var sqlPath = GernerateSqlFilePath(o, o.File); var fileSql = System.IO.File.ReadAllText(sqlPath); sqls.Add(o.File, fileSql); var sqlServer = new SqlServerInstance(o.ConnectionString); foreach (var sql in sqls) { var ds = sqlServer.ExecuteQuery(sql.Value); using (var workbook = new XLWorkbook()) { foreach (DataTable table in ds.Tables) { var workshet = workbook.Worksheets.Add(table); for (var iCol = 1; iCol <= table.Columns.Count; iCol++) { workshet.Column(iCol).AdjustToContents(); } } var outputFileName = GenerateFileName(o, sql.Key, DateTime.Now); workbook.SaveAs(outputFileName); } } }); // Console.Read(); }
public void When_VerifyDatabaseServer_With_inValid_sqlserver_and_no_username_and_no_password_Should_Return_database_server_not_found() { // Arrange var sqlServerName = "does_not_exists"; var userName = string.Empty; var password = string.Empty; // Act Func <Task> action = async() => await SqlServerInstance.VerifyDatabaseServer(sqlServerName, userName, password); // Assert action.Should().ThrowAsync <ConnectionFailureException>().WithMessage("Failed to connect to server does_not_exists."); }
public void When_TryFindDatabase_With_valid_database_and_no_username_or_password_Should_return_Ok() { // Arrange var serverName = "konfidence2"; var database = "TestClassGenerator"; var userName = string.Empty; var password = string.Empty; // Act Action action = () => SqlServerInstance.TryFindDatabase(serverName, database, userName, password); // Assert action.Should().Throw <SqlClientException>().WithMessage("no password or username provided"); }
public static Dictionary<string, int> GetDefaults(SqlServerInstance i) { var dict = new Dictionary<string, int> { {"access check cache bucket count", 0}, {"access check cache quota", 0}, {"Ad Hoc Distributed Queries", 0}, {"affinity I/O mask", 0}, {"affinity mask", 0}, {"affinity64 I/O mask", 0}, {"affinity64 mask", 0}, {"Agent XPs", 0}, {"allow updates", 0}, {"awe enabled", 0}, {"blocked process threshold", 0}, {"c2 audit mode", 0}, {"clr enabled", 0}, {"contained database authentication", 0}, {"cost threshold for parallelism", 5}, {"cross db ownership chaining", 0}, {"cursor threshold", -1}, {"Database Mail XPs", 0}, {"default full-text language", 1033}, {"default language", 0}, {"default trace enabled", 1}, {"disallow results from triggers", 0}, {"fill factor (%)", 0}, {"ft crawl bandwidth (max)", 100}, {"ft crawl bandwidth (min)", 0}, {"ft notify bandwidth (max)", 100}, {"ft notify bandwidth (min)", 0}, {"index create memory (KB)", 0}, {"in-doubt xact resolution", 0}, {"lightweight pooling", 0}, {"locks", 0}, {"max degree of parallelism", 0}, {"max full-text crawl range", 4}, {"max server memory (MB)", 2147483647}, {"max text repl size (B)", 65536}, {"max worker threads", 0}, {"media retention", 0}, {"min memory per query (KB)", 1024}, {"min server memory (MB)", 0}, {"nested triggers", 1}, {"network packet size (B)", 4096}, {"Ole Automation Procedures", 0}, {"open objects", 0}, {"optimize for ad hoc workloads", 0}, {"PH timeout (s)", 60}, {"precompute rank", 0}, {"priority boost", 0}, {"query governor cost limit", 0}, {"query wait (s)", -1}, {"recovery interval (min)", 0}, {"remote access", 1}, {"remote admin connections", 0}, {"remote login timeout (s)", 10}, {"remote proc trans", 0}, {"remote query timeout (s)", 600}, {"Replication XPs", 0}, {"RPC parameter data validation", 0}, {"scan for startup procs", 0}, {"server trigger recursion", 1}, {"set working set size", 0}, {"show advanced options", 0}, {"SMO and DMO XPs", 1}, {"SQL Mail XPs", 0}, {"transform noise words", 0}, {"two digit year cutoff", 2049}, {"user connections", 0}, {"user options", 0}, {"Web Assistant Procedures", 0}, {"xp_cmdshell", 0} }; // some defaults were different before 2012 if (i.Version < SqlServerVersions.SQL2012.RTM) { dict["remote login timeout (s)"] = 20; } return dict; }