public int Execute(ConnectionSetting connection, int jobId, IDbConnection dbConnection)
        {
            const string query = "UPDATE ReportJobQueue SET ProcessEndDate = @ProcessEndDate, Status = @Status WHERE Id = @Id";

            _concurrencyCoordinator.UnlockReportJob(connection.Name, jobId);
            return(dbConnection.Execute(query, new { Id = jobId, ProcessEndDate = DateTime.UtcNow, Status = JobStatus.Complete }));
        }
Exemple #2
0
        public int Execute(ConnectionSetting connection, int jobId, Exception ex, IDbConnection dbConnection)
        {
            const string query = "UPDATE ReportJobQueue SET Status = @Status, ErrorMessage = @ErrorMessage, ErrorStackTrace = @ErrorStackTrace WHERE Id = @Id";

            _concurrencyCoordinator.UnlockReportJob(connection.Name, jobId);
            return(dbConnection.Execute(query, new { Id = jobId, Status = JobStatus.Error, ErrorMessage = ex.Message, ErrorStackTrace = ex.ToString() }));
        }
        public void UnlockReportJob_OnCall_CreatesTextFile()
        {
            // setup
            string connectionName   = Path.GetRandomFileName();
            int    jobId            = new Random().Next(1, 100);
            string processingFolder = Path.Combine(_testRootFolder, connectionName);

            _reportLocationProvider.GetProcessingFolder(connectionName).Returns(processingFolder);
            string lockFilePath = Path.Combine(processingFolder, jobId.ToString());

            Directory.CreateDirectory(processingFolder);
            File.WriteAllText(lockFilePath, String.Empty);

            // execute
            _concurrencyCoordinator.UnlockReportJob(connectionName, jobId);

            Assert.IsFalse(File.Exists(lockFilePath));

            // clean up
            Directory.Delete(processingFolder, true);
        }