private void CalculateWeightNumber() { var weightBoundary = _unitOfWork.Repository <Config>().GetAll().Where(x => x.Name.Equals("WeightBoundary") && x.Active == true).Select(x => x.Value).FirstOrDefault(); var systemzones = _unitOfWork.Repository <SystemZone>().GetAll().Include(x => x.Ward).ToList(); foreach (var item in systemzones) { item.WeightNumber = 0; var districtPopulationDensity = item.Ward.District.PopulationDensity; var systemzonePopoulation = (item.Geom.Area * 12096.719247500967) * districtPopulationDensity; int temp = (int)((systemzonePopoulation / weightBoundary) + 1); item.WeightNumber += temp; var buildingsInSystemzone = _unitOfWork.Repository <Building>().GetAll().Where(x => item.Geom.Intersects(x.Geom) && x.Status != (int?)Status.Deleted && x.Status != (int?)Status.WaitingUpdate && x.Status != (int?)Status.Reject).ToList(); item.WeightNumber += buildingsInSystemzone.Where(x => (x.NumberOfFloor >= 0 && x.NumberOfFloor <= 5) || x.NumberOfFloor == null).Count() * 1 + buildingsInSystemzone.Where(x => x.NumberOfFloor > 5 && x.NumberOfFloor <= 10).Count() * 2 + buildingsInSystemzone.Where(x => x.NumberOfFloor > 10).Count() * 3; } var log = new TestCronJob() { Message = "Cronjob working at " + TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time")) }; _unitOfWork.Repository <TestCronJob>().Insert(log); _unitOfWork.Repository <SystemZone>().UpdateRange(systemzones.AsQueryable()); _unitOfWork.CommitAsync(); }
public static void TestCronJobAsync() { TestCronJob test = new TestCronJob() { Message = "Test Cronjon " + DateTime.UtcNow.AddHours(7).ToString() }; TradeZoneMapContext context = new TradeZoneMapContext(); context.TestCronJobs.Add(test); context.SaveChanges(); }
public Given_a_scheduled_CronJob() { _sut = new TestCronJob(); SchedulingService.AddScheduledJob(time => time.AddSeconds(1), (Action<ICronJob> callback) => callback(_sut)); }
public Given_a_scheduled_CronJob() { _sut = new TestCronJob(); SchedulingService.AddScheduledJob(time => time.AddSeconds(1), (Action <ICronJob> callback) => callback(_sut)); }