/// <summary> /// 验证管理员权限 /// </summary> /// <param name="PageKey">页面标示符 /controller/action 小写</param> /// <returns></returns> protected bool CheckAdminPower(string PageKey, bool isPost) { if (string.IsNullOrWhiteSpace(PageKey)) { isPost = WorkContext.IsHttpPost; PageKey = WorkContext.PageKey; } PageKey = PageKey.ToLower(); if (WorkContext.UserInfo.SysRole.IsAdmin) { return(true); } var result = true; BLL.BaseBLL <Entity.SysRoute> bll = new BLL.BaseBLL <Entity.SysRoute>(); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); filters.Add(new BLL.FilterSearch("IsPost", isPost.ToString(), BLL.FilterSearchContract.等于)); filters.Add(new BLL.FilterSearch("Route", PageKey, BLL.FilterSearchContract.等于)); if (bll.Exists(filters)) { var entity = WorkContext.UserInfo.SysRole.SysRoleRoutes.Where(p => p.SysRoute.Route == PageKey && p.SysRoute.IsPost == isPost).FirstOrDefault(); result = entity == null ? false : true; } return(result); }
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)); }
/// <summary> /// 异步添加异常日志到数据库 /// </summary> /// <param name="ex">异常信息</param> /// <returns></returns> public static void ToInDB(Exception ex) { Tools.WebSiteModel model = Tools.ConfigHelper.LoadConfig <Tools.WebSiteModel>(Tools.ConfigFileEnum.SiteConfig); if (!model.LogExceptionInDB) { return; } var entity = new Entity.SysLogException() { AddTime = DateTime.Now, Message = ex.Message, Source = ex.Source, StackTrace = ex.StackTrace }; new System.Threading.Thread(new System.Threading.ThreadStart(delegate() { BLL.BaseBLL <Entity.SysLogException> bll = new BLL.BaseBLL <Entity.SysLogException>(); bll.Add(entity); })) { IsBackground = true }.Start(); }
/// <summary> /// (已弃用) /// </summary> /// <param name="idex">页码</param> /// <param name="sizePage">页容量</param> /// <param name="ContentLength">内容截取长度</param> /// <returns></returns> public object Get(int idex, int sizePage, int ContentLength) { int total; BLL.BaseBLL <BlogInfo> blog = new BLL.BaseBLL <BlogInfo>(); var bloglist = blog.GetList(idex, sizePage, out total, t => t.IsShowHome == true, false, t => t.BlogCreateTime, false, tableName: t => t.User)// .ToList() .Select(t => new BlogInfo() { Id = t.Id, Title = t.Title, Content = MyHtmlHelper.GetHtmlText(t.Content, ContentLength), BlogCreateTime = t.BlogCreateTime, User = new BlogUser() { UserName = t.User.UserName, UserNickname = t.User.UserNickname }, ReadNum = t.ReadNum, CommentNum = t.CommentNum }).ToList(); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("blog", bloglist); dic.Add("total", total); //dic.Add("users", CacheData.GetAllUserInfo().Where(t => t.IsLock == false).ToList()); //dic.Add("SessionUser", BLL.Common.BLLSession.UserInfoSessioin); return(dic); }
private int GetTagId(string tagname, string userName) { BLL.BaseBLL <BlogTag> blogtag = new BLL.BaseBLL <BlogTag>(); try { var blogtagmode = blogtag.GetList(t => t.TagName == tagname); if (blogtagmode.Count() >= 1) { return(blogtagmode.FirstOrDefault().Id); } else { var tmepUserid = GetUserId(userName); var user = new BLL.BaseBLL <BlogUser>().GetList(t => t.Id == tmepUserid, isAsNoTracking: false).FirstOrDefault(); blogtag.Insert(new BlogTag() { TagName = tagname, IsDelte = false, BlogUser = user// new BlogUser { Id = GetUserId(userName), IsLock = false, BlogUserInfo = new BlogUserInfo() }, }); blogtag.save(); return(GetTagId(tagname, userName)); } } catch (Exception ex) { throw; return(-1); } }
private void SaveReadNum(BlogInfo blogobj, string md5) { LogSave.TrackLogSave(GetUserDistinguish(Request, false), "ReadBlogLog"); var isup = true; BLL.BaseBLL <BlogInfo> blogbll = new BLL.BaseBLL <BlogInfo>(); var blogtemp = blogbll.GetList(t => t.Id == blogobj.Id, isAsNoTracking: false).FirstOrDefault(); if (blogtemp.ReadNum == null) { blogtemp.ReadNum = 1; } else if (!IsRead(blogtemp, md5)) { blogtemp.ReadNum++; } else { isup = false; } if (isup) { blogbll.save(); } }
/// <summary> /// 检查 这个 url地址 是否被添加过 /// </summary> /// <param name="url"></param> /// <returns></returns> private bool IsAreBlog(string url) { BLL.BaseBLL <BlogInfo> blog = new BLL.BaseBLL <BlogInfo>(); var blogs = blog.GetList(t => t.Url == url); return(blogs.Count() >= 1); }
/// <summary> /// 自定义 特殊页面 公共方法 (弃用) /// </summary> /// <param name="str"></param> /// <param name="messid"></param> private void Forum(string str, ref int messid) { #region 检测是否存在 admin 用户 if (adminuserid <= 0) { BLL.BaseBLL <BlogUser> userbll = new BLL.BaseBLL <BlogUser>(); var user = userbll.GetList(t => t.UserName == admin).FirstOrDefault(); if (null == user) { var usertemp = new BlogUser() { UserName = admin, UserPass = "******".MD5().MD5(), IsDelte = false, IsLock = false, UserNickname = "", BlogUserInfo = new BlogUserInfo() }; userbll.Insert(usertemp); userbll.save(false); adminuserid = usertemp.Id; } else { adminuserid = user.Id; } } #endregion #region 是否存在 自定义 特殊页面 (返回 blogid) if (messid == 0) { BLL.BaseBLL <BlogInfo> blogbll = new BLL.BaseBLL <BlogInfo>(); var blog = blogbll.GetList(t => t.Title == str).FirstOrDefault(); if (null == blog) { var blogtemp = new BlogInfo() { Id = 0, User = new BlogUser() { Id = adminuserid }, IsDelte = false, Title = str }; blogbll.Insert(blogtemp); blogbll.save(false); //GetDataHelper.GetAllUserInfo(true);//更新缓存 messid = blogtemp.Id; } else { messid = blog.Id; } } #endregion }
public ActionResult Index(int page = 1, string word = "", int type = 0) { LoadType(); word = WebHelper.UrlDecode(word); Models.ViewModelSysDbBack response_model = new Models.ViewModelSysDbBack(); response_model.page = page; response_model.word = word; response_model.type = type; //获取每页大小的Cookie response_model.page_size = TypeHelper.ObjectToInt(WebHelper.GetCookie(WorkContext.PageKeyCookie), SiteKey.AdminDefaultPageSize); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); if (type != 0) { filters.Add(new BLL.FilterSearch("BackType", type.ToString(), BLL.FilterSearchContract.等于)); } if (!string.IsNullOrWhiteSpace(word)) { filters.Add(new BLL.FilterSearch("DbName", word, BLL.FilterSearchContract.like)); filters.Add(new BLL.FilterSearch("BackName", word, BLL.FilterSearchContract.like)); } int total = 0; BLL.BaseBLL <Entity.SysDbBack> bll = new BLL.BaseBLL <Entity.SysDbBack>(); List <Entity.SysDbBack> list = bll.GetPagedList(page, response_model.page_size, ref total, filters, "AddTime desc"); response_model.DataList = list; response_model.total = total; response_model.total_page = CalculatePage(total, response_model.page_size); return(View(response_model)); }
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 ActionResult Index(int page = 1, string word = "") { word = WebHelper.UrlDecode(word); Models.ViewModelSysRoleList response_model = new Models.ViewModelSysRoleList(); response_model.page = page; response_model.word = word; //获取每页大小的Cookie response_model.page_size = TypeHelper.ObjectToInt(WebHelper.GetCookie(WorkContext.PageKeyCookie), SiteKey.AdminDefaultPageSize); int total = 0; List <BLL.FilterSearch> filter = new List <BLL.FilterSearch>(); if (!string.IsNullOrWhiteSpace(word)) { filter.Add(new BLL.FilterSearch("RoleName", word, BLL.FilterSearchContract.like)); } BLL.BaseBLL <Entity.SysRole> bll = new BLL.BaseBLL <Entity.SysRole>(); var list = bll.GetPagedList(page, response_model.page_size, ref total, filter, "AddTime desc"); response_model.DataList = list; response_model.total = total; response_model.total_page = CalculatePage(total, response_model.page_size); return(View(response_model)); }
public JsonResult DelException(string ids) { if (string.IsNullOrWhiteSpace(ids)) { WorkContext.AjaxStringEntity.msgbox = "缺少参数"; return(Json(WorkContext.AjaxStringEntity)); } BLL.BaseBLL <Entity.SysLogException> bll = new BLL.BaseBLL <Entity.SysLogException>(); if ("all".Equals(ids.ToLower())) { bll.DelBy(new List <BLL.FilterSearch>()); AddAdminLogs(Entity.SysLogMethodType.Delete, "清空异常日志"); } else { int id = TypeHelper.ObjectToInt(ids); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); filters.Add(new BLL.FilterSearch("ID", id.ToString(), BLL.FilterSearchContract.等于)); bll.DelBy(filters); AddAdminLogs(Entity.SysLogMethodType.Delete, "删除异常日志:" + id.ToString()); } WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "success"; return(Json(WorkContext.AjaxStringEntity)); }
public ActionResult Index(int page = 1, int platform = 0) { LoadPlatform(); Models.ViewModelAppVersion response_model = new Models.ViewModelAppVersion(); response_model.page = page; response_model.platform = platform; //获取每页大小的Cookie response_model.page_size = TypeHelper.ObjectToInt(WebHelper.GetCookie(WorkContext.PageKeyCookie), SiteKey.AdminDefaultPageSize); List <BLL.FilterSearch> filters = new List <BLL.FilterSearch>(); if (platform != 0) { filters.Add(new BLL.FilterSearch("Platforms", platform.ToString(), BLL.FilterSearchContract.等于)); } int total = 0; BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>(); List <Entity.AppVersion> list = bll.GetPagedList(page, response_model.page_size, ref total, filters, "AddTime desc"); response_model.DataList = list; response_model.total = total; response_model.total_page = CalculatePage(total, response_model.page_size); return(View(response_model)); }
private void MyBegin() { try { //设置日志存放路径 LogConfig.logFilePath = HttpContext.Current.Server.MapPath("~/") + @"\Log\"; Blogs.Helper.FileHelper.defaultpath = HttpContext.Current.Server.MapPath("~/"); BLL.BaseBLL <BlogUser> userbll = new BLL.BaseBLL <BlogUser>(); var isbegin = userbll.GetList(t => true).Count() > 0; if (!isbegin) { var user = new BlogUser() { UserName = "******", UserPass = "******", IsDelte = false, IsLock = false, UserMail = "无效", CreationTime = DateTime.Now, BlogUserInfo = new BlogUserInfo() }; userbll.Insert(user); userbll.save(false); } DemoController.GetData(); } catch (Exception) { } }
private static int GetTagId(string tagname, int userid) { BLL.BaseBLL <BlogTag> blogtag = new BaseBLL <BlogTag>(); try { var blogtagmode = blogtag.GetList(t => t.TagName == tagname); if (blogtagmode.Count() >= 1) { return(blogtagmode.FirstOrDefault().Id); } else { var user = new BLL.BaseBLL <BlogUser>().GetList(t => t.Id == userid, isAsNoTracking: false).FirstOrDefault(); blogtag.Insert(new BlogTag() { TagName = tagname, IsDelte = false, BlogUser = user }); blogtag.save(); return(GetTagId(tagname, userid)); } } catch (Exception ex) { return(-1); } }
public JsonResult Del(string ids) { int id = TypeHelper.ObjectToInt(ids); if (id <= 0) { WorkContext.AjaxStringEntity.msgbox = "非法参数"; return(Json(WorkContext.AjaxStringEntity)); } string str = BLL.BLLCusCategory.GetChildIDStr(TypeHelper.ObjectToInt(ids)); if (string.IsNullOrWhiteSpace(str)) { WorkContext.AjaxStringEntity.msgbox = "找不到相关数据"; return(Json(WorkContext.AjaxStringEntity)); } BLL.BaseBLL <Entity.CusCategory> bll = new BLL.BaseBLL <Entity.CusCategory>(); var id_list = Array.ConvertAll <string, int>(str.Split(','), int.Parse); bll.DelBy(p => id_list.Contains(p.ID)); AddAdminLogs(Entity.SysLogMethodType.Delete, "删除分类:" + str); WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "success"; return(Json(WorkContext.AjaxStringEntity)); }
/// <summary> /// 自定义 特殊页面 公共方法 /// </summary> /// <param name="str">BlogTitle名字</param> /// <param name="pageName">存在MyPageId的KEY名</param> private void Forum(string str, string pageName) { #region 检测是否存在 admin 用户 BLL.BaseBLL <BlogUser> userbll = new BLL.BaseBLL <BlogUser>(); if (adminuserid <= 0) { var user = userbll.GetList(t => t.UserName == admin).FirstOrDefault(); if (null == user) { var usertemp = new BlogUser() { UserName = admin, UserPass = "******".MD5().MD5(), IsDelte = false, IsLock = false, UserNickname = "", UserMail = "无效", BlogUserInfo = new BlogUserInfo() }; userbll.Insert(usertemp); userbll.save(false); adminuserid = usertemp.Id; } else { adminuserid = user.Id; } } #endregion #region 是否存在 自定义 特殊页面 (返回 blogid) if (MyPageId[pageName] == 0) { BLL.BaseBLL <BlogInfo> blogbll = new BLL.BaseBLL <BlogInfo>(); var blog = blogbll.GetList(t => t.Title == str).FirstOrDefault(); if (null == blog) { var bloguser = userbll.GetList(t => t.Id == adminuserid, isAsNoTracking: false).FirstOrDefault(); var blogtemp = new BlogInfo() { Id = 0, //BlogUser = new BlogUser() { Id = adminuserid }, User = bloguser, IsDelte = false, Title = str }; blogbll.Insert(blogtemp); blogbll.save(); // CacheData.GetAllUserInfo(true);//更新缓存 MyPageId[pageName] = blogtemp.Id; } else { MyPageId[pageName] = blog.Id; } } #endregion }
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)); }
/// <summary> /// 加载所有分类 /// </summary> /// <returns></returns> public List <Entity.CusCategory> LoadCategory() { BLL.BaseBLL <Entity.CusCategory> bll = new BLL.BaseBLL <Entity.CusCategory>(); var oldData = bll.GetListBy(0, new List <BLL.FilterSearch>(), "SortNo Desc"); List <Entity.CusCategory> newData = new List <Entity.CusCategory>(); GetChilds(oldData, newData, null); foreach (var item in newData) { item.Title = StringHelper.StringOfChar(item.Depth - 1, " ") + "├ " + StringHelper.StringOfChar(item.Depth - 1, " ") + item.Title; } return(newData); }
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)); }
/// <summary> /// 根据博客ID 取评论内容 /// </summary> /// <param name="blogId">博客id</param> /// <param name="index">页码</param> /// <param name="sizePage">页容量</param> /// <param name="order">升序:true 降序:false</param> /// <returns></returns> public object GetComment(int blogId, int index, int sizePage, bool order) { int total; BLL.BaseBLL <BlogComment> comment = new BLL.BaseBLL <BlogComment>(); var commentList = comment.GetList(index, sizePage, out total, t => t.BlogInfo.Id == blogId, false, t => t.Id, order) .ToList().Select(t => new BlogComment() { }); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("CommentList", commentList); dic.Add("Total", total);//总页数 return(dic); }
public ActionResult LogMethod(int page = 1, int type = 0, string word = "") { List <SelectListItem> typeList = new List <SelectListItem>(); typeList.Add(new SelectListItem() { Text = "所有日志", Value = "0" }); foreach (var item in EnumHelper.BEnumToDictionary(typeof(Entity.SysLogMethodType))) { string text = EnumHelper.GetDescription <Entity.SysLogMethodType>((Entity.SysLogMethodType)item.Key); typeList.Add(new SelectListItem() { Text = text, Value = item.Key.ToString() }); } ViewData["LogMethod_Type"] = typeList; word = WebHelper.UrlDecode(word); Models.ViewModelLogMethod response_model = new Models.ViewModelLogMethod(); response_model.page = page; response_model.word = word; //获取每页大小的Cookie response_model.page_size = TypeHelper.ObjectToInt(WebHelper.GetCookie("logmethodindex"), SiteKey.AdminDefaultPageSize); int total = 0; List <BLL.FilterSearch> filter = new List <BLL.FilterSearch>(); if (type != 0) { filter.Add(new BLL.FilterSearch("Type", type.ToString(), BLL.FilterSearchContract.等于)); } if (!string.IsNullOrWhiteSpace(word)) { filter.Add(new BLL.FilterSearch("Detail", word, BLL.FilterSearchContract.like)); } BLL.BaseBLL <Entity.SysLogMethod> bll = new BLL.BaseBLL <Entity.SysLogMethod>(); var list = bll.GetPagedList(page, response_model.page_size, ref total, filter, "AddTime desc", "SysUser"); response_model.DataList = list; response_model.total = total; response_model.total_page = CalculatePage(total, response_model.page_size); return(View(response_model)); }
public JsonResult DelApiAction(string ids) { if (string.IsNullOrWhiteSpace(ids)) { WorkContext.AjaxStringEntity.msgbox = "缺少参数"; return(Json(WorkContext.AjaxStringEntity)); } BLL.BaseBLL <Entity.SysLogApiAction> bll = new BLL.BaseBLL <Entity.SysLogApiAction>(); var id_list = Array.ConvertAll <string, int>(ids.Split(','), int.Parse); bll.DelBy(p => id_list.Contains(p.ID)); WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "success"; return(Json(WorkContext.AjaxStringEntity)); }
/// <summary> /// 新增文章类型 /// </summary> /// <param name="newtypename"></param> /// <param name="userid"></param> /// <returns></returns> public ActionResult NewAddType(string newtypename) { JSData jsdata = new JSData(); #region 数据验证 if (null == BLLSession.UserInfoSessioin) { jsdata.Messg = "您还未登录~"; } else if (string.IsNullOrEmpty(newtypename)) { jsdata.Messg = "类型不能为空~"; } if (!string.IsNullOrEmpty(jsdata.Messg)) { jsdata.State = EnumState.失败; return(Json(jsdata)); } #endregion int userid = BLLSession.UserInfoSessioin.Id; var user = new BLL.BaseBLL <BlogUser>().GetList(t => t.Id == userid, isAsNoTracking: false).FirstOrDefault(); BLL.BaseBLL <BlogType> bll = new BaseBLL <BlogType>(); bll.Insert( new BlogType() { TypeName = newtypename, BlogUser = user, IsDelte = false } ); if (bll.save() > 0)//保存 { //BLL.Common.CacheData.GetAllType(true);//更新缓存 jsdata.State = EnumState.成功; jsdata.Messg = "新增成功~"; } else { jsdata.State = EnumState.失败; jsdata.Messg = "新增失败~"; } return(Json(jsdata)); }
public ActionResult EditAndroid(Entity.AppVersion entity) { var isAdd = entity.ID == 0 ? true : false; BLL.BaseBLL <Entity.AppVersion> bll = new BLL.BaseBLL <Entity.AppVersion>(); entity.APPType = Entity.APPVersionType.Standard; entity.Platforms = Entity.APPVersionPlatforms.Android; //数据验证 if (isAdd) { //判断版本是否存在 if (bll.Exists(p => p.Platforms == Entity.APPVersionPlatforms.Android && p.APPType == Entity.APPVersionType.Standard && p.Version == entity.Version)) { ModelState.AddModelError("Content", "该版本存在"); } } else { if (!bll.Exists(p => p.ID == entity.ID)) { return(PromptView("/admin/AppVersion", "404", "Not Found", "信息不存在或已被删除", 5)); } } if (ModelState.IsValid) { //添加 if (entity.ID == 0) { entity.AddTime = DateTime.Now; bll.Add(entity); } else //修改 { bll.Modify(entity); } return(PromptView("/admin/AppVersion", "OK", "Success", "操作成功", 5)); } else { return(View(entity)); } }
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 JsonResult Del(string ids) { if (string.IsNullOrWhiteSpace(ids)) { WorkContext.AjaxStringEntity.msgbox = "缺少参数"; return(Json(WorkContext.AjaxStringEntity)); } BLL.BaseBLL <Entity.Demo> bll = new BLL.BaseBLL <Entity.Demo>(); var id_list = Array.ConvertAll <string, int>(ids.Split(','), int.Parse); bll.DelBy(p => id_list.Contains(p.ID)); AddAdminLogs(Entity.SysLogMethodType.Delete, "删除Demo:" + ids); WorkContext.AjaxStringEntity.msg = 1; WorkContext.AjaxStringEntity.msgbox = "success"; return(Json(WorkContext.AjaxStringEntity)); }