public static void wipeBaselines() { Context.DataContext dbContext = new Context.DataContext(EstablishValidConnection()); dbContext.ExecuteCommand("DELETE FROM BaselineSecurityMappings"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[BaselineSecurityMappings]', RESEED, 0)"); }
private static void RunScript(string fileName) { Context.DataContext dbContext = new Context.DataContext(EstablishValidConnection()); string initScript = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); string[] script = File.ReadAllLines(initScript); foreach (string command in script) { try { dbContext.ExecuteCommand(command); } catch (Exception ex) { string s = ex.Message; } } }
/// <summary> /// clear capablities data /// </summary> public static void wipeCape() { Context.DataContext dbContext = new Context.DataContext(EstablishValidConnection()); dbContext.ExecuteCommand("DELETE FROM MapTypesCapabilitiesControls"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[MapTypesCapabilitiesControls]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM TICMappings"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[TICMappings]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM Capabilities"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[Capabilities]', RESEED, 0)"); }
/// <summary> /// wipe out all data from database /// </summary> public static void ClearData() { Context.DataContext dbContext = new Context.DataContext(EstablishValidConnection()); //delete data and reset ids dbContext.ExecuteCommand("TRUNCATE TABLE Relateds"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[Relateds]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM BaselineSecurityMappings"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[BaselineSecurityMappings]', RESEED, 0)"); dbContext.ExecuteCommand("TRUNCATE TABLE MapTypesCapabilitiesControls"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[MapTypesCapabilitiesControls]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM TICMappings"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[TICMappings]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM Specs"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[Specs]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM Controls"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[Controls]', RESEED, 0)"); dbContext.ExecuteCommand("DELETE FROM Capabilities"); dbContext.ExecuteCommand("DBCC CHECKIDENT ('[ModelDb].[dbo].[Capabilities]', RESEED, 0)"); }