public ActionResult DelAdditionalData(int id, int page) { try { using (DataWallContext db = new DataWallContext()) { SysAdditionalData sysAdditionalData = new SysAdditionalData() { ID = id, DelState = 1, EditTime = DateTime.Now }; db.Entry(sysAdditionalData).State = EntityState.Modified; //不更新的字段 db.Entry(sysAdditionalData).Property(x => x.Type).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.PeopleNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.BookNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.StillPeopleNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.StillBookNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.DataDatetime).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.SysLibraryId).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.CrateTime).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.IsEnable).IsModified = false; db.SaveChanges(); int npage = 0; int Count = db.SysAdditionalDatas.Where(u => u.DelState == 0).Count(); double MaxPage = Convert.ToDouble(Convert.ToDouble(Count + 10) / Convert.ToDouble(10)); if (MaxPage > page) { npage = page; } else { if (Count <= 10) { npage = 1; } else { npage = page - 1; } } Lg.AddLog("删除额外数据", "Other", 3, GetUserName()); return(Json(new { code = "200", page = npage, msg = "删除成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("额外数据删除失败:" + ex.Message); return(Json(new { code = "201", msg = "删除失败,请重试或联/系管理员!" })); } }
public ActionResult UserEdit(FormCollection User) { try { if (Check("UserEdit", int.Parse(User["ID"]), User["UserName"])) { using (DataWallContext db = new DataWallContext()) { SysUser sysUser = new SysUser() { ID = int.Parse(User["ID"]), UserName = User["UserName"], Email = User["Email"], EditTime = DateTime.Now }; db.Entry(sysUser).State = EntityState.Modified; //修改密码 if (!string.IsNullOrEmpty(User["Password"])) { sysUser.Password = MD5Helper.MD5Encrypt32(User["Password"]); } //不修改密码 else { //不更新的字段 db.Entry(sysUser).Property(x => x.Password).IsModified = false; } //不更新的字段 db.Entry(sysUser).Property(x => x.CrateTime).IsModified = false; db.Entry(sysUser).Property(x => x.IsEnable).IsModified = false; db.Entry(sysUser).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改用户", "User", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } else { return(Json(new { code = "202", msg = "用户名已存在!" })); } } catch (Exception ex) { if (User.Count > 0) { LogHelper.ErrorLog("用户修改失败:" + ex.Message); } return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
public ActionResult EditEnable(int id, int enable) { try { using (DataWallContext db = new DataWallContext()) { SysLibrary sysLibrary = new SysLibrary() { ID = id, IsEnable = enable, EditTime = DateTime.Now }; db.Entry(sysLibrary).State = EntityState.Modified; //不更新的字段 db.Entry(sysLibrary).Property(x => x.LibraryName).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryDescribe).IsModified = false; db.Entry(sysLibrary).Property(x => x.Type).IsModified = false; db.Entry(sysLibrary).Property(x => x.City).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryCode).IsModified = false; db.Entry(sysLibrary).Property(x => x.CrateTime).IsModified = false; db.Entry(sysLibrary).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改场馆状态", "Library", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("场馆状态修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联/系管理员!" })); } }
public ActionResult CustDeviceEditEnable(int id, int enable) { try { using (DataWallContext db = new DataWallContext()) { SysCustDevice sysCustDevice = new SysCustDevice() { ID = id, IsEnable = enable, EditTime = DateTime.Now }; db.Entry(sysCustDevice).State = EntityState.Modified; //不更新的字段 db.Entry(sysCustDevice).Property(x => x.CustDeviceName).IsModified = false; db.Entry(sysCustDevice).Property(x => x.Uuid).IsModified = false; db.Entry(sysCustDevice).Property(x => x.DataGuid).IsModified = false; db.Entry(sysCustDevice).Property(x => x.SysLibraryId).IsModified = false; db.Entry(sysCustDevice).Property(x => x.CrateTime).IsModified = false; db.Entry(sysCustDevice).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改客流设备状态", "Other", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("客流设备状态修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联/系管理员!" })); } }
public ActionResult DelLibrary(int id, int page) { try { using (DataWallContext db = new DataWallContext()) { SysLibrary sysLibrary = new SysLibrary() { ID = id, DelState = 1, EditTime = DateTime.Now }; db.Entry(sysLibrary).State = EntityState.Modified; //不更新的字段 db.Entry(sysLibrary).Property(x => x.LibraryName).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryDescribe).IsModified = false; db.Entry(sysLibrary).Property(x => x.Type).IsModified = false; db.Entry(sysLibrary).Property(x => x.City).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryCode).IsModified = false; db.Entry(sysLibrary).Property(x => x.CrateTime).IsModified = false; db.Entry(sysLibrary).Property(x => x.IsEnable).IsModified = false; db.SaveChanges(); int npage = 0; int Count = db.SysLibrarys.Where(u => u.DelState == 0).AsNoTracking().Count(); double MaxPage = Convert.ToDouble(Convert.ToDouble(Count + 10) / Convert.ToDouble(10)); if (MaxPage > page) { npage = page; } else { if (Count <= 10) { npage = 1; } else { npage = page - 1; } } Lg.AddLog("删除场馆", "Library", 3, GetUserName()); return(Json(new { code = "200", page = npage, msg = "删除成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("场馆删除失败:" + ex.Message); return(Json(new { code = "201", msg = "删除失败,请重试或联/系管理员!" })); } }
public ActionResult EditModule(string Set, int Id) { try { using (DataWallContext db = new DataWallContext()) { var Module = db.SysThemeSets.Where(m => m.SysLibraryId == Id).AsNoTracking().FirstOrDefault(); if (Module != null) { SysThemeSet sysModule = new SysThemeSet() { ID = Module.ID, SysSeting = Set, EditTime = DateTime.Now, }; db.Entry(sysModule).State = EntityState.Modified; //不更新的字段 db.Entry(sysModule).Property(x => x.SysStyle).IsModified = false; db.Entry(sysModule).Property(x => x.SysLibraryId).IsModified = false; db.Entry(sysModule).Property(x => x.CrateTime).IsModified = false; db.Entry(sysModule).Property(x => x.IsEnable).IsModified = false; db.Entry(sysModule).Property(x => x.DelState).IsModified = false; db.SaveChanges(); } else { SysThemeSet sysModule = new SysThemeSet() { SysStyle = 1, SysSeting = Set, SysLibraryId = Id, CrateTime = DateTime.Now, EditTime = DateTime.Now, IsEnable = 0, DelState = 0 }; db.SysThemeSets.Add(sysModule); //添加 db.SaveChanges(); } Lg.AddLog("修改主题", "Module", 2, GetUserName()); //推送更新 PushUpdate(Id, "主题更新", 6); return(Json(new { code = "200", msg = "修改成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("内容状态修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联/系管理员!" })); } }
public ActionResult AdditionalDataEditEnable(int id, int enable) { try { using (DataWallContext db = new DataWallContext()) { SysAdditionalData sysAdditionalData = new SysAdditionalData() { ID = id, IsEnable = enable, EditTime = DateTime.Now }; db.Entry(sysAdditionalData).State = EntityState.Modified; //不更新的字段 db.Entry(sysAdditionalData).Property(x => x.Type).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.PeopleNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.BookNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.StillPeopleNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.StillBookNum).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.DataDatetime).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.SysLibraryId).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.CrateTime).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改额外数据状态", "Other", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("额外数据状态修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联/系管理员!" })); } }
public ActionResult CustDeviceEdit(FormCollection CustDevice) { try { using (DataWallContext db = new DataWallContext()) { //当前用户可管理场馆 List <SysLibrary> libList = GetLibraryList(); if (libList.Count == 0) { return(Json(new { code = "202", msg = "当前用户未分配可管理场馆,请联系系统管理员!" })); } ViewData["datalist"] = libList; //客流设备 if (CustDevice["Library"] != null) { SysCustDevice sysCustDevice = new SysCustDevice() { ID = int.Parse(CustDevice["ID"]), CustDeviceName = CustDevice["CustDeviceName"], SysLibraryId = int.Parse(CustDevice["Library"]), EditTime = DateTime.Now }; db.Entry(sysCustDevice).State = EntityState.Modified; //不更新的字段 db.Entry(sysCustDevice).Property(x => x.Uuid).IsModified = false; db.Entry(sysCustDevice).Property(x => x.DataGuid).IsModified = false; db.Entry(sysCustDevice).Property(x => x.CrateTime).IsModified = false; db.Entry(sysCustDevice).Property(x => x.IsEnable).IsModified = false; db.Entry(sysCustDevice).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改客流设备", "Other", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } else { return(Json(new { code = "202", msg = "请选择内容所属场馆!" })); } } } catch (Exception ex) { LogHelper.ErrorLog("客流设备修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
public ActionResult EditEnable(int id, int enable) { try { using (DataWallContext db = new DataWallContext()) { string RoleName = ""; foreach (var item in db.SysUsers.AsNoTracking().FirstOrDefault(u => u.ID == id).SysUserRoles) { RoleName = item.SysRole.RoleName; } if (RoleName != "Administrator") { SysUser sysUser = new SysUser() { ID = id, IsEnable = enable, EditTime = DateTime.Now }; db.Entry(sysUser).State = EntityState.Modified; //不更新的字段 db.Entry(sysUser).Property(x => x.UserName).IsModified = false; db.Entry(sysUser).Property(x => x.Email).IsModified = false; db.Entry(sysUser).Property(x => x.Password).IsModified = false; db.Entry(sysUser).Property(x => x.CrateTime).IsModified = false; db.Entry(sysUser).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改用户状态", "User", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } else { LogHelper.ErrorLog("管理员状态修改失败"); return(Json(new { code = "201", msg = "超级管理员用户不可进行该操作!" })); } } } catch (Exception ex) { LogHelper.ErrorLog("用户状态修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联/系管理员!" })); } }
public ActionResult DelLibraryAll(string idList, int page) { try { using (DataWallContext db = new DataWallContext()) { //获取待删除场馆id集 string[] sArray = idList.Split(','); int[] IdList = new int[sArray.Length]; for (int i = 0; i < sArray.Length; i++) { IdList[i] = Int32.Parse(sArray[i]); } for (int i = 0; i < IdList.Length; i++) { int id = IdList[i]; SysLibrary sysLibrary = new SysLibrary() { ID = id, DelState = 1, EditTime = DateTime.Now }; db.Entry(sysLibrary).State = EntityState.Modified; //不更新的字段 db.Entry(sysLibrary).Property(x => x.LibraryName).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryDescribe).IsModified = false; db.Entry(sysLibrary).Property(x => x.Type).IsModified = false; db.Entry(sysLibrary).Property(x => x.City).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryCode).IsModified = false; db.Entry(sysLibrary).Property(x => x.CrateTime).IsModified = false; db.Entry(sysLibrary).Property(x => x.IsEnable).IsModified = false; db.SaveChanges(); } int npage = 0; int Count = db.SysLibrarys.Where(u => u.DelState == 0).AsNoTracking().Count(); double MaxPage = Convert.ToDouble(Convert.ToDouble(Count + 10) / Convert.ToDouble(10)); if (MaxPage > page) { npage = page; } else { if (Count <= 10) { npage = 1; } else { if ((Count % 10) <= page) { npage = page - 1; } } } Lg.AddLog("删除场馆", "User", 3, GetUserName()); return(Json(new { code = "200", page = npage, msg = "删除成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("场馆删除失败:" + ex.Message); return(Json(new { code = "201", msg = "删除失败,请重试或联/系管理员!" })); } }
public ActionResult LibraryEdit(FormCollection Library) { try { if (Check("LibraryEdit", int.Parse(Library["ID"]), Library["LibraryName"])) { using (DataWallContext db = new DataWallContext()) { int LbraryId = int.Parse(Library["ID"]); int Type = int.Parse(Library["Type"]); SysProgramInfo sysProgramInfo = db.SysProgramInfos.AsNoTracking().FirstOrDefault(); List <SysLibrary> sysLibraryList = db.SysLibrarys.AsNoTracking().Where(s => s.DelState == 0).ToList(); switch (Type) { case 0: if (sysLibraryList.Where(s => s.Type == 0).Count() >= sysProgramInfo.MasterNum) { if (sysLibraryList.Where(s => s.Type == 0 & s.ID == LbraryId & s.DelState == 0).Count() < 1) { return(Json(new { code = "202", msg = "总馆数量已达上限" })); } } break; case 1: if (sysLibraryList.Where(s => s.Type == 1).Count() >= sysProgramInfo.BranchNum) { if (sysLibraryList.Where(s => s.Type == 1 & s.ID == LbraryId & s.DelState == 0).Count() < 1) { return(Json(new { code = "202", msg = "分馆数量已达上限" })); } } break; } //场馆 int FatherLibraryId = 0; if (Type == 0) { FatherLibraryId = 0; } else { if (Library["FatherLibraryId"] == null) { return(Json(new { code = "201", msg = "请选择上级场馆" })); } FatherLibraryId = int.Parse(Library["FatherLibraryId"]); if (int.Parse(Library["ID"]) == FatherLibraryId) { return(Json(new { code = "202", msg = "不可以选择自身为上级场馆" })); } } string LibraryName = Library["LibraryName"]; string LibraryCode = PingYinHelper.GetFirstSpell(Library["LibraryName"]) + DateTime.Now.Millisecond; SysLibrary sysLibrary = new SysLibrary() { ID = LbraryId, LibraryName = Library["LibraryName"], LibraryDescribe = HttpUtility.UrlDecode(Library["Describe"]).Replace("'", "‘"), FatherLibraryId = FatherLibraryId, Type = int.Parse(Library["Type"]), EditTime = DateTime.Now }; db.Entry(sysLibrary).State = EntityState.Modified; //不更新的字段 db.Entry(sysLibrary).Property(x => x.City).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryCode).IsModified = false; db.Entry(sysLibrary).Property(x => x.CrateTime).IsModified = false; db.Entry(sysLibrary).Property(x => x.IsEnable).IsModified = false; db.Entry(sysLibrary).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改场馆", "Library", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } else { return(Json(new { code = "202", msg = "场馆已存在!" })); } } catch (Exception ex) { if (Library.Count > 0) { LogHelper.ErrorLog("场馆修改失败:" + ex.Message); } return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
public ActionResult AdditionalDataEdit(FormCollection AdditionalData) { try { using (DataWallContext db = new DataWallContext()) { //当前用户可管理场馆 List <SysLibrary> libList = GetLibraryList(); if (libList.Count == 0) { return(Json(new { code = "202", msg = "当前用户未分配可管理场馆,请联系系统管理员!" })); } ViewData["datalist"] = libList; //额外数据 if (AdditionalData["Library"] != null) { int BookNum = 0; int StillPeopleNum = 0; int StillBookNum = 0; int LibraryId = int.Parse(AdditionalData["Library"]); string ToLibraryName = db.SysLibrarys.Find(LibraryId).LibraryName; if (AdditionalData["Type"] == "0") { BookNum = 0; StillPeopleNum = 0; StillPeopleNum = 0; int type = 3; var msg = "客流数据更新"; MyHub.Show(ToLibraryName, JsonConvert.SerializeObject(new { msg = msg, action = "Other", type = type })); } else { BookNum = int.Parse(AdditionalData["BookNum"]); StillPeopleNum = int.Parse(AdditionalData["StillPeopleNum"]); StillBookNum = int.Parse(AdditionalData["StillBookNum"]); int type = 4; var msg = "借还数据更新"; MyHub.Show(ToLibraryName, JsonConvert.SerializeObject(new { msg = msg, action = "Other", type = type })); } SysAdditionalData sysAdditionalData = new SysAdditionalData() { ID = int.Parse(AdditionalData["ID"]), PeopleNum = int.Parse(AdditionalData["PeopleNum"]), BookNum = BookNum, StillPeopleNum = StillPeopleNum, StillBookNum = StillBookNum, DataDatetime = DateTime.Parse(AdditionalData["DataDatetime"]), SysLibraryId = int.Parse(AdditionalData["Library"]), EditTime = DateTime.Now }; db.Entry(sysAdditionalData).State = EntityState.Modified; //不更新的字段 db.Entry(sysAdditionalData).Property(x => x.Type).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.CrateTime).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.IsEnable).IsModified = false; db.Entry(sysAdditionalData).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改额外数据", "Other", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } else { return(Json(new { code = "202", msg = "请选择内容所属场馆!" })); } } } catch (Exception ex) { LogHelper.ErrorLog("额外数据修改失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
public ActionResult DelUserAll(string idList, int page) { try { using (DataWallContext db = new DataWallContext()) { //获取待删除用户id集 string[] sArray = idList.Split(','); int[] IdList = new int[sArray.Length]; for (int i = 0; i < sArray.Length; i++) { IdList[i] = Int32.Parse(sArray[i]); } for (int i = 0; i < IdList.Length; i++) { int id = IdList[i]; string RoleName = ""; foreach (var item in db.SysUsers.AsNoTracking().FirstOrDefault(u => u.ID == id).SysUserRoles) { RoleName = item.SysRole.RoleName; } if (RoleName != "Administrator") { SysUser sysUser = new SysUser() { ID = id, DelState = 1, EditTime = DateTime.Now }; db.Entry(sysUser).State = EntityState.Modified; //不更新的字段 db.Entry(sysUser).Property(x => x.ID).IsModified = false; db.Entry(sysUser).Property(x => x.UserName).IsModified = false; db.Entry(sysUser).Property(x => x.Email).IsModified = false; db.Entry(sysUser).Property(x => x.Password).IsModified = false; db.Entry(sysUser).Property(x => x.CrateTime).IsModified = false; db.Entry(sysUser).Property(x => x.IsEnable).IsModified = false; db.SaveChanges(); } } int npage = 0; int Count = db.SysUsers.Where(u => u.DelState == 0).AsNoTracking().Count(); double MaxPage = Convert.ToDouble(Convert.ToDouble(Count + 10) / Convert.ToDouble(10)); if (MaxPage > page) { npage = page; } else { if (Count <= 10) { npage = 1; } else { if ((Count % 10) <= page) { npage = page - 1; } } } Lg.AddLog("删除用户", "User", 3, GetUserName()); return(Json(new { code = "200", page = npage, msg = "删除成功!" })); } } catch (Exception ex) { LogHelper.ErrorLog("用户删除失败:" + ex.Message); return(Json(new { code = "201", msg = "删除失败,请重试或联/系管理员!" })); } }
public ActionResult DelUser(int id, int page) { try { using (DataWallContext db = new DataWallContext()) { string RoleName = ""; foreach (var item in db.SysUsers.AsNoTracking().FirstOrDefault(u => u.ID == id).SysUserRoles) { RoleName = item.SysRole.RoleName; } if (RoleName != "Administrator") { SysUser sysUser = new SysUser() { ID = id, DelState = 1, EditTime = DateTime.Now }; db.Entry(sysUser).State = EntityState.Modified; //不更新的字段 db.Entry(sysUser).Property(x => x.UserName).IsModified = false; db.Entry(sysUser).Property(x => x.Email).IsModified = false; db.Entry(sysUser).Property(x => x.Password).IsModified = false; db.Entry(sysUser).Property(x => x.CrateTime).IsModified = false; db.Entry(sysUser).Property(x => x.IsEnable).IsModified = false; db.SaveChanges(); int npage = 0; int Count = db.SysUsers.Where(u => u.DelState == 0).AsNoTracking().Count(); double MaxPage = Convert.ToDouble(Convert.ToDouble(Count + 10) / Convert.ToDouble(10)); if (MaxPage > page) { npage = page; } else { if (Count <= 10) { npage = 1; } else { npage = page - 1; } } Lg.AddLog("删除用户", "User", 3, GetUserName()); return(Json(new { code = "200", page = npage, msg = "删除成功!" })); } else { LogHelper.ErrorLog("管理员删除失败"); return(Json(new { code = "201", msg = "超级管理员用户不可进行该操作!" })); } } } catch (Exception ex) { LogHelper.ErrorLog("用户删除失败:" + ex.Message); return(Json(new { code = "201", msg = "删除失败,请重试或联/系管理员!" })); } }