public void Start() { //Recreate database ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;")); DropDatabaseTask.Delete("DemoDB"); CreateDatabaseTask.Create("DemoDB"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB;")); //Logging (only works with existing configuration nlog config in App.config) CreateLogTablesTask.CreateLog(); StartLoadProcessTask.Start("Process 1"); ControlFlow.STAGE = "Staging"; SqlTask.ExecuteNonQuery("some sql", "Select 1 as test"); TransferCompletedForLoadProcessTask.Complete(); ControlFlow.STAGE = "DataVault"; Sequence.Execute("some custom code", () => { }); LogTask.Warn("Some warning!"); EndLoadProcessTask.End("Everything successful"); string jsonLP = GetLoadProcessAsJSONTask.GetJSON(); string jsonLog = GetLogAsJSONTask.GetJSON(1); }
public void TestCreateWithAllParameters() { string dbName = TestContext.Properties["dbName"].ToString(); var sqlTask = new SqlTask("Get assert data", $"select cast(db_id('{dbName}') as int)"); DropDatabaseTask.Delete(dbName); Assert.IsFalse(sqlTask.ExecuteScalarAsBool()); CreateDatabaseTask.Create(dbName, RecoveryModel.Simple, "Latin1_General_CS_AS"); Assert.IsTrue(sqlTask.ExecuteScalarAsBool()); }
public void TestDropDB() { string dbName = TestContext.Properties["dbName"].ToString(); var sqlTask = new SqlTask("Get assert data", $"select cast(db_id('{dbName}') as int)"); CreateDatabaseTask.Create(dbName); Assert.IsTrue(sqlTask.ExecuteScalarAsBool()); DropDatabaseTask.Delete(dbName); Assert.IsFalse(sqlTask.ExecuteScalarAsBool()); }
public void Preparation() { ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;")); DropDatabaseTask.Delete("DemoDB"); CreateDatabaseTask.Create("DemoDB"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB")); CreateSchemaTask.Create("demo"); OrderDataTableDef.CreateTable(); CustomerTableDef.CreateTable(); CustomerRatingTableDef.CreateTable(); SqlTask.ExecuteNonQuery("Fill customer table", "INSERT INTO demo.Customer values('Sandra Kettler')"); SqlTask.ExecuteNonQuery("Fill customer table", "INSERT INTO demo.Customer values('Nick Thiemann')"); SqlTask.ExecuteNonQuery("Fill customer table", "INSERT INTO demo.Customer values('Zoe Rehbein')"); SqlTask.ExecuteNonQuery("Fill customer table", "INSERT INTO demo.Customer values('Margit Gries')"); }
public void Start() { //Basics ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;")); DropDatabaseTask.Delete("DemoDB"); CreateDatabaseTask.Create("DemoDB"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB;")); CreateSchemaTask.Create("demo"); CreateTableTask.Create("demo.table1", new List <TableColumn>() { new TableColumn(name: "key", dataType: "int", allowNulls: false, isPrimaryKey: true, isIdentity: true), new TableColumn(name: "value", dataType: "nvarchar(100)", allowNulls: true) }); SqlTask.ExecuteNonQuery("Insert data", $@"insert into demo.table1 (value) select * from (values ('Ein Text'), ('Noch mehr Text')) as data(v)"); int count = RowCountTask.Count("demo.table1").Value; Debug.WriteLine($"Found {count} entries in demo table!"); //Truncate: //TruncateTableTask.Truncate("demo.table1"); //Batch processing / Go keyword: //SqlTask.ExecuteNonQuery("sql with go keyword", @"insert into demo.table1 (value) select '####'; //go 2"); ControlFlow.CurrentDbConnection = new SMOConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB;")); SqlTask.ExecuteNonQuery("sql with go keyword", @"insert into demo.table1 (value) select '####'; go 2"); AddFileGroupTask.AddFileGroup("FGName", "DemoDB", "200MB", "10MB", isDefaultFileGroup: true); CRUDProcedureTask.CreateOrAlter("demo.proc1", "select 1 as test"); }