public virtual JsonResult IsLogin() { EntityResponseDto res = new EntityResponseDto(); try { string ip = Request.UserHostAddress; StaffEntity staff = WebHelper.GetSessionObj(WebHelper.USER_LOGIN_SESSION) as StaffEntity; if (staff != null) { res.Success = true; } else { res.Success = false; } } catch (Exception ex) { res.Success = false; res.Message = ex.Message; Log.Error(ex); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Read(CommonAjaxArgs args) { EntityResponseDto res = new EntityResponseDto(); var predicate = ExpressionUtil.GetSearchExpression(typeof(T), args.Filter) as Expression <Func <T, bool> >; args.Limit = args.Limit <= 0 ? 50 : args.Limit; args.Page = args.Page == 0 ? 1 : args.Page; Sorter sort = new Sorter() { SortField = "ID", SortOrder = System.Data.SqlClient.SortOrder.Descending }; if (args.Query.Sorters != null && args.Query.Sorters.Count > 0) { sort = args.Query.Sorters.First(); } string[] includes = args.Include; res.Count = Repository.GetQueryExp <T>(predicate, includes).Count(); res.Entitys = Repository.QueryPage <T>(predicate, new Pagination() { page = args.Page, rows = args.Limit, sidx = sort.SortField, sord = sort.SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "asc" : "desc" }, includes); res.Success = true; return(MyJson(res)); }
public virtual JsonResult Gets(CommonAjaxArgs args) { EntityResponseDto res = new EntityResponseDto(); var predicate = ExpressionUtil.GetSearchExpression(typeof(T), args.Query.Searchs) as Expression <Func <T, bool> >; var page = args.Query.Page; if (page.PageSize <= 0) { page.PageSize = 500; } Sorter sort = new Sorter() { SortField = "ID", SortOrder = System.Data.SqlClient.SortOrder.Descending }; if (args.Query.Sorters != null && args.Query.Sorters.Count > 0) { sort = args.Query.Sorters.First(); } string[] includes = args.Query.IncludeEntityPaths == null ? null : args.Query.IncludeEntityPaths.ToArray(); res.Count = Repository.GetQueryExp <T>(predicate, includes).Count(); res.Entitys = Repository.QueryPage <T>(predicate, new Pagination() { page = page.PageIndex, rows = page.PageSize, sidx = sort.SortField, sord = sort.SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "asc" : "desc" }, includes); res.Success = true; return(MyJson(res)); }
public virtual JsonResult Read(CommonAjaxArgs args) { EntityResponseDto res = new EntityResponseDto(); var predicate = ExpressionUtil.GetSearchExpression(typeof(T), args.Filter) as Expression <Func <T, bool> >; args.Limit = args.Limit <= 0 ? 50 : args.Limit; args.Page = args.Page == 0 ? 1 : args.Page; if (string.IsNullOrWhiteSpace(args.Sort)) { args.Sort = "ID"; args.SortDir = "desc"; } string[] includes = args.Include; res.Count = Repository.GetQueryExp <T>(predicate, includes).Count(); res.Entitys = Repository.QueryPage <T>(predicate, new Pagination() { page = args.Page, rows = args.Limit, sidx = args.Sort, sord = args.SortDir }, includes); res.Success = true; return(MyJson(res)); }
public virtual JsonResult GetMenu(long?parentId) { EntityResponseDto res = new EntityResponseDto(); res.Entitys = Repository.QueryAll <MenuEntity>(x => x.ParentID == parentId); res.Success = true; return(MyJson(res, JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Delete(long[] ids) { EntityResponseDto res = new EntityResponseDto(); Repository.Delete <T>(ids); res.Success = true; return(MyJson(res)); }
public virtual JsonResult Logout() { EntityResponseDto res = new EntityResponseDto(); string ip = Request.UserHostAddress; WebHelper.RemoveUser(); res.Success = true; return(Json(res, JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Delete([FromBody] DeleteModel deleteModel, [FromServices] IRepositoryBase repository) { EntityResponseDto res = new EntityResponseDto(); Validate(deleteModel.Ids); int count = repository.Delete <T>(deleteModel.Ids); res.Success = true; return(Json(res)); }
public virtual JsonResult IsLogin() { EntityResponseDto res = new EntityResponseDto(); string ip = Request.UserHostAddress; User user = Repository.GetCurrentUser(); if (user != null) { res.Success = true; } return(Json(res, JsonRequestBehavior.AllowGet)); }
// GET: Sys/Menu public virtual JsonResult GetMenu(long?parentId) { EntityResponseDto res = new EntityResponseDto(); try { res.Entitys = Repository.QueryAll <MenuEntity>(x => x.ParentID == parentId); res.Success = true; } catch (Exception ex) { res.Success = false; res.Message = ex.Message; Log.Error(ex); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Logout() { EntityResponseDto res = new EntityResponseDto(); try { string ip = Request.UserHostAddress; WebHelper.RemoveSession(WebHelper.USER_LOGIN_SESSION); res.Success = true; } catch (Exception ex) { res.Success = false; res.Message = ex.Message; Log.Error(ex); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public JsonResult CreateTask(long projectId) { EntityResponseDto res = new EntityResponseDto(); try { ProjectService.Repository.BeginTran(); MenuService.Repository.QueryFirst <ProjectEntity>(x => x.ID == 10); ProjectService.CreateTask(projectId); ProjectService.Repository.Commit(); res.Success = true; } catch (Exception ex) { ProjectService.Repository.Rollback(); res.Success = false; Log.Error(ex); } return(MyJson(res)); }
public JsonResult Delete(long[] ids) { EntityResponseDto res = new EntityResponseDto(); try { Repository.BeginTran(); Repository.Delete <T>(ids); Repository.Commit(); res.Success = true; } catch (Exception ex) { Repository.Rollback(); res.Success = false; res.Message = ex.Message; Log.Error(ex); } return(MyJson(res)); }
// GET: Org/Staff public virtual JsonResult Login(string userName, string pwd) { EntityResponseDto res = new EntityResponseDto(); string ip = Request.UserHostAddress; if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(pwd)) { throw new Exception("用户名和密码不能为空!"); } StaffEntity staff = StaffService.Login(userName, pwd, ip); if (staff != null) { res.Dic.Add("user", staff); } else { throw new Exception("登录失败!"); } res.Success = true; return(Json(res, JsonRequestBehavior.AllowGet)); }
// GET: Org/Staff public virtual JsonResult Login(string userName, string userPwd) { EntityResponseDto res = new EntityResponseDto(); try { string ip = Request.UserHostAddress; if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(userPwd)) { throw new Exception("用户名和密码不能为空!"); } Repository.BeginTran(); StaffEntity staff = StaffService.Login(userName, userPwd, ip); if (staff != null) { res.Dic.Add("user", staff); } else { throw new Exception("登陆失败!"); } Repository.Commit(); res.Success = true; } catch (Exception ex) { Log.Error(ex); Repository.Rollback(); res.Success = false; res.Message = ex.Message; } finally { Repository.Dispose(); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Read([FromForm] CommonAjaxArgs args, [FromServices] IRepositoryBase repository) { EntityResponseDto res = new EntityResponseDto(); var predicate = ExpressionUtil.GetSearchExpression(typeof(T), args.Filter) as Expression <Func <T, bool> >; args.PageSize = args.PageSize <= 0 ? 50 : args.PageSize; args.PageIndex = args.PageIndex == 0 ? 1 : args.PageIndex; args.SortField = string.IsNullOrWhiteSpace(args.SortField) ? EntityConst.EntityIdName : args.SortField; args.SortOrder = string.IsNullOrWhiteSpace(args.SortOrder) ? "desc" : args.SortOrder; string[] includes = args.Include; res.Total = repository.GetQueryExp <T>(predicate, includes).Count(); res.Data = repository.QueryPage <T>(predicate, new Pagination() { page = args.PageIndex, rows = args.PageSize, SortField = args.SortField, SortOrder = args.SortOrder }, includes); res.Success = true; return(Json(res)); }