public void DeleteArticle(string id) { Guid guid = Guid.Parse(id); _articlesRepository.DeleteArticle(guid); _unitOfWork.Commit(); }
private static void CreateAccount(int number, Instrument instrument) { using var uow = new NHUnitOfWork(); uow.OpenSession(_currentReadTenantIds); uow.BeginTransaction(); Console.WriteLine( $"Creating Account#: {number} under Instrument#: {instrument.Number} for Tenant ID: {_currentWriteTenantId}"); var account = new Account { AccountNumber = number, Instrument = instrument }; try { instrument.AddAccount(account); uow.Session.SaveOrUpdate(account); uow.Commit(); } catch (InvalidOperationException ex) { Console.WriteLine($"Unable to create Account: {ex.Message}"); uow.Rollback(); } }
private void initialized() { using (var uow = new NHUnitOfWork(PMSSession.GetSession())) { var periodRep = new PeriodRepository(uow); for (int i = 0; i < 5; i++) { var period = new Period(new PeriodId(periodRep.GetNextId()), "Test", DateTime.Now, DateTime.Now, 91); periodRep.Add(period); } uow.Commit(); } }
public void can_create_payroll_of_active_employees() { using (var uow = new NHUnitOfWork()) { var ees = _employees.FetchAllActive(); var actual = ees.Count; var pr = PayrollReport.Create(ees, Date.Now); EventBroker.getInstance().Command(new CommandIncludeSalaryDeductionInReport(pr)); Assert.True(ees.Count > 0); Assert.Equal(pr.Records.Count, actual); _payrolls.Save(pr); uow.Commit(); } }
private static void CreateReferenceDataItem(string value) { using var uow = new NHUnitOfWork(); uow.OpenSession(_currentReadTenantIds); uow.BeginTransaction(); Console.WriteLine($"Creating ReferenceDataItem with Value: {value} using Tenant ID: {_currentWriteTenantId}"); var referenceDataItem = new ReferenceDataItem { Value = value }; uow.Session.SaveOrUpdate(referenceDataItem); uow.Commit(); }
public void TestDatapiontRepositorySavaMethod() { NHUnitOfWork nhUnitOfWork = new NHUnitOfWork(); DataPointRepository dataPointRepository = new DataPointRepository(nhUnitOfWork); DataPoint dataPointPre = dataPointRepository.FindBy(1); dataPointPre.Description = "MyID is" + Convert.ToString((dataPointPre.Id)); dataPointRepository.Save(dataPointPre); DataPoint dataPointAfter = dataPointRepository.FindBy(1); nhUnitOfWork.Commit(); Assert.AreEqual(dataPointPre.Description, dataPointAfter.Description); }
public TestFixture() { ISalaryRepository salary_repository = new SalaryRepository(); IEmployeeRepository employees_repository = new EmployeeRepository(); using (var uow = new NHUnitOfWork()) { var e = Employee.Create(Person.Create("juan", "santos", "puruntong", "", Gender.MALE, Date.Now), Date.Now); var s = Salary.Create(e, MonetaryValue.of("php", 10000)); var d = Deduction.Create(s, 3, MonetaryValue.of("php", 5000)); var da = Deduction.CreateAmortized(s, 12, MonetaryValue.of("php", 200), mode: DeductionMode.CONTINIOUS); var db = Deduction.CreateAmortized(s, 12, MonetaryValue.of("php", 300), mode: DeductionMode.CONTINIOUS); var dc = Deduction.CreateAmortized(s, 12, MonetaryValue.of("php", 400), mode: DeductionMode.CONTINIOUS); var e2 = Employee.Create(Person.Create("juan", "cruz", "dela cruz", "", Gender.MALE, Date.Now), Date.Now); var s2 = Salary.Create(e2, MonetaryValue.of("php", 15000)); var d2 = Deduction.Create(s2, 3, MonetaryValue.of("php", 3000)); var d2a = Deduction.CreateAmortized(s2, 12, MonetaryValue.of("php", 200), mode: DeductionMode.CONTINIOUS); var d2b = Deduction.CreateAmortized(s2, 12, MonetaryValue.of("php", 300), mode: DeductionMode.CONTINIOUS); var d2c = Deduction.CreateAmortized(s2, 12, MonetaryValue.of("php", 400), mode: DeductionMode.CONTINIOUS); var e3 = Employee.Create(Person.Create("ann", "santos", "cruz", "", Gender.FEMALE, Date.Now), Date.Now); var s3 = Salary.Create(e3, MonetaryValue.of("php", 13000)); var d3 = Deduction.Create(s3, 2, MonetaryValue.of("php", 2000)); var d3a = Deduction.CreateAmortized(s3, 12, MonetaryValue.of("php", 200), mode: DeductionMode.CONTINIOUS); var d3b = Deduction.CreateAmortized(s3, 12, MonetaryValue.of("php", 300), mode: DeductionMode.CONTINIOUS); var d3c = Deduction.CreateAmortized(s3, 12, MonetaryValue.of("php", 400), mode: DeductionMode.CONTINIOUS); var e4 = Employee.Create(Person.Create("audrey", "yin", "yang", "", Gender.FEMALE, Date.Now), Date.Now); var s4 = Salary.Create(e4, MonetaryValue.of("php", 14000)); var d4 = Deduction.Create(s4, 2, MonetaryValue.of("php", 5000)); var d4a = Deduction.CreateAmortized(s4, 12, MonetaryValue.of("php", 200), mode: DeductionMode.CONTINIOUS); var d4b = Deduction.CreateAmortized(s4, 12, MonetaryValue.of("php", 300), mode: DeductionMode.CONTINIOUS); var d4c = Deduction.CreateAmortized(s4, 12, MonetaryValue.of("php", 400), mode: DeductionMode.CONTINIOUS); employees_repository.Save(e); employees_repository.Save(e2); employees_repository.Save(e3); employees_repository.Save(e4); salary_repository.Save(s); salary_repository.Save(s2); salary_repository.Save(s3); salary_repository.Save(s4); uow.Commit(); } }
private static Instrument CreateInstrument(int number) { using var uow = new NHUnitOfWork(); uow.OpenSession(_currentReadTenantIds); uow.BeginTransaction(); Console.WriteLine($"Creating Instrument#: {number} for Tenant ID: {_currentWriteTenantId}"); var instrument = new Instrument { Number = number }; uow.Session.SaveOrUpdate(instrument); uow.Commit(); return(instrument); }
public void Start(Calculation calculation) { Task.Factory.StartNew(() => { publisher.RegisterHandler(new JobIndexPointPersister()); using (var transaction = new TransactionScope()) using (var reuow = new NHUnitOfWork(RuleEngineSession.GetSession())) using (var uow = new NHUnitOfWork(PMSSession.GetSession())) { var empRep = new EmployeeRepository(uow); var rebps = new RuleBasedPolicyEngineService(new LocatorProvider("PMSDb"), publisher); var policyRep = new MITD.PMS.Persistence.NH.PolicyRepository(uow, new PolicyConfigurator(rebps)); var policy = policyRep.GetById(calculation.PolicyId); var periodRep = new PeriodRepository(uow); var period = periodRep.GetById(calculation.PeriodId); var jiRep = new JobIndexRepository(uow); var jpRep = new JobPositionRepository(uow); var jipRep = new JobIndexPointRepository(uow); var ji = jiRep.GetAllJobIndex(period.Id).First(); var jp = jpRep.GetJobPositions(period.Id).First(); var en = calculation.EmployeeIdList.Select(i => i.EmployeeNo).ToList(); IList <Employee> employees = empRep.Find(e => en.Contains(e.Id.EmployeeNo) && e.Id.PeriodId == calculation.PeriodId); foreach (var employee in employees) { if (doStop) { break; } //var indices = policy.CalculateFor(DateTime.Now, employee, period,calculation, // new CalculationDataProvider(empRep),publisher, ); //publisher.Publish(new JobIndexPointsReady(indices)); } reuow.Commit(); uow.Commit(); transaction.Complete(); } }); }
public void TestDatapiontRepositoryUpdatAndCommitModthInUnitOfWork() { NHUnitOfWork nhUnitOfWork = new NHUnitOfWork(); DataPointRepository dataPointRepository = new DataPointRepository(nhUnitOfWork); DataPoint dataPointPre = dataPointRepository.FindBy(1); dataPointPre.Description = "MyID is" + Convert.ToString((dataPointPre.Id)); dataPointRepository.Save(dataPointPre); DataPoint dataPointAfter = dataPointRepository.FindBy(1); //如果不调用nhUnitOfWork.Commit(), //修改的数据还保存在ISession中,但是不会被保存到数据库 //测试方法: //在Commit前后分别查看数据库的变化 nhUnitOfWork.Commit(); Assert.AreEqual(dataPointPre.Description, dataPointAfter.Description); }
public void Handle(JobIndexPointsReady eventData) { Task.Factory.StartNew(() => { using (var transaction = new TransactionScope()) using (var uow = new NHUnitOfWork(PMSSession.GetSession())) { var rep = new JobIndexPointRepository(uow); foreach (var item in eventData.PointsHolder.EmployeePointsForAdd) { rep.Add(item); } foreach (var item in eventData.PointsHolder.EmployeePointsForUpdate) { var employeePoint = rep.GetById(item.Key); employeePoint.SetValue(item.Value); } uow.Commit(); transaction.Complete(); } }); }
public void can_get_active_deductions() { using (var uow = new NHUnitOfWork()) { var employee = Employee.Create(Person.Create("a", "a", "a", "", Gender.MALE, Date.Now), Date.Now); var salary = Salary.Create(employee, MonetaryValue.of("PHP", 15000)); Deduction.Create(salary, 3, MonetaryValue.of("php", 1000)); Deduction.Create(salary, 3, MonetaryValue.of("php", 2000)); Deduction.Create(salary, 3, MonetaryValue.of("php", 3000)); // Deduction.Create(salary, 3, MonetaryValue.of("php", 0)); EventBroker.getInstance().Command(new CommandAssociateSalaryToEmployee(salary, employee)); _employees.Save(employee); _salaries.Save(salary); uow.Commit(); } using (var uow = new NHUnitOfWork()) { var ees = _employees.FetchAllActive(); var ds = _salaries.FetchEmployeeActiveDeduction(ees[0]); Assert.Equal(3, ds.Count); } }
public void TestDatapiontRepositoryRemoveMethod_BothRemovingEntityForISessionAndemoveFormDataBase() { NHUnitOfWork nhUnitOfWork = new NHUnitOfWork(); DataPointRepository dataPointRepository = new DataPointRepository(nhUnitOfWork); DataPoint dataPointPre = dataPointRepository.FindBy(15); if (dataPointPre != null) { dataPointRepository.Remove(dataPointPre); } //如果不调用nhUnitOfWork.Commit(),就会: //只是在ISession中删除,但是没有在数据库中删除 //测试方法: //在Commit前后分别查看数据库的变化 nhUnitOfWork.Commit(); DataPoint dataPointAfter = dataPointRepository.FindBy(15); Assert.IsNull(dataPointAfter); }
public void RuleTest() { using (var scope = new TransactionScope()) { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["PMSDBConnection"].ConnectionString)) { var uows = new MITD.Domain.Repository.UnitOfWorkScope( new Data.NH.NHUnitOfWorkFactory(() => PMSAdmin.Persistence.NH.PMSAdminSession.GetSession(con))); using (var uow = new NHUnitOfWork(PMSSession.GetSession(con))) using (var uow2 = uows.CurrentUnitOfWork) { con.Open(); var pmsAdminService = new PMS.ACL.PMSAdmin.PMSAdminService( new PMSAdmin.Application.UnitService(new PMSAdmin.Persistence.NH.UnitRepository(uows), new PMSAdmin.Persistence.NH.CustomFieldRepository(uows)), new PMSAdmin.Application.JobService(new PMSAdmin.Persistence.NH.JobRepository(uows), new PMSAdmin.Persistence.NH.CustomFieldRepository(uows)), new PMSAdmin.Application.CustomFieldService(new PMSAdmin.Persistence.NH.CustomFieldRepository(uows)), new PMSAdmin.Application.JobPositionService(new PMSAdmin.Persistence.NH.JobPositionRepository(uows)), new PMSAdmin.Application.JobIndexService(new PMSAdmin.Persistence.NH.JobIndexRepository(uows), new PMSAdmin.Persistence.NH.CustomFieldRepository(uows)), new PMSAdmin.Application.UnitIndexService(new PMSAdmin.Persistence.NH.UnitIndexRepository(uows), new PMSAdmin.Persistence.NH.CustomFieldRepository(uows)) ); EventPublisher publisher = new EventPublisher(); var rep = new PMS.Persistence.NH.EmployeeRepository(uow); var periodRep = new PMS.Persistence.NH.PeriodRepository(uow); var calcRep = new PMS.Persistence.NH.CalculationRepository(uow); var policyRep = new MITD.PMS.Persistence.NH.PolicyRepository(uow, new PolicyConfigurator( new RuleBasedPolicyEngineService(new LocatorProvider("PMSDbConnection"), publisher))); var provider = new PMS.Application.CalculationDataProvider(rep, pmsAdminService, new PMS.Persistence.NH.JobIndexPointRepository(uow)); var policy = policyRep.GetById(new PolicyId(1)); var period = periodRep.GetBy(c => c.Active); var emp = rep.GetBy(new EmployeeId("150554", period.Id)); // if period has no calculation var calculation = new Calculation(calcRep.GetNextId(), period, policy, Guid.NewGuid().ToString(), DateTime.Now, "150554"); calcRep.Add(calculation); uow.Commit(); // if period has calculation , get it by its identifier //var calculation = calcRep.GetById(new CalculationId(1)); MITD.PMSReport.Domain.Model.CalculationData empData; var pathNo = 1; List <SummaryCalculationPoint> calcList = new List <SummaryCalculationPoint>(); var session = new CalculatorSession(); while (pathNo <= 2) { Utils.Res = new MITD.PMS.RuleContracts.RuleResult(); session.AddCalculationPoints(calcList); session.PathNo = pathNo; var data = provider.Provide(emp, out empData, calculation, true, session); var rule1 = new Rule10(); rule1.Execute(data); var rule2 = new Rule11(); rule2.Execute(data); var rule3 = new Rule12(); rule3.Execute(data); //var rule4 = new Rule13(); //rule4.Execute(data); var res = provider.Convert(Utils.Res, empData, emp, period, calculation); calcList = res.CalculationPoints.OfType <SummaryCalculationPoint>().ToList(); var jipRep = new JobIndexPointRepository(uow); if (res.EmployeePointsForAdd != null) { foreach (var point in res.EmployeePointsForAdd) { jipRep.Add(point); } } if (res.EmployeePointsForUpdate != null) { foreach (var point in res.EmployeePointsForUpdate) { var employeePoint = jipRep.GetById(point.Key); employeePoint.SetValue(point.Value); } } uow.Commit(); pathNo++; } } } } }
public void NHUnitOfWorkOperationsTest() { //CREATE = SAVE AND COMMIT using (var uow = new NHUnitOfWork(_sessionFactory)) { // populate the database var input = new List<IMeasure> { new SimpleMeasure("ReteA", 10U) }; var loc = _entitiesFactory.CreateLocation("Location1", input); loc.TotalTime = TimeVal; var input2 = new List<IMeasure> { new SimpleMeasure("ReteB", 50U), new SimpleMeasure("ReteC", 100U) }; var loc2 = _entitiesFactory.CreateLocation("Location2", input2); loc2.TotalTime = TimeVal1; //this saves everything else via cascading uow.Save(loc); uow.Save(loc2); uow.Commit(); } // READ = // Get, GetLocationByName and GetAll using (var uow = new NHUnitOfWork(_sessionFactory)) { var locA = uow.GetLocationByName("Location1"); Assert.AreEqual(locA.Name, "Location1"); Assert.AreEqual(locA.TotalTime, TimeVal); var locB = uow.Get<Location>(locA.Id); Assert.AreEqual(locB.Name, "Location1"); Assert.AreEqual(locB.TotalTime, TimeVal); IList<Location> locations = uow.GetAll<Location>(); Assert.AreEqual(locations.Count, 2); foreach (var location in locations) { //For a visual feedback Console.WriteLine(location.ToString()); if (location.Name == "Location1") { Assert.AreEqual(location.TotalTime, TimeVal); } else if (location.Name == "Location2") { Assert.AreEqual(location.TotalTime, TimeVal1); } else { Log.Debug(location.Name); Assert.Fail("Location name not matching"); } } var networks = uow.GetAll<Network>(); Assert.AreEqual(networks.Count, 3); uow.Commit(); } Location longLivedLocation; const string locName = "Location1"; // UPDATE = SAVE AND COMMIT // update within a single unit of work using (var uow = new NHUnitOfWork(_sessionFactory)) { longLivedLocation = uow.GetLocationByName(locName); longLivedLocation.TotalTime = TimeVal2; uow.Commit(); } using (var uow = new NHUnitOfWork(_sessionFactory)) { var locB = uow.Get<Location>(longLivedLocation.Id); Assert.AreEqual(locB.TotalTime, TimeVal2); } // update of an entity retrieved in a unit of work // BEWARE OF DIRTY WRITES!!! THEY ARE STILL DIFFERENT TRANSACTIONS!!! using (var uow = new NHUnitOfWork(_sessionFactory)) { longLivedLocation.TotalTime = TimeVal3; uow.Save(longLivedLocation); uow.Commit(); } using (var uow = new NHUnitOfWork(_sessionFactory)) { var tmp = uow.GetLocationByName(locName); Assert.AreEqual(tmp.TotalTime, TimeVal3); uow.Commit(); } // ROLLBACK using (var uow = new NHUnitOfWork(_sessionFactory)) { longLivedLocation = uow.GetLocationByName("Location1"); longLivedLocation.TotalTime = TimeVal4; var input = new List<IMeasure> { new SimpleMeasure("ReteC", 10U) }; var loc = _entitiesFactory.CreateLocation("Location3", input); loc.TotalTime = TimeVal; uow.Save(loc); uow.Rollback(); } using (var uow = new NHUnitOfWork(_sessionFactory)) { var locB = uow.Get<Location>(longLivedLocation.Id); //old value Assert.AreEqual(locB.TotalTime, TimeVal3); var locations = uow.GetAll<Location>(); Assert.AreEqual(locations.Count, 2); foreach (var location in locations) { if(location.Name!="Location1" && location.Name!="Location2") { Log.Debug(location.Name); Assert.Fail("Location added in rollbacked unit of work"); } } } // LAZY LOADING // It seems it does not work (always eager loading). Less performances, zero problems... // Check it by hand, looking at logs Log.Debug("LAZY LOADING"); Location locLazy; using (var uow = new NHUnitOfWork(_sessionFactory)) { locLazy = uow.GetLocationByName("Location1"); } Assert.AreEqual(locLazy.Name, "Location1"); Assert.AreEqual(locLazy.TotalTime, TimeVal3); var up = new List<IMeasure> { new SimpleMeasure("ReteA", 20U) }; locLazy.UpdateStats(up); Log.Debug(locLazy.ToString()); IList<Location> locLazies; using (var uow = new NHUnitOfWork(_sessionFactory)) { locLazies = uow.GetAll<Location>(); } up = new List<IMeasure> { new SimpleMeasure("ReteA", 10U), new SimpleMeasure("ReteB", 40U) }; locLazies[1].UpdateStats(up); Log.Debug(locLazies[1].ToString()); // DELETE using (var uow = new NHUnitOfWork(_sessionFactory)) { var locations = uow.GetAll<Location>(); foreach (var location in locations) { uow.Delete(location); } uow.Commit(); } // check deletion cascade using (var uow = new NHUnitOfWork(_sessionFactory)) { var locations = uow.GetAll<Location>(); Assert.AreEqual(locations.Count, 0); var networks = uow.GetAll<Network>(); Assert.AreEqual(networks.Count, 0); } }
public void NHUnitOfWorkDisposeTransactionTest() { var uow = new NHUnitOfWork(_sessionFactory); uow.Dispose(); uow.Commit(); }
public void CalculationTest() { MITD.PMSAdmin.Domain.Model.Policies.PolicyId policyId; var empLst = string.Empty; PMSAdmin.Domain.Model.JobIndices.JobIndex sharedji; using (var transaction = new TransactionScope()) using (var puow = new NHUnitOfWork(PMSAdminSession.GetSession())) using (var reuow = new NHUnitOfWork(RuleEngineSession.GetSession())) { var ruleRep = new RuleRepository(reuow); var rfRep = new RuleFunctionRepository(reuow); var reConfigRep = new REConfigeRepository(reuow); var rebps = new RuleBasedPolicyEngineService(new LocatorProvider("PMSDb"), publisher); var policyRep = new MITD.PMSAdmin.Persistence.NH.PolicyRepository(puow); var rule = new Rule(new RuleId(ruleRep.GetNextId()), Guid.NewGuid().ToString(), @" RuleExecutionUtil.Res.Add( new RuleResult{Value = data.Data}); ", RuleType.PerCalculation, 1); ruleRep.Add(rule); var policy = new MITD.PMSAdmin.Domain.Model.Policies.RuleEngineBasedPolicy( policyRep.GetNextId(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); policyId = policy.Id; policyRep.Add(policy); policy.AssignRule(rule); var jirep = new PMSAdmin.Persistence.NH.JobIndexRepository(puow); var ai = new PMSAdmin.Domain.Model.JobIndices.JobIndexCategory( jirep.GetNextId(), null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); jirep.Add(ai); sharedji = new PMSAdmin.Domain.Model.JobIndices.JobIndex( jirep.GetNextId(), ai, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); jirep.Add(sharedji); reuow.Commit(); puow.Commit(); transaction.Complete(); } Calculation calc; var puows = new UnitOfWorkScope(new NHUnitOfWorkFactory(() => PMSAdminSession.GetSession())); var uows = new UnitOfWorkScope(new NHUnitOfWorkFactory(() => { var res = PMSSession.GetSession(); res.SetBatchSize(100); return(res); })); Period period; using (var transaction = new TransactionScope()) using (var puow = puows.CurrentUnitOfWork as NHUnitOfWork) using (var uow = uows.CurrentUnitOfWork as NHUnitOfWork) { var periodRep = new PeriodRepository(uow); period = new Period(new PeriodId(periodRep.GetNextId()), Guid.NewGuid().ToString(), DateTime.Now, DateTime.Now, 91); periodRep.Add(period); var sjiService = new PMS.ACL.PMSAdmin.PMSAdminService(null, null, null, null, new PMSAdmin.Application.JobIndexService(new PMSAdmin.Persistence.NH.JobIndexRepository(puow), new PMSAdmin.Persistence.NH.CustomFieldRepository(puow)) , new PMSAdmin.Application.UnitIndexService(new PMSAdmin.Persistence.NH.UnitIndexRepository(uows), new PMSAdmin.Persistence.NH.CustomFieldRepository(uows) ) ); var sji = sjiService.GetSharedJobIndex(new PMS.Domain.Model.JobIndices.SharedJobIndexId(sharedji.Id.Id)); var jiRep = new PMS.Persistence.NH.JobIndexRepository(uow); var jic = new PMS.Domain.Model.JobIndices.JobIndexGroup( jiRep.GetNextId(), period, null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); jiRep.Add(jic); var ji = new PMS.Domain.Model.JobIndices.JobIndex( jiRep.GetNextId(), period, sji, jic, true); jiRep.Add(ji); uow.Commit(); transaction.Complete(); } for (int j = 0; j < 10; j++) { using (var transaction = new TransactionScope()) using (var uow = uows.CurrentUnitOfWork as NHUnitOfWork) { var empRep = new EmployeeRepository(uow); for (int i = 0; i < 500; i++) { var emp = new Employee(Guid.NewGuid().ToString(), period, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); empLst += emp.Id.EmployeeNo + ";"; empRep.Add(emp); } empLst = empLst.Remove(empLst.Length - 1); uow.Commit(); transaction.Complete(); } } using (var transaction = new TransactionScope()) using (var uow = uows.CurrentUnitOfWork as NHUnitOfWork) { var rebps = new RuleBasedPolicyEngineService(new LocatorProvider("PMSDb"), publisher); var calcRep = new CalculationRepository(uow); var policyRep = new MITD.PMS.Persistence.NH.PolicyRepository(uow, new PolicyConfigurator(rebps)); var policy = policyRep.GetById(new PolicyId(policyId.Id)); calc = new Calculation(calcRep.GetNextId(), period, policy, Guid.NewGuid().ToString(), DateTime.Now, empLst); calcRep.Add(calc); uow.Commit(); transaction.Complete(); } //var calculator = new JobIndexPointCalculator(publisher); //using (var transaction = new TransactionScope()) //using (var uow = new NHUnitOfWork(PMSSession.GetSession())) //{ // var calcRep = new CalculationRepository(uow); // calc = calcRep.GetById(calc.Id); // calc.Run(calculator); // uow.Commit(); // transaction.Complete(); //} //var t = Task.Factory.StartNew(() => // { // Thread.Sleep(1000); // using (var transaction = new TransactionScope()) // using (var uow = new NHUnitOfWork(PMSSession.GetSession())) // { // var calcRep = new CalculationRepository(uow); // calc = calcRep.GetById(calc.Id); // calc.Stop(calculator); // uow.Commit(); // transaction.Complete(); // } // }); //t.Wait(); }