protected override void ActionCore() { while (!IsCancelled()) { DateTime now = DateTime.Now; foreach (var pair in _fixedJobs) { if (now > pair.Value.ChangeTime) { DateTime lastTime = pair.Value.CurrentTime; DateTime currentTime = TimePointConvert.NextTimePoint(pair.Value.Level, lastTime); DateTime nextTime = TimePointConvert.NextTimePoint(pair.Value.Level, currentTime); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { pair.Key.Handle(lastTime, currentTime, nextTime); } catch (Exception ex) { _logger.LogError((int)LogEvent.定时任务, ex, $"定制任务异常 {pair.Value.Name}"); } stopwatch.Stop(); _logger.LogDebug((int)LogEvent.定时任务, $"定时任务完成 任务名称:{pair.Value.Name} 执行时间:{lastTime} 当前时间:{currentTime} 下次触发:{nextTime} 耗时:{stopwatch.ElapsedMilliseconds}毫秒"); pair.Value.CurrentTime = currentTime; pair.Value.ChangeTime = nextTime.Add(pair.Value.Span); } } Thread.Sleep(1000); } }
/// <summary> /// 筛选 /// </summary> /// <param name="queryable">数据源</param> /// <param name="sectionId">路段编号</param> /// <param name="level">时间级别</param> /// <param name="startTime">开始时间</param> /// <param name="endTime">结束时间</param> /// <returns></returns> private IQueryable <SectionStatus> Where(IQueryable <SectionStatus> queryable, int sectionId, DateTimeLevel level, DateTime startTime, DateTime endTime) { if (level >= DateTimeLevel.Day) { startTime = TimePointConvert.CurrentTimePoint(level, startTime); endTime = TimePointConvert.NextTimePoint(level, TimePointConvert.CurrentTimePoint(level, endTime)).AddMinutes(-1); } return(queryable .Where(f => f.SectionId == sectionId && f.DateTime >= startTime && f.DateTime <= endTime)); }
/// <summary> /// 筛选 /// </summary> /// <param name="queryable">数据源</param> /// <param name="dataIds">车道数据编号集合</param> /// <param name="level">时间级别</param> /// <param name="startTime">开始时间</param> /// <param name="endTime">结束时间</param> /// <returns></returns> protected IQueryable <LaneFlow> Where(IQueryable <LaneFlow> queryable, HashSet <string> dataIds, DateTimeLevel level, DateTime startTime, DateTime endTime) { if (level >= DateTimeLevel.Day) { startTime = TimePointConvert.CurrentTimePoint(level, startTime); endTime = TimePointConvert.NextTimePoint(level, TimePointConvert.CurrentTimePoint(level, endTime)).AddMinutes(-1); } return(queryable .Where(f => dataIds.Contains(f.DataId) && f.DateTime >= startTime && f.DateTime <= endTime)); }
/// <summary> /// 筛选 /// </summary> /// <param name="queryable">数据源</param> /// <param name="dataId">数据编号</param> /// <param name="level">时间级别</param> /// <param name="startTime">开始时间</param> /// <param name="endTime">结束时间</param> /// <returns></returns> private IQueryable <TrafficDensity> Where(IQueryable <TrafficDensity> queryable, string dataId, DateTimeLevel level, DateTime startTime, DateTime endTime) { if (level >= DateTimeLevel.Day) { startTime = TimePointConvert.CurrentTimePoint(level, startTime); endTime = TimePointConvert.NextTimePoint(level, TimePointConvert.CurrentTimePoint(level, endTime)).AddMinutes(-1); } return(queryable .Where(f => f.DataId == dataId && f.DateTime >= startTime && f.DateTime <= endTime)); }
/// <summary> /// 初始化缓存 /// </summary> /// <param name="devices">设备集合</param> private void InitAdapter(List <FlowDevice> devices) { _logger.LogInformation((int)LogEvent.系统, "初始化数据适配"); DateTime minTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, DateTime.Now); DateTime maxTime = TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, minTime); FlowAdapter flowAdapter = _serviceProvider.GetRequiredService <FlowAdapter>(); FlowBranchBlock flowBranchBlock = _serviceProvider.GetRequiredService <FlowBranchBlock>(); VideoBranchBlock videoBranchBlock = _serviceProvider.GetRequiredService <VideoBranchBlock>(); flowBranchBlock.Open(devices, minTime, maxTime); videoBranchBlock.Open(minTime, maxTime); flowAdapter.Start(devices, flowBranchBlock, videoBranchBlock); }
/// <summary> /// 初始化缓存 /// </summary> /// <param name="devices">设备集合</param> private void InitAdapter(List <DensityDevice> devices) { _logger.LogInformation((int)LogEvent.系统, "初始化数据适配"); DateTime minTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, DateTime.Now); DateTime maxTime = TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, minTime); DensityAdapter densityAdapter = _serviceProvider.GetRequiredService <DensityAdapter>(); DensityBranchBlock densityBranchBlock = _serviceProvider.GetRequiredService <DensityBranchBlock>(); EventBranchBlock eventBranchBlock = _serviceProvider.GetRequiredService <EventBranchBlock>(); densityBranchBlock.Open(devices, minTime, maxTime); eventBranchBlock.Open(devices); densityAdapter.Start(devices, densityBranchBlock, eventBranchBlock); }
/// <summary> /// 处理数据块中的流量数据 /// </summary> /// <param name="data">流量数据</param> protected override void Handle(T data) { if (data.DateTime >= _maxTime) { PostData(); InitData(); _minTime = TimePointConvert.CurrentTimePoint(_level, data.DateTime); _maxTime = TimePointConvert.NextTimePoint(_level, _minTime); SetData(data, _minTime); } else if (data.DateTime >= _minTime && data.DateTime < _maxTime) { SetData(data, _minTime); } }
/// <summary> /// 添加定时任务 /// </summary> /// <param name="fixedJob">定时任务</param> /// <param name="level">时间间隔级别</param> /// <param name="span">时间偏移</param> /// <param name="name">任务名称</param> public void AddFixedJob(IFixedJob fixedJob, DateTimeLevel level, TimeSpan span, string name) { DateTime currentTime = TimePointConvert.CurrentTimePoint(level, DateTime.Now); DateTime changeTime = TimePointConvert.NextTimePoint(level, currentTime).Add(span); _logger.LogInformation((int)LogEvent.定时任务, $"添加定时任务 {name} {level} { changeTime:yyyy-MM-dd HH:mm:ss}"); _fixedJobs.TryAdd(fixedJob, new FixedJobItem { Name = name, Level = level, Span = span, CurrentTime = currentTime, ChangeTime = changeTime }); }
public static Dictionary <TrafficRegion, int> CreateData(IServiceProvider serviceProvider, List <DensityDevice> devices, List <DataCreateMode> modes, List <DateTime> startTimes, List <DateTime> endTimes, bool initDatabase = false) { if (initDatabase) { ResetDatabase(serviceProvider); } Dictionary <TrafficRegion, int> regions = new Dictionary <TrafficRegion, int>(); for (int i = 0; i < startTimes.Count; ++i) { DateTime minTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, startTimes[i]); DateTime maxTime = TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, minTime); DensityBranchBlock branch = new DensityBranchBlock(serviceProvider); branch.Open(devices, minTime, maxTime); Random random = new Random(); foreach (DensityDevice device in devices) { foreach (var relation in device.DensityDevice_DensityChannels) { foreach (TrafficRegion region in relation.Channel.Regions) { int randomValue = random.Next(1, 1000); if (modes[i] == DataCreateMode.Random) { regions[region] = randomValue; } int value = 1; for (int m = 0; m < 1440; ++m) { DateTime dataTime = startTimes[i].AddMinutes(m); if (dataTime > DateTime.Now) { break; } if (dataTime >= startTimes[i] && dataTime < endTimes[i]) { TrafficDensity density; if (modes[i] == DataCreateMode.Fixed) { density = new TrafficDensity { MatchId = $"{device.Ip}_{relation.Channel.ChannelIndex}_{region.RegionIndex}", DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Value = 1 }; } else if (modes[i] == DataCreateMode.Sequence) { density = new TrafficDensity { MatchId = $"{device.Ip}_{relation.Channel.ChannelIndex}_{region.RegionIndex}", DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Value = value }; } else { density = new TrafficDensity { MatchId = $"{device.Ip}_{relation.Channel.ChannelIndex}_{region.RegionIndex}", DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Value = randomValue }; } branch.Post(density); } ++value; } } } } branch.Close(); if (i == startTimes.Count - 1) { DateTime currentTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel); if (minTime != currentTime) { using (DensityContext context = serviceProvider.GetRequiredService <DensityContext>()) { context.ChangeDatabase(BranchDbConvert.GetTableName(minTime)); } branch.SwitchBranch(maxTime, TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, maxTime)); } } else { DateTime nextItem = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, startTimes[i + 1]); if (minTime != nextItem) { using (DensityContext context = serviceProvider.GetRequiredService <DensityContext>()) { context.ChangeDatabase(BranchDbConvert.GetTableName(minTime)); } branch.SwitchBranch(maxTime, TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, maxTime)); } } } return(regions); }
public static Dictionary <string, List <LaneFlow> > CreateData(IServiceProvider serviceProvider, List <FlowDevice> devices, List <DataCreateMode> modes, List <DateTime> startTimes, List <DateTime> endTimes, bool initDatabase = false) { if (initDatabase) { ResetDatabase(serviceProvider); } Dictionary <string, List <LaneFlow> > datas = new Dictionary <string, List <LaneFlow> >(); foreach (FlowDevice device in devices) { foreach (var relation in device.FlowDevice_FlowChannels) { foreach (Lane lane in relation.Channel.Lanes) { datas.Add(lane.DataId, new List <LaneFlow>()); } } } for (int i = 0; i < startTimes.Count; ++i) { DateTime minTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, startTimes[i]); DateTime maxTime = TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, minTime); FlowBranchBlock branch = new FlowBranchBlock(serviceProvider); branch.Open(devices, minTime, maxTime); Random random = new Random(); foreach (FlowDevice device in devices) { foreach (var relation in device.FlowDevice_FlowChannels) { foreach (Lane lane in relation.Channel.Lanes) { int value = 1; for (int m = 0; m < 1440; ++m) { DateTime dataTime = startTimes[i].AddMinutes(m); if (dataTime > DateTime.Now) { break; } if (dataTime >= startTimes[i] && dataTime < endTimes[i]) { LaneFlow laneFlow; if (modes[i] == DataCreateMode.Fixed) { laneFlow = new LaneFlow { DataId = lane.DataId, DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Cars = 1, Buss = 1, Trucks = 1, Vans = 1, Tricycles = 1, Motorcycles = 1, Bikes = 1, Persons = 1, AverageSpeedData = 50, HeadDistance = 10, Occupancy = 30, TimeOccupancy = 40, TrafficStatus = TrafficStatus.轻度拥堵, Count = 1 }; } else if (modes[i] == DataCreateMode.Sequence) { laneFlow = new LaneFlow { DataId = lane.DataId, DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Cars = value++, Buss = 2, Trucks = 3, Vans = 4, Tricycles = 5, Motorcycles = 6, Bikes = 7, Persons = 8, AverageSpeedData = 9, HeadDistance = 10, Occupancy = 12, TimeOccupancy = 13, TrafficStatus = TrafficStatus.通畅, Count = 1 }; } else { laneFlow = new LaneFlow { DataId = lane.DataId, DateTime = new DateTime(dataTime.Year, dataTime.Month, dataTime.Day, dataTime.Hour, dataTime.Minute, 0), Cars = random.Next(1, 10), Buss = random.Next(1, 10), Trucks = random.Next(1, 10), Vans = random.Next(1, 10), Tricycles = random.Next(1, 10), Motorcycles = random.Next(1, 10), Bikes = random.Next(1, 10), Persons = random.Next(1, 10), AverageSpeedData = random.Next(1, 10), HeadDistance = random.Next(1, 10), Occupancy = random.Next(1, 10), TimeOccupancy = random.Next(1, 10), TrafficStatus = (TrafficStatus)random.Next(1, 6), Count = 1 }; } laneFlow.SectionId = lane.Channel.RoadSection.SectionId; laneFlow.SectionType = lane.Channel.RoadSection.SectionType; laneFlow.SectionLength = lane.Channel.RoadSection.Length; laneFlow.FreeSpeed = lane.Channel.RoadSection.FreeSpeed; laneFlow.Distance = laneFlow.Vehicle * lane.Length; laneFlow.TravelTime = laneFlow.AverageSpeedData > 0 ? laneFlow.Vehicle * lane.Length / Convert.ToDouble(laneFlow.AverageSpeedData * 1000 / 3600) : 0; datas[lane.DataId].Add(laneFlow); branch.Post(laneFlow); } ++value; } } } } branch.Close(); if (i == startTimes.Count - 1) { DateTime currentTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel); if (minTime != currentTime) { using (FlowContext context = serviceProvider.GetRequiredService <FlowContext>()) { context.ChangeDatabase(BranchDbConvert.GetTableName(minTime)); } branch.SwitchBranch(maxTime, TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, maxTime)); } } else { DateTime nextItem = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, startTimes[i + 1]); if (minTime != nextItem) { using (FlowContext context = serviceProvider.GetRequiredService <FlowContext>()) { context.ChangeDatabase(BranchDbConvert.GetTableName(minTime)); } branch.SwitchBranch(maxTime, TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, maxTime)); } } } return(datas); }
public static void CreateData(IServiceProvider serviceProvider, List <FlowDevice> devices, DataCreateMode mode, DateTime startDate, DateTime endDate, bool initDatabase = false) { if (initDatabase) { using (FlowContext context = serviceProvider.CreateScope().ServiceProvider.GetRequiredService <FlowContext>()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); } } DateTime minTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, startDate); DateTime maxTime = TimePointConvert.NextTimePoint(BranchDbConvert.DateLevel, minTime); VideoBranchBlock branch = new VideoBranchBlock(serviceProvider); branch.Open(minTime, maxTime); Random random = new Random(); for (DateTime date = startDate; date <= endDate; date = date.AddDays(1)) { int value = 1; for (int i = 0; i < 1440; ++i) { DateTime startTime = startDate.AddMinutes(i); foreach (FlowDevice device in devices) { foreach (var relation in device.FlowDevice_FlowChannels) { foreach (Lane lane in relation.Channel.Lanes) { VideoVehicle videoVehicle; VideoBike bike; VideoPedestrain pedestrain; if (mode == DataCreateMode.Fixed) { videoVehicle = new VideoVehicle { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGR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 1, CarColor = 1, PlateNumber = "京A0000" + 1, PlateType = 1 }; bike = new VideoBike { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\r\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", BikeType = (int)NonVehicle.自行车 }; pedestrain = new VideoPedestrain { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\r\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", Age = (int)Age.儿童, Sex = (int)Sex.女, UpperColor = (int)UpperColor.红 }; } else if (mode == DataCreateMode.Sequence) { int temp = value; value += 1; videoVehicle = new VideoVehicle { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute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PEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", CarType = 1, CarBrand = "brand" + temp, CarColor = 1, PlateNumber = "京A0000" + 1, PlateType = 1 }; bike = new VideoBike { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\r\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", BikeType = (temp % 2 == 0 ? 2 : 3) }; pedestrain = new VideoPedestrain { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDA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RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", Age = (int)Age.儿童, Sex = (temp % 2 == 0 ? 1 : 2), UpperColor = (int)UpperColor.红 }; } else { videoVehicle = new VideoVehicle { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\r\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", CarType = random.Next(1, 21), CarBrand = "brand" + random.Next(1, 100), CarColor = random.Next(1, 13), PlateNumber = "京A0000" + random.Next(1, 9), PlateType = random.Next(1, 29) }; bike = new VideoBike { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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B61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", BikeType = random.Next(2, 3) }; pedestrain = new VideoPedestrain { DataId = lane.DataId, DateTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0), Image = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4p\r\nLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//2wBDAQ4ODhMREyYVFSZPNS01T09PT09P\r\nT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0//wAARCAAkACoDASEA\r\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\r\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\r\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\r\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\r\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\r\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\r\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\r\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpWXAw\r\nenaq8gVepAq0SV32/wB4fnUDAdiDTGRlaNh9T+dSBvSDPTrjpTwba1toBdWJlnlUsVP8I/GmIYs+\r\nl4+bSnX6N/8AXqIrpV3J5NqlxBclSUBRsOR7nigZmKxkQMylTyCD2I60nFAjdhsIbq7Erq3mICUI\r\nJwD2JFTNbaurY/twrjpmyX5v1zUsaAwa4Rxq0eR62R5+tQuPEeQFvdJLg8eZE4/rQgMKK0uWv724\r\nu54PtJfE8MWdqnsR9RT/ACz6H8qoRd1bVptEEE8SQu8wYIkjY3Yx0OaxZviNerFgQWfmE4OA7bPc\r\n/wD66mwy4fHVoyIV1bD7RvH2QlQfbvUcXj2TczPp8NwycCVJNm4euG6UWGTaZcNq1tdauYxCLiXa\r\nEDZwB61YwaZJh/EuRo10srj5EcgdutS6c1hd2kHn6LphJRckQkE8A+tMZtxeF9AlSF20mAGTOQrO\r\nB/Os7xp4Z0bSfDVxc2NkscygBX3MSvPbJpAL4MHm+Cogxx++bOO/Irof7Ph/vP8AmP8ACmI//9k=", Feature = "", Age = (int)Age.儿童, Sex = (int)Sex.女, UpperColor = random.Next(1, 9) }; } branch.Post(videoVehicle); branch.Post(bike); branch.Post(pedestrain); } } } } } DateTime currentTime = TimePointConvert.CurrentTimePoint(BranchDbConvert.DateLevel, DateTime.Now); branch.Close(); if (currentTime != minTime) { using (FlowContext context = serviceProvider.GetRequiredService <FlowContext>()) { context.ChangeBikeTable(BranchDbConvert.GetTableName(minTime)); context.ChangePedestrainTable(BranchDbConvert.GetTableName(minTime)); context.ChangeVehicleTable(BranchDbConvert.GetTableName(minTime)); } } }