public void isFullInquiryForms()//Period period) { JobIndex jobIndex = null; using (var session = PMSSession.GetSession()) using (session.BeginTransaction()) { //var jiRep = new PMS.Persistence.NH.JobIndexRepository(new NHUnitOfWork(session)); var jiRep = new PMS.Persistence.NH.InquiryJobIndexPointRepository(new NHUnitOfWork(session)); var pRep = new PMS.Persistence.NH.PeriodRepository(new NHUnitOfWork(session)); var period = pRep.GetAll().First(); var has = jiRep.IsAllInquiryJobIndexPointsHasValue(period); //var id = jiRep.GetNextId(); //jobIndex = new JobIndex(id, period, getSharedJobIndex(),jiRep.GetJobIndexGroupById(new Domain.Model.JobIndices.AbstractJobIndexId(1)),true); //session.Save(jobIndex); session.Transaction.Commit(); } }
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++; } } } } }