public DatabaseContext() : base(new SQLiteConnection { ConnectionString = new SQLiteConnectionStringBuilder { DataSource = Path.Combine(Config.Server.AuditFilePath, "auditDB.db"), ForeignKeys = true }.ConnectionString }, true) { var userPrinciple = Common.Utilities.ServerUser; Common.Utilities.PerformActionInsideImpersonatedContext(userPrinciple, () => { this.Configuration.AutoDetectChangesEnabled = false; this.Configuration.ValidateOnSaveEnabled = false; var directoryWrapper = new DirectoryWrapper(); directoryWrapper.CreateIfNotExists(Config.Server.AuditFilePath); DbConfiguration.SetConfiguration(new SQLiteConfiguration()); this.Database.CreateIfNotExists(); this.Database.Initialize(false); this.Database.ExecuteSqlCommand("CREATE TABLE IF NOT EXISTS \"AuditLog\" ( `Id` INTEGER PRIMARY KEY AUTOINCREMENT, `WorkflowID` TEXT, `WorkflowName` TEXT, `ExecutionID` TEXT, `VersionNumber` TEXT, `AuditType` TEXT, `PreviousActivity` TEXT, `PreviousActivityType` TEXT, `PreviousActivityID` TEXT, `NextActivity` TEXT, `NextActivityType` TEXT, `NextActivityID` TEXT, `ServerID` TEXT, `ParentID` TEXT, `ClientID` TEXT, `ExecutingUser` TEXT, `ExecutionOrigin` INTEGER, `ExecutionOriginDescription` TEXT, `ExecutionToken` TEXT, `AdditionalDetail` TEXT, `IsSubExecution` INTEGER, `IsRemoteWorkflow` INTEGER, `Environment` TEXT, `AuditDate` TEXT )"); this.Configuration.AutoDetectChangesEnabled = false; this.Configuration.ValidateOnSaveEnabled = false; }); }
public TestCatalog() { _directoryWrapper = new DirectoryWrapper(); _fileWrapper = new FileWrapper(); _directoryWrapper.CreateIfNotExists(EnvironmentVariables.TestPath); Tests = new ConcurrentDictionary <Guid, List <IServiceTestModelTO> >(); _serializer = new Dev2JsonSerializer(); }
public TestCoverageCatalog(IResourceCatalog resourceCatalog) { _directoryWrapper = new DirectoryWrapper(); _fileWrapper = new FileWrapper(); _directoryWrapper.CreateIfNotExists(EnvironmentVariables.TestCoveragePath); _serializer = new Dev2JsonSerializer(); _serviceAllTestsCoverageModelToFactory = CustomContainer.Get <IServiceTestCoverageModelToFactory>() ?? new ServiceTestCoverageModelToFactory(resourceCatalog); }
public static string GetServerLogSettingsConfigFile() { var localAppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); var serverLogFolder = Path.Combine(localAppDataFolder, "Warewolf", "Server Log"); IDirectory directory = new DirectoryWrapper(); directory.CreateIfNotExists(serverLogFolder); var serverLogFile = Path.Combine(serverLogFolder, "warewolf-Server.log"); return(serverLogFile); }
private void SaveCoverageReport(Guid resourceId, IServiceTestCoverageModelTo serviceTestCoverageModelTo) { var dirPath = GetTestCoveragePathForResourceId(resourceId); _directoryWrapper.CreateIfNotExists(dirPath); if (!string.Equals(serviceTestCoverageModelTo.OldReportName, serviceTestCoverageModelTo.ReportName, StringComparison.InvariantCultureIgnoreCase)) { var oldFilePath = Path.Combine(dirPath, $"{serviceTestCoverageModelTo.OldReportName}.coverage"); _fileWrapper.Delete(oldFilePath); } var filePath = Path.Combine(dirPath, $"{serviceTestCoverageModelTo.ReportName}.coverage"); var sw = new StreamWriter(filePath, false); _serializer.Serialize(sw, serviceTestCoverageModelTo); }
void SaveTestToDisk(Guid resourceId, IServiceTestModelTO serviceTestModelTo) { var dirPath = GetTestPathForResourceId(resourceId); _directoryWrapper.CreateIfNotExists(dirPath); if (!string.Equals(serviceTestModelTo.OldTestName, serviceTestModelTo.TestName, StringComparison.InvariantCultureIgnoreCase)) { var oldFilePath = Path.Combine(dirPath, $"{serviceTestModelTo.OldTestName}.test"); _fileWrapper.Delete(oldFilePath); } var filePath = Path.Combine(dirPath, $"{serviceTestModelTo.TestName}.test"); serviceTestModelTo.Password = DpapiWrapper.EncryptIfDecrypted(serviceTestModelTo.Password); var sw = new StreamWriter(filePath, false); _serializer.Serialize(sw, serviceTestModelTo); }
static void CreateIfNotExists(string path) { var directoryWrapper = new DirectoryWrapper(); directoryWrapper.CreateIfNotExists(path); }