public ActionResult Create(EquipmentInstallationCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Eunumber.Trim().Length <= 0) { response.SetFailed("请输入设备编号"); return(Ok(response)); } using (_dbContext) { if (_dbContext.EquipmentInstallation.Count(x => x.Eunumber == model.Eunumber) > 0) { response.SetFailed("设备编号已存在"); return(Ok(response)); } var entity = _mapper.Map <EquipmentInstallationCreateViewModel, EquipmentInstallation>(model); entity.Eiid = RandomHelper.GetRandomizer(8, true, false, true, true); entity.InstallationTime = DateTime.Now; _dbContext.EquipmentInstallation.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public ActionResult Create(InstallationPositionCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.AreaName.Trim().Length <= 0) { response.SetFailed("请输入区域名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.InstallationPosition.Count(x => x.AreaName == model.AreaName) > 0) { response.SetFailed("区域名称已存在"); return(Ok(response)); } var entity = _mapper.Map <InstallationPositionCreateViewModel, InstallationPosition>(model); entity.Ipid = RandomHelper.GetRandomizer(8, true, false, true, true); entity.InstallationTime = DateTime.Now; _dbContext.InstallationPosition.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(UserCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.LoginName.Trim().Length <= 0) { response.SetFailed("请输入登录名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncUser.Count(x => x.LoginName == model.LoginName) > 0) { response.SetFailed("登录名已存在"); return(Ok(response)); } var entity = _mapper.Map <UserCreateViewModel, DncUser>(model); entity.CreatedOn = DateTime.Now; entity.Guid = Guid.NewGuid(); entity.Status = model.Status; _dbContext.DncUser.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(PermissionCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Name.Trim().Length <= 0) { response.SetFailed("请输入权限名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncPermission.Count(x => x.ActionCode == model.ActionCode && x.MenuGuid == model.MenuGuid) > 0) { response.SetFailed("权限操作码已存在"); return(Ok(response)); } var entity = _mapper.Map <PermissionCreateViewModel, DncPermission>(model); entity.CreatedOn = DateTime.Now; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); entity.CreatedByUserGuid = AuthContextService.CurrentUser.Guid; entity.CreatedByUserName = AuthContextService.CurrentUser.DisplayName; _dbContext.DncPermission.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(RoleCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Name.Trim().Length <= 0) { response.SetFailed("请输入角色名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncRole.Count(x => x.Name == model.Name) > 0) { response.SetFailed("角色已存在"); return(Ok(response)); } var entity = _mapper.Map <RoleCreateViewModel, DncRole>(model); entity.CreatedOn = DateTime.Now; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); entity.CreatedByUserId = 1; entity.CreatedByUserName = "******"; _dbContext.DncRole.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(IconCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Code.Trim().Length <= 0) { response.SetFailed("请输入图标名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncIcon.Count(x => x.Code == model.Code) > 0) { response.SetFailed("图标已存在"); return(Ok(response)); } var entity = _mapper.Map <IconCreateViewModel, DncIcon>(model); entity.CreatedOn = DateTime.Now; entity.CreatedByUserGuid = AuthContextService.CurrentUser.Guid; entity.CreatedByUserName = AuthContextService.CurrentUser.DisplayName; _dbContext.DncIcon.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(RoleCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Name.Trim().Length <= 0) { response.SetFailed("请输入角色名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncRole.Count(x => x.Name == model.Name) > 0) { response.SetFailed("角色已存在"); return(Ok(response)); } var entity = _mapper.Map <RoleCreateViewModel, DncRole>(model); entity.CreatedOn = DateTime.Now; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); entity.IsSuperAdministrator = false; entity.IsBuiltin = false; entity.CreatedByUserGuid = AuthContextService.CurrentUser.Guid; entity.CreatedByUserName = AuthContextService.CurrentUser.DisplayName; _dbContext.DncRole.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public ActionResult <ResponseModel> Create(FinanceInfoCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Title.Trim().Length <= 0) { response.SetFailed("请输入财务管理名称"); return(Ok(response)); } using (_dbContext) { var entity = _mapper.Map <FinanceInfoCreateViewModel, FinanceInfo>(model); entity.CreatedOn = DateTime.Now; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); entity.CreatedByUserGuid = AuthContextService.CurrentUser.Guid; entity.CreatedByUserName = AuthContextService.CurrentUser.DisplayName; _dbContext.FinanceInfo.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public ActionResult Create(ECUTableCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.ElectronicUnitNumber.Trim().Length <= 0) { response.SetFailed("请输入设备编号"); return(Ok(response)); } using (_dbContext) { if (_dbContext.Ecutable.Count(x => x.ElectronicUnitNumber == model.ElectronicUnitNumber) > 0) { response.SetFailed("设备编号已存在"); return(Ok(response)); } var entity = _mapper.Map <ECUTableCreateViewModel, Ecutable>(model); entity.Ecuid = RandomHelper.GetRandomizer(8, true, false, true, true); entity.DateOfManufacture = DateTime.Now; _dbContext.Ecutable.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(CeshiCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.A.Trim().Length <= 0) { response.SetFailed("请输入角色名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncCeshi.Count(x => x.A == model.A) > 0) { response.SetFailed("角色已存在"); return(Ok(response)); } var entity = _mapper.Map <CeshiCreateViewModel, DncCeshi>(model); entity.B = RandomHelper.GetRandomizer(8, true, false, true, true); entity.E = AuthContextService.CurrentUser.DisplayName; _dbContext.DncCeshi.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public ActionResult <ResponseModel> Create(DicTypeCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.Name.Trim().Length <= 0) { response.SetFailed("请输入字典类型名称"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DncRole.Count(x => x.Name == model.Name) > 0) { response.SetFailed("字典类型已存在"); return(Ok(response)); } var entity = _mapper.Map <DicTypeCreateViewModel, SystemDicType>(model); entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); _dbContext.SystemDicType.Add(entity); _dbContext.SaveChanges(); //清理缓存 _dictionaryService.ClearDictionaryCache(); response.SetSuccess(); return(Ok(response)); } }
public ActionResult Create(DeviceInformationCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; if (model.BatchNumber.Trim().Length <= 0) { response.SetFailed("请输入批次号"); return(Ok(response)); } using (_dbContext) { if (_dbContext.DeviceInformation.Count(x => x.Eunumber == model.Eunumber) > 0) { response.SetFailed("设备编号已存在"); return(Ok(response)); } var entity = _mapper.Map <DeviceInformationCreateViewModel, DeviceInformation>(model); entity.Diid = RandomHelper.GetRandomizer(8, true, false, true, true); entity.DateOfManufacture = DateTime.Now; _dbContext.DeviceInformation.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(MenuCreateViewModel model) { using (_dbContext) { var entity = _mapper.Map <MenuCreateViewModel, DncMenu>(model); entity.CreatedOn = DateTime.Now; entity.Guid = Guid.NewGuid(); entity.CreatedByUserGuid = AuthContextService.CurrentUser.Guid; entity.CreatedByUserName = AuthContextService.CurrentUser.DisplayName; _dbContext.DncMenu.Add(entity); _dbContext.SaveChanges(); var response = ResponseModelFactory.CreateInstance; response.SetSuccess(); return(Ok(response)); } }
public IActionResult Create(TaskListCreateViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = _mapper.Map <TaskListCreateViewModel, DncTaskList>(model); entity.KeyWork = model.KeyWork; entity.ImportanceOfWork = model.ImportanceOfWork; entity.CreationTime = DateTime.Now; entity.MajorIinitiatives = model.MajorIinitiatives; entity.ImplementationProgress = model.ImplementationProgress; entity.ProgressStatus = model.ProgressStatus; entity.PersonLiable = model.PersonLiable; entity.Remarks = model.Remarks; entity.IsComplete = model.IsComplete; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); _dbContext.DncTaskList.Add(entity); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }
/// <summary> /// 系统数据初始化 /// </summary> /// <param name="context"></param> public static void Initialize(DncZeusDbContext context) { if (context.DncUser.Any()) { return; //数据已经初始化过了 } // 添加一个系统超级管理员 context.DncUser.Add(new DncUser { Avatar = "https://file.iviewui.com/dist/a0e88e83800f138b94d2414621bd9704.png", CreatedOn = DateTime.Now, CreatedByUserId = 1, CreatedByUserName = "******", DisplayName = "系统管理员", Guid = new Guid("20263da4-aed4-4aba-a6cc-b985c016858e"), LoginName = "administrator", ModifiedByUserId = 1, ModifiedByUserName = "******", Password = "******", // 明文密码,生产环境请自行加密处理 UserType = UserType.SuperAdministator }); context.SaveChanges(); }
public IActionResult List() { using (_dbContext) { _dbContext.Database.ExecuteSqlCommand("DELETE FROM DataList"); var planlist = _dbContext.DncWorkTask.ToList(); List <string> daylist = new List <string>(); List <string> delaylist = new List <string>(); DateTime nowday = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); for (int cleari = 0; cleari < planlist.ToArray().Length; cleari++) { //首先保证 time1<=time2 DateTime day1 = Convert.ToDateTime(planlist[cleari].CompletionTime.Substring(0, 10)); DateTime day2 = Convert.ToDateTime(planlist[cleari].CompletionTime.Substring(13, 10)); string month = null; if (day1 <= day2) { if (int.Parse(day1.ToString("yyyy-MM-dd").Substring(5, 2)) < int.Parse(day2.ToString("yyyy-MM-dd").Substring(5, 2))) { month = day1.ToString("yyyy-MM-dd").Substring(0, 7) + " - " + day2.ToString("yyyy-MM-dd").Substring(0, 7); } else if (int.Parse(day1.ToString("yyyy-MM-dd").Substring(5, 2)) == int.Parse(day2.ToString("yyyy-MM-dd").Substring(5, 2))) { month = day2.ToString("yyyy-MM-dd").Substring(0, 7); } } DataListCreateViewModel model = new DataListCreateViewModel(); var entity = _mapper.Map <DataListCreateViewModel, DataList>(model); entity.Id = cleari + 1; entity.Month = month; entity.No1 = 0; entity.No2 = 0; entity.No3 = 0; entity.No4 = 0; entity.No5 = 0; entity.No6 = 0; entity.No7 = 0; entity.No8 = 0; entity.No9 = 0; entity.No10 = 0; entity.No11 = 0; entity.No12 = 0; entity.No13 = 0; entity.No14 = 0; entity.No15 = 0; entity.No16 = 0; entity.No17 = 0; entity.No18 = 0; entity.No19 = 0; entity.No20 = 0; entity.No21 = 0; entity.No22 = 0; entity.No23 = 0; entity.No24 = 0; entity.No25 = 0; entity.No26 = 0; entity.No27 = 0; entity.No28 = 0; entity.No29 = 0; entity.No30 = 0; entity.No31 = 0; entity.IsDelete = 0; entity.Status = 0; entity.Code = RandomHelper.GetRandomizer(8, true, false, true, true); _dbContext.DataList.Add(entity); _dbContext.SaveChanges(); } var timelist = _dbContext.DataList.ToList(); for (int i = 0; i < planlist.ToArray().Length; i++) { //2021-04-08 - 2021-04-28 //首先保证 time1<=time2 DateTime day1 = Convert.ToDateTime(planlist[i].CompletionTime.Substring(0, 10)); DateTime day2 = Convert.ToDateTime(planlist[i].CompletionTime.Substring(13, 10)); if (day1 <= nowday && nowday <= day2) { while (day1 <= nowday) { daylist.Add(day1.ToString("yyyy-MM-dd")); day1 = day1.AddDays(1); } for (int days = 0; days < daylist.ToArray().Length; days++) { if (daylist[days].Substring(8, 2) == "01") { timelist[i].No1 = 1; } if (daylist[days].Substring(8, 2) == "02") { timelist[i].No2 = 1; } if (daylist[days].Substring(8, 2) == "03") { timelist[i].No3 = 1; } if (daylist[days].Substring(8, 2) == "04") { timelist[i].No4 = 1; } if (daylist[days].Substring(8, 2) == "05") { timelist[i].No5 = 1; } if (daylist[days].Substring(8, 2) == "06") { timelist[i].No6 = 1; } if (daylist[days].Substring(8, 2) == "07") { timelist[i].No7 = 1; } if (daylist[days].Substring(8, 2) == "08") { timelist[i].No8 = 1; } if (daylist[days].Substring(8, 2) == "09") { timelist[i].No9 = 1; } if (daylist[days].Substring(8, 2) == "10") { timelist[i].No10 = 1; } if (daylist[days].Substring(8, 2) == "11") { timelist[i].No11 = 1; } if (daylist[days].Substring(8, 2) == "12") { timelist[i].No12 = 1; } if (daylist[days].Substring(8, 2) == "13") { timelist[i].No13 = 1; } if (daylist[days].Substring(8, 2) == "14") { timelist[i].No14 = 1; } if (daylist[days].Substring(8, 2) == "15") { timelist[i].No15 = 1; } if (daylist[days].Substring(8, 2) == "16") { timelist[i].No16 = 1; } if (daylist[days].Substring(8, 2) == "17") { timelist[i].No17 = 1; } if (daylist[days].Substring(8, 2) == "18") { timelist[i].No18 = 1; } if (daylist[days].Substring(8, 2) == "19") { timelist[i].No19 = 1; } if (daylist[days].Substring(8, 2) == "20") { timelist[i].No20 = 1; } if (daylist[days].Substring(8, 2) == "21") { timelist[i].No21 = 1; } if (daylist[days].Substring(8, 2) == "22") { timelist[i].No22 = 1; } if (daylist[days].Substring(8, 2) == "23") { timelist[i].No23 = 1; } if (daylist[days].Substring(8, 2) == "24") { timelist[i].No24 = 1; } if (daylist[days].Substring(8, 2) == "25") { timelist[i].No25 = 1; } if (daylist[days].Substring(8, 2) == "26") { timelist[i].No26 = 1; } if (daylist[days].Substring(8, 2) == "27") { timelist[i].No27 = 1; } if (daylist[days].Substring(8, 2) == "28") { timelist[i].No28 = 1; } if (daylist[days].Substring(8, 2) == "29") { timelist[i].No29 = 1; } if (daylist[days].Substring(8, 2) == "30") { timelist[i].No30 = 1; } if (daylist[days].Substring(8, 2) == "31") { timelist[i].No31 = 1; } } } if (day1 <= nowday && nowday > day2) { while (day1 <= nowday) { daylist.Add(day1.ToString("yyyy-MM-dd")); day1 = day1.AddDays(1); } while (day2 <= nowday) { delaylist.Add(day2.ToString("yyyy-MM-dd")); day2 = day2.AddDays(1); } for (int days = 0; days < daylist.ToArray().Length; days++) { if (daylist[days].Substring(8, 2) == "01") { timelist[i].No1 = 1; } if (daylist[days].Substring(8, 2) == "02") { timelist[i].No2 = 1; } if (daylist[days].Substring(8, 2) == "03") { timelist[i].No3 = 1; } if (daylist[days].Substring(8, 2) == "04") { timelist[i].No4 = 1; } if (daylist[days].Substring(8, 2) == "05") { timelist[i].No5 = 1; } if (daylist[days].Substring(8, 2) == "06") { timelist[i].No6 = 1; } if (daylist[days].Substring(8, 2) == "07") { timelist[i].No7 = 1; } if (daylist[days].Substring(8, 2) == "08") { timelist[i].No8 = 1; } if (daylist[days].Substring(8, 2) == "09") { timelist[i].No9 = 1; } if (daylist[days].Substring(8, 2) == "10") { timelist[i].No10 = 1; } if (daylist[days].Substring(8, 2) == "11") { timelist[i].No11 = 1; } if (daylist[days].Substring(8, 2) == "12") { timelist[i].No12 = 1; } if (daylist[days].Substring(8, 2) == "13") { timelist[i].No13 = 1; } if (daylist[days].Substring(8, 2) == "14") { timelist[i].No14 = 1; } if (daylist[days].Substring(8, 2) == "15") { timelist[i].No15 = 1; } if (daylist[days].Substring(8, 2) == "16") { timelist[i].No16 = 1; } if (daylist[days].Substring(8, 2) == "17") { timelist[i].No17 = 1; } if (daylist[days].Substring(8, 2) == "18") { timelist[i].No18 = 1; } if (daylist[days].Substring(8, 2) == "19") { timelist[i].No19 = 1; } if (daylist[days].Substring(8, 2) == "20") { timelist[i].No20 = 1; } if (daylist[days].Substring(8, 2) == "21") { timelist[i].No21 = 1; } if (daylist[days].Substring(8, 2) == "22") { timelist[i].No22 = 1; } if (daylist[days].Substring(8, 2) == "23") { timelist[i].No23 = 1; } if (daylist[days].Substring(8, 2) == "24") { timelist[i].No24 = 1; } if (daylist[days].Substring(8, 2) == "25") { timelist[i].No25 = 1; } if (daylist[days].Substring(8, 2) == "26") { timelist[i].No26 = 1; } if (daylist[days].Substring(8, 2) == "27") { timelist[i].No27 = 1; } if (daylist[days].Substring(8, 2) == "28") { timelist[i].No28 = 1; } if (daylist[days].Substring(8, 2) == "29") { timelist[i].No29 = 1; } if (daylist[days].Substring(8, 2) == "30") { timelist[i].No30 = 1; } if (daylist[days].Substring(8, 2) == "31") { timelist[i].No31 = 1; } } for (int delays = 0; delays < delaylist.ToArray().Length; delays++) { if (delaylist[delays].Substring(8, 2) == "01") { timelist[i].No1 = 2; } if (delaylist[delays].Substring(8, 2) == "02") { timelist[i].No2 = 2; } if (delaylist[delays].Substring(8, 2) == "03") { timelist[i].No3 = 2; } if (delaylist[delays].Substring(8, 2) == "04") { timelist[i].No4 = 2; } if (delaylist[delays].Substring(8, 2) == "05") { timelist[i].No5 = 2; } if (delaylist[delays].Substring(8, 2) == "06") { timelist[i].No6 = 2; } if (delaylist[delays].Substring(8, 2) == "07") { timelist[i].No7 = 2; } if (delaylist[delays].Substring(8, 2) == "08") { timelist[i].No8 = 2; } if (delaylist[delays].Substring(8, 2) == "09") { timelist[i].No9 = 2; } if (delaylist[delays].Substring(8, 2) == "10") { timelist[i].No10 = 2; } if (delaylist[delays].Substring(8, 2) == "11") { timelist[i].No11 = 2; } if (delaylist[delays].Substring(8, 2) == "12") { timelist[i].No12 = 2; } if (delaylist[delays].Substring(8, 2) == "13") { timelist[i].No13 = 2; } if (delaylist[delays].Substring(8, 2) == "14") { timelist[i].No14 = 2; } if (delaylist[delays].Substring(8, 2) == "15") { timelist[i].No15 = 2; } if (delaylist[delays].Substring(8, 2) == "16") { timelist[i].No16 = 2; } if (delaylist[delays].Substring(8, 2) == "17") { timelist[i].No17 = 2; } if (delaylist[delays].Substring(8, 2) == "18") { timelist[i].No18 = 2; } if (delaylist[delays].Substring(8, 2) == "19") { timelist[i].No19 = 2; } if (delaylist[delays].Substring(8, 2) == "20") { timelist[i].No20 = 2; } if (delaylist[delays].Substring(8, 2) == "21") { timelist[i].No21 = 2; } if (delaylist[delays].Substring(8, 2) == "22") { timelist[i].No22 = 2; } if (delaylist[delays].Substring(8, 2) == "23") { timelist[i].No23 = 2; } if (delaylist[delays].Substring(8, 2) == "24") { timelist[i].No24 = 2; } if (delaylist[delays].Substring(8, 2) == "25") { timelist[i].No25 = 2; } if (delaylist[delays].Substring(8, 2) == "26") { timelist[i].No26 = 2; } if (delaylist[delays].Substring(8, 2) == "27") { timelist[i].No27 = 2; } if (delaylist[delays].Substring(8, 2) == "28") { timelist[i].No28 = 2; } if (delaylist[delays].Substring(8, 2) == "29") { timelist[i].No29 = 2; } if (delaylist[delays].Substring(8, 2) == "30") { timelist[i].No30 = 2; } if (delaylist[delays].Substring(8, 2) == "31") { timelist[i].No31 = 2; } } } } var response = ResponseModelFactory.CreateInstance; response.SetData(timelist); return(Ok(response)); } }