Skip to content

Commit a5f27aa

Browse files
committed
Corrected context information processing in the background job.
1 parent df6c7c7 commit a5f27aa

File tree

8 files changed

+29
-8
lines changed

8 files changed

+29
-8
lines changed

src/Server/Coderr.Server.ReportAnalyzer/AnalysisDbContext.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,17 @@ public IDbConnection Connection
3535
{
3636
get
3737
{
38+
if (_unitOfWork is OurUnitOfWork ourUnitOfWork)
39+
{
40+
return ourUnitOfWork.Transaction.Connection;
41+
}
42+
if (_unitOfWork != null && _con == null)
43+
{
44+
throw new NotSupportedException("Got a unit of work but not a connection");
45+
}
46+
3847
if (_con != null)
3948
return _con;
40-
4149
_con = _connectionFactory();
4250
return _con;
4351
}

src/Server/Coderr.Server.ReportAnalyzer/OurUnitOfWork.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public void Dispose()
3636

3737
public void SaveChanges()
3838
{
39+
if (Transaction == null)
40+
return;
41+
3942
Transaction.Commit();
4043
Transaction.Dispose();
4144
Transaction = null;

src/Server/Coderr.Server.SqlServer/Analysis/Jobs/InsertCollectionsJob.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ public async Task ExecuteAsync()
4343
break;
4444

4545
await DeleteImportedRows(collections);
46+
await _importer.Execute();
4647
_importer.Clear();
4748
}
4849

49-
// _dbContext.SaveChanges();
50+
_dbContext.SaveChanges();
5051
}
5152

5253

src/Server/Coderr.Server.SqlServer/Analysis/Jobs/RemoveOldCollectionDataJob.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public async Task ExecuteAsync()
7070
}
7171
}
7272
}
73+
74+
_analysisDbContext.SaveChanges();
7375
}
7476
}
7577
}

src/Server/Coderr.Server.Web.Tests/applicationhost.config

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+

2+
3+
4+
5+
6+
7+
<?xml version="1.0" encoding="UTF-8"?>
28
<!--
39

410
IIS configuration sections.
@@ -162,10 +168,10 @@
162168
</site>
163169
<site name="codeRR.Server.Web" id="2">
164170
<application path="/" applicationPool="Clr4IntegratedAppPool">
165-
<virtualDirectory path="/" physicalPath="C:\src\1tcompany\codeRR.oss\codeRR.Server\src\Server\Coderr.Server.Web" />
171+
<virtualDirectory path="/" physicalPath="D:\src\1TCompany\codeRR\OSS\codeRR.Server\src\Server\Coderr.Server.Web" />
166172
</application>
167173
<application path="/coderr" applicationPool="Clr4IntegratedAppPool">
168-
<virtualDirectory path="/" physicalPath="C:\src\1tcompany\codeRR.oss\codeRR.Server\src\Server\Coderr.Server.Web" />
174+
<virtualDirectory path="/" physicalPath="D:\src\1TCompany\codeRR\OSS\codeRR.Server\src\Server\Coderr.Server.Web" />
169175
</application>
170176
<bindings>
171177
<binding protocol="http" bindingInformation="*:50473:localhost" />

src/Server/Coderr.Server.Web/App_Start/CompositionRoot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private IScopedTaskInvoker CreateTaskInvoker(IServiceLocator arg)
7373
private IAdoNetUnitOfWork CreateUnitOfWork(IServiceLocator arg)
7474
{
7575
var con = DbConnectionFactory.Open(true);
76-
return new AdoNetUnitOfWork(con, true, IsolationLevel.RepeatableRead);
76+
return new OurUnitOfWork(con, true);
7777
}
7878

7979
private IDbConnection CreateConnection(IServiceLocator arg)

src/Server/Coderr.Server.Web/App_Start/Services/ServiceRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void BuildServices()
133133
_backgroundJobManager = new BackgroundJobManager(CompositionRoot.Container);
134134
_backgroundJobManager.JobFailed += OnJobFailed;
135135
_backgroundJobManager.StartInterval = TimeSpan.FromSeconds(Debugger.IsAttached ? 0 : 10);
136-
_backgroundJobManager.ExecuteInterval = TimeSpan.FromMinutes(3);
136+
_backgroundJobManager.ExecuteInterval = TimeSpan.FromSeconds(30);
137137

138138
_backgroundJobManager.ScopeClosing += OnBackgroundJobScopeClosing;
139139
}

src/Server/Coderr.Server.Web/Infrastructure/TransactionalAttribute.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Web;
55
using System.Web.Mvc;
6+
using codeRR.Server.ReportAnalyzer;
67
using Griffin.Data;
78

89
namespace codeRR.Server.Web.Infrastructure
@@ -13,7 +14,7 @@ public override void OnActionExecuted(ActionExecutedContext filterContext)
1314
{
1415
if (filterContext.Exception == null && filterContext.Controller.ViewData.ModelState.IsValid)
1516
{
16-
var uow = (AdoNetUnitOfWork) filterContext.HttpContext.GetService(typeof(IAdoNetUnitOfWork));
17+
var uow = (OurUnitOfWork) filterContext.HttpContext.GetService(typeof(IAdoNetUnitOfWork));
1718
uow.SaveChanges();
1819
}
1920

0 commit comments

Comments
 (0)