public void ExecuteResetProcessedLogFileJob(int logFileId) { using (IDbContext dbContext = _dbContextFactory.GetDbContext()) { ISetLogFileUnprocessedCommand cmd = new SetLogFileUnprocessedCommand(dbContext , new JobRegistrationService() ); dbContext.BeginTransaction(); cmd.Execute(logFileId); dbContext.Commit(); } }
public void Execute_IntegrationTest_SQLite() { string filePath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".dbtest"); List <W3CEvent> logEvents1 = null; List <W3CEvent> logEvents2 = new List <W3CEvent>(); using (StreamReader logStream = new StreamReader(TestAsset.ReadTextStream(TestAsset.LogFile))) { logEvents1 = W3CEnumerable.FromStream(logStream).ToList(); logEvents2.AddRange(logEvents1.GetRange(0, 10)); } using (SQLiteDbContext dbContext = new SQLiteDbContext(filePath)) { dbContext.Initialise(); ISetLogFileUnprocessedCommand setLogFileUnprocessedCommand = new SetLogFileUnprocessedCommand(dbContext, _jobRegistrationService); // create the project first so we have one ProjectModel project = DataHelper.CreateProjectModel(); DataHelper.InsertProjectModel(dbContext, project); // create the log files LogFileModel logFile1 = DataHelper.CreateLogFileModel(project.Id); logFile1.Status = LogFileStatus.Complete; DataHelper.InsertLogFileModel(dbContext, logFile1); LogFileModel logFile2 = DataHelper.CreateLogFileModel(project.Id); logFile2.Status = LogFileStatus.Complete; DataHelper.InsertLogFileModel(dbContext, logFile2); // check that the log file is processed int processedCount = dbContext.ExecuteScalar <int>("SELECT COUNT(*) FROM LogFiles WHERE ProjectId = @ProjectId AND Status = @Status", new { ProjectId = project.Id, Status = LogFileStatus.Complete }); Assert.AreEqual(2, processedCount); // execute for a single log file setLogFileUnprocessedCommand.Execute(logFile1.Id); processedCount = dbContext.ExecuteScalar <int>("SELECT COUNT(*) FROM LogFiles WHERE ProjectId = @ProjectId AND Status = @Status", new { ProjectId = project.Id, Status = LogFileStatus.Processing }); Assert.AreEqual(1, processedCount); } }