public ActionResult Edit(int?id) { BLL.BaseBLL <Entity.SysRole> bll = new BLL.BaseBLL <Entity.SysRole>(); if (id == null) { GetTree(); } else { GetTree(TypeHelper.ObjectToInt(id, 0)); } Entity.SysRole entity = new Entity.SysRole(); int num = TypeHelper.ObjectToInt(id, 0); if (num != 0) { entity = bll.GetModel(p => p.ID == num, null); if (entity == null) { return(PromptView("/admin/SysRole", "404", "Not Found", "信息不存在或已被删除", 5)); } } return(View(entity)); }
public JsonResult Restore(int id) { BLL.BaseBLL <Entity.SysDbBack> bll = new BLL.BaseBLL <Entity.SysDbBack>(); var entity = bll.GetModel(p => p.ID == id, null); if (entity == null) { WorkContext.AjaxStringEntity.msgbox = "备份信息不存在"; } else { string msg = ""; bool is_ok = new BLL.BLLSysDbBack().RestoreDb(entity, out msg); if (is_ok) { AddAdminLogs(Entity.SysLogMethodType.Resotre, "还原数据库:" + entity.FilePath); WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "还原成功"; } else { WorkContext.AjaxStringEntity.msgbox = msg; } } return(Json(WorkContext.AjaxStringEntity)); }
public ActionResult EditIOS(Entity.AppVersion entity) { var isAdd = entity.ID == 0 ? true : false; LoadPlatform(); BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>(); entity.Platforms = Entity.APPVersionPlatforms.IOS; entity.LogoImg = "null"; entity.MD5 = "null"; ModelState.Remove("LogoImg"); ModelState.Remove("MD5"); //数据验证 if (isAdd) { //判断版本是否存在 if (bll.Exists(p => p.Platforms == Entity.APPVersionPlatforms.IOS && p.APPType == entity.APPType && p.Version == entity.Version)) { ModelState.AddModelError("Version", "该版本存在"); } } else { if (bll.Exists(p => p.ID == entity.ID)) { return(PromptView("/admin/AppVersion", "404", "Not Found", "信息不存在或已被删除", 5)); } } if (ModelState.IsValid) { //添加 if (entity.ID == 0) { var new_ver = bll.GetModel(p => p.Platforms == Entity.APPVersionPlatforms.IOS && p.APPType == entity.APPType, "VersionCode desc"); entity.VersionCode = new_ver == null ? 1 : new_ver.VersionCode + 1; entity.AddTime = DateTime.Now; bll.Add(entity); } else //修改 { //var old_entity = db.AppVersions.Find(entity.ID); //db.Entry(old_entity).CurrentValues.SetValues(entity); bll.Modify(entity); } return(PromptView("/admin/AppVersion", "OK", "Success", "操作成功", 5)); } else { return(View(entity)); } }
public ActionResult Login(Models.ViewModelLogin viewModelLogin) { //登陆错误次数限制 if (Session[SessionKey.Login_Fail_Total] != null) { if (TypeHelper.ObjectToInt(Session[SessionKey.Login_Fail_Total]) > 3) { ModelState.AddModelError("user_name", "失败次数过多,重启浏览器后再试"); return(View(viewModelLogin)); } } if (ModelState.IsValid) { string passworld = SecureHelper.MD5(viewModelLogin.password); BLL.BaseBLL <Entity.SysUser> bll = new BLL.BaseBLL <Entity.SysUser>(); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); filters.Add(new BLL.FilterSearch("UserName", viewModelLogin.user_name, BLL.FilterSearchContract.等于)); filters.Add(new BLL.FilterSearch("Password", passworld, BLL.FilterSearchContract.等于)); Entity.SysUser model = bll.GetModel(filters, null, "SysRole.SysRoleRoutes.SysRoute"); if (model == null) { ModelState.AddModelError("user_name", "用户名或密码错误"); return(View(viewModelLogin)); } if (!model.Status) { ModelState.AddModelError("user_name", "用户已被禁用"); return(View(viewModelLogin)); } Session[SessionKey.Admin_User_Info] = model; Session.Timeout = 60; if (viewModelLogin.is_rember) { WebHelper.SetCookie(CookieKey.Is_Remeber, "1", 14400); WebHelper.SetCookie(CookieKey.Login_UserID, model.ID.ToString(), 14400); WebHelper.SetCookie(CookieKey.Login_UserPassword, model.Password, 14400); } else { WebHelper.SetCookie(CookieKey.Login_UserID, model.ID.ToString()); WebHelper.SetCookie(CookieKey.Login_UserPassword, model.Password); } model.LastLoginTime = DateTime.Now; bll.Modify(model, new string[] { "LastLoginTime" }); AddAdminLogs(Entity.SysLogMethodType.Login, "通过后台网页登陆", model.ID); return(RedirectToAction("Index", "Home")); } return(View(viewModelLogin)); }
public ActionResult Edit(Entity.SysRole entity) { var isAdd = entity.ID == 0 ? true : false; BLL.BaseBLL <Entity.SysRole> bll = new BLL.BaseBLL <Entity.SysRole>(); GetTree(entity.ID); var qx = WebHelper.GetFormString("hid_qx"); //数据验证 if (isAdd) { if (bll.Exists(p => p.RoleName == entity.RoleName)) { ModelState.AddModelError("RoleName", "该组名已存在"); } } else { if (!bll.Exists(p => p.ID == entity.ID)) { return(PromptView("/admin/SysRole", "404", "Not Found", "该组不存在或已被删除", 5)); } var old_entity = bll.GetModel(p => p.ID == entity.ID, null); //验证组名是否存在 if (old_entity.RoleName != entity.RoleName) { if (bll.Exists(p => p.RoleName == entity.RoleName)) { ModelState.AddModelError("RoleName", "该组名已存在"); } } } if (ModelState.IsValid) { BLL.BLLSysRole bll_role = new BLL.BLLSysRole(); if (entity.ID == 0)//添加 { bll_role.Add(entity, qx); } else //修改 { bll_role.Modify(entity, qx); } return(PromptView("/admin/SysRole", "OK", "Success", "操作成功", 5)); } else { return(View(entity)); } }
public ActionResult Info(int id) { BLL.BaseBLL <Entity.SysDbBack> bll = new BLL.BaseBLL <Entity.SysDbBack>(); var entity = bll.GetModel(p => p.ID == id, null, "AddUser"); if (entity == null) { return(PromptView("/admin/SysDbBack", "404", "Not Found", "信息不存在或已被删除", 5)); } return(View(entity)); }
public ActionResult Login() { var viewModelLogin = new Models.ViewModelLogin(); if (WorkContext.UserInfo != null) { return(RedirectToAction("Index")); } //如果保存了cookie,则为用户做自动登录 if (!string.IsNullOrWhiteSpace(WebHelper.GetCookie(CookieKey.Is_Remeber))) { if (WebHelper.GetCookie(CookieKey.Is_Remeber) == "1") { int uid = TypeHelper.ObjectToInt(WebHelper.GetCookie(CookieKey.Login_UserID)); string upwd = WebHelper.GetCookie(CookieKey.Login_UserPassword); BLL.BaseBLL <Entity.SysUser> bll = new BLL.BaseBLL <Entity.SysUser>(); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); filters.Add(new BLL.FilterSearch("ID", uid.ToString(), BLL.FilterSearchContract.等于)); filters.Add(new BLL.FilterSearch("Password", upwd, BLL.FilterSearchContract.等于)); Entity.SysUser model = bll.GetModel(filters, null, "SysRole.SysRoleRoutes.SysRoute"); if (model != null) { if (model.Status) { AddAdminLogs(Entity.SysLogMethodType.Login, "已记住密码,做自动登录", model.ID); Session[SessionKey.Admin_User_Info] = model; Session.Timeout = 60; //一小时不操作,session就过期 model.LastLoginTime = DateTime.Now; bll.Modify(model, new string[] { "LastLoginTime" }); return(RedirectToAction("Index")); } else { return(View(viewModelLogin)); } } else { return(View(viewModelLogin)); } } else { return(View(viewModelLogin)); } } return(View(viewModelLogin)); }
public ActionResult Edit(int?id) { BLL.BaseBLL <Entity.SysUser> bll = new BLL.BaseBLL <Entity.SysUser>(); Load(); Entity.SysUser entity = new Entity.SysUser(); int num = TypeHelper.ObjectToInt(id, 0); if (num != 0) { entity = bll.GetModel(p => p.ID == num, null); if (entity == null) { return(PromptView("/admin/SysUser", "404", "Not Found", "信息不存在或已被删除", 5)); } } return(View(entity)); }
public ActionResult EditAndroid(int?id) { int num = TypeHelper.ObjectToInt(id, 0); Entity.AppVersion entity = new Entity.AppVersion(); if (num != 0) { BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>(); entity = bll.GetModel(p => p.ID == num, null); if (entity == null) { return(PromptView("/admin/AppVersion", "404", "Not Found", "信息不存在或已被删除", 5)); } if (entity.Platforms != Entity.APPVersionPlatforms.Android) { return(PromptView("/admin/AppVersion", "400", "数据非法", "此信息非安卓版本", 5)); } } return(View(entity)); }
/// <summary> /// 获取树数据 /// </summary> /// <param name="id">当前组ID,没有传0</param> private void GetTree(int id = 0) { BLL.BaseBLL <Entity.SysRole> bll_route = new BLL.BaseBLL <Entity.SysRole>(); BLL.BaseBLL <Entity.SysRoleRoute> bll_role_route = new BLL.BaseBLL <Entity.SysRoleRoute>(); Entity.SysRole role = null; if (id != 0) { role = bll_route.GetModel(p => p.ID == id, null); } List <Models.ViewModelTree> list = new List <Models.ViewModelTree>(); var route_group = new BLL.BLLSysRoute().GetListGroupByTag(); for (int i = 0; i < route_group.Count; i++) { int top_id = i + 10000; Models.ViewModelTree model = new Models.ViewModelTree(); model.id = top_id; model.name = route_group[i].Key; model.open = i < 4 ? true : false; model.pId = 0; list.Add(model); foreach (var item in route_group[i].ToList()) { Models.ViewModelTree model2 = new Models.ViewModelTree(); model2.id = item.ID; model2.name = item.Desc; model2.open = false; model2.pId = top_id; if (role != null) { model2.is_checked = bll_role_route.Exists(p => p.SysRoleID == role.ID && p.SysRouteID == item.ID); } list.Add(model2); } } ViewData["Tree"] = JsonHelper.ToJson(list).Replace("is_checked", "checked"); }
public JsonResult UpdateRoute() { List <Models.ModelRoute> route_list = new List <Models.ModelRoute>(); #region 反射获取所有的控制路由 string path = IOHelper.GetMapPath("~/bin/Universal.Web.dll"); byte[] buffer = System.IO.File.ReadAllBytes(path); Assembly assembly = Assembly.Load(buffer); foreach (var type in assembly.ExportedTypes) { System.Reflection.MemberInfo[] properties = type.GetMembers(); foreach (var item in properties) { string controllerName = item.ReflectedType.Name.Replace("Controller", "").ToString(); string actionName = item.Name.ToString(); //访问路由 string route_map = controllerName.ToLower() + "/" + actionName.ToLower(); //是否是HttpPost请求 bool IsHttpPost = item.GetCustomAttributes(typeof(System.Web.Mvc.HttpPostAttribute), true).Count() > 0 ? true : false; object[] attrs = item.GetCustomAttributes(typeof(Framework.AdminPermissionAttribute), true); if (attrs.Length == 1) { Framework.AdminPermissionAttribute attr = (Framework.AdminPermissionAttribute)attrs[0]; route_list.Add(new Models.ModelRoute { Tag = attr.Tag, Desc = attr.Desc, IsPost = IsHttpPost, Route = route_map }); } } } #endregion BLL.BaseBLL <Entity.SysRoute> bll = new BLL.BaseBLL <Entity.SysRoute>(); var db_list = bll.GetListBy(0, new List <BLL.FilterSearch>(), null); foreach (var item in db_list) { var entity = route_list.Where(p => p.IsPost == item.IsPost && p.Route == item.Route).FirstOrDefault(); //如果数据库对应程序中不存在,则删除数据库里的 if (entity == null) { bll.Del(item); } else { //否则修改数据库里的DES之类的辅助说明 item.Desc = entity.Desc; item.Tag = entity.Tag; bll.Modify(item); } } foreach (var item in route_list) { var entity = bll.GetModel(p => p.IsPost == item.IsPost && p.Route == item.Route, null); if (entity == null) { var route = new Entity.SysRoute(); route.AddTime = DateTime.Now; route.Desc = item.Desc; route.IsPost = item.IsPost; route.Route = item.Route; route.Tag = item.Tag; bll.Add(route); } } AddAdminLogs(Entity.SysLogMethodType.Update, "更新权限数据"); WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "success"; return(Json(WorkContext.AjaxStringEntity)); }
public ActionResult Edit(Entity.SysUser entity) { var isAdd = entity.ID == 0 ? true : false; BLL.BaseBLL <Entity.SysUser> bll = new BLL.BaseBLL <Entity.SysUser>(); Load(); if (entity.SysRoleID == 0) { ModelState.AddModelError("SysRoleID", "请选择用户组"); } //数据验证 if (isAdd) { //判断用户名是否存在 if (!bll.Exists(p => p.UserName == entity.UserName)) { ModelState.AddModelError("UserName", "该用户名已存在"); } } else { //如果要编辑的用户不存在 if (!bll.Exists(p => p.ID == entity.ID)) { return(PromptView("/admin/SysUser", "404", "Not Found", "信息不存在或已被删除", 5)); } ModelState.Remove("UserName"); } if (ModelState.IsValid) { //添加 if (entity.ID == 0) { entity.RegTime = DateTime.Now; entity.Password = SecureHelper.MD5(entity.Password); entity.LastLoginTime = DateTime.Now; bll.Add(entity); } else //修改 { var user = bll.GetModel(p => p.ID == entity.ID, null); if (entity.Password != "litdev") { user.Password = SecureHelper.MD5(entity.Password); } user.NickName = entity.NickName; user.Gender = entity.Gender; user.Status = entity.Status; user.Avatar = entity.Avatar; user.SysRoleID = entity.SysRoleID; bll.Modify(user); } return(PromptView("/admin/SysUser", "OK", "Success", "操作成功", 5)); } else { return(View(entity)); } }