| | |
| | | AutoMapper.Mapper.Initialize((cfg) => { |
| | | cfg.AddProfile<MapperConfiguration>(); |
| | | }); |
| | | |
| | | // 删除一个月前的数据 |
| | | new Thread(AutoDeleteHistoryDate.Handler).Start(); |
| | | } |
| | | |
| | | private void ReceiveHandle() |
| | |
| | | |
| | | private void CreateDatabase() |
| | | { |
| | | using (var context = new DbModel()) |
| | | try |
| | | { |
| | | // 确保数据库和表存在,如果不存在则创建 |
| | | context.Database.EnsureCreated(); |
| | | |
| | | // 添加一些数据 |
| | | context.RobotInfo.Add(new RobotInfo |
| | | using (var context = new DbModel()) |
| | | { |
| | | WarnningNum = 0, |
| | | //RobotStatus = "Normal", |
| | | RobotModel = "Model X", |
| | | RobotSerialNo = "123456", |
| | | WarnningContent = "清除富文本框数据", |
| | | CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | IsDelete = false |
| | | }); |
| | | // 确保数据库和表存在,如果不存在则创建 |
| | | context.Database.EnsureCreated(); |
| | | |
| | | // 保存更改 |
| | | context.SaveChanges(); |
| | | // 添加一些数据 |
| | | context.RobotInfo.Add(new RobotInfo |
| | | { |
| | | WarnningNum = 0, |
| | | //RobotStatus = "Normal", |
| | | RobotModel = "Model X", |
| | | RobotSerialNo = "123456", |
| | | WarnningContent = "清除富文本框数据", |
| | | CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | CreateStamp = DateTimeOffset.Now.ToUnixTimeSeconds(), |
| | | IsDelete = false |
| | | }); |
| | | |
| | | var xx = context.RobotInfo.ToList(); |
| | | // 保存更改 |
| | | context.SaveChanges(); |
| | | |
| | | var xx = context.RobotInfo.ToList(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | r_showBox.Text = "数据库初始化异常"+ ex.Message; |
| | | } |
| | | } |
| | | |