public static ItemListBox<OrderBase> GetOrderListByPage(int page, int pageSize, string key, int status, string starttime, string endtime, ref int count) { try { using (Context ctx = new Context()) { var expression = from o in ctx.OrderBase join d in ctx.OrderDetail on o.ID equals d.OrderID join p in ctx.Product on o.ID equals p.OrderID join ga in ctx.Game on p.GameID equals ga.id into gm from g in gm.DefaultIfEmpty() select new { o, d, p, g }; if (!string.IsNullOrEmpty(key)) { expression = expression.Where(a => a.o.CreaterUser.Contains(key) || a.o.Source.Contains(key) || a.p.Name.Contains(key) || a.p.Description.Contains(key) || (a.g != null && a.g.name.Contains(key))); } if (status != -100) { expression = expression.Where(a => a.o.State == status); } if (!string.IsNullOrEmpty(starttime)) { DateTime startTime = DateTime.Parse(starttime + " 00:00:00"); expression = expression.Where(a => a.o.CreateTime >= startTime); } if (!string.IsNullOrEmpty(endtime)) { DateTime endTime = DateTime.Parse(endtime + " 23:59:59"); expression = expression.Where(a => a.o.CreateTime < endTime); } List<OrderBase> orderList = expression .ToList() .GroupBy(a => new { a.o }) .Select(a => new OrderBase().Set(a.FirstOrDefault().o)) .Skip(page * pageSize) .Take(pageSize) .ToList(); return new ItemListBox<OrderBase>(orderList).BuildPage(count, page, pageSize, new PageParameter() { Style = "admin" }); } } catch (Exception ex) { LogHelper.Write(CommonLogger.Application, ex); } return null; }
public static ItemListBox<OrderBase> GetPlaceOrderListByPage(int page, int pageSize, string key, int status, string starttime, string endtime, ref int count) { try { using (Context ctx = new Context()) { string userName = System.Web.HttpContext.Current.User.Identity.Name; var expression = from o in ctx.OrderBase where o.CreaterUser == userName join d in ctx.OrderDetail on o.ID equals d.OrderID select new { o, d}; if (!string.IsNullOrEmpty(key)) { expression = expression.Where(a => a.o.CreaterUser.Contains(key) || a.o.Source.Contains(key) ); } if (status != -100) { expression = expression.Where(a => a.o.State == status); } if (!string.IsNullOrEmpty(starttime)) { DateTime startTime = DateTime.Parse(starttime + " 00:00:00"); expression = expression.Where(a => a.o.CreateTime >= startTime); } if (!string.IsNullOrEmpty(endtime)) { DateTime endTime = DateTime.Parse(endtime + " 23:59:59"); expression = expression.Where(a => a.o.CreateTime < endTime); } List<OrderBase> orderList = expression .ToList() .GroupBy(a => new { a.o }) .Select(a => new OrderBase().Set(a.FirstOrDefault().o)) .Skip(page * pageSize) .Take(pageSize) .ToList(); return new ItemListBox<OrderBase>(orderList).BuildPage(count, page, pageSize, new PageParameter() { Style = "admin" }); } } catch (Exception ex) { LogHelper.Write(CommonLogger.Application, ex); } return null; }
public ActionResult ModuleDelete(int moduleID) { var module = new Module().Find(moduleID.ToString()); if (module.Level == 3) { module.PostDelete(); } else if (module.Level == 2) { using (Context ctx = new Context()) ctx.Module.Where(c => c.ParentID == moduleID).Delete(); //ctx.Delete<U_Module>() // .WhereSet(c => c.ParentID, WhereOperator.Equal, moduleID) // .End() // module.PostDelete(); } else if (module.Level == 1) { var chidren = new Module().FindAll(c => c.ParentID == moduleID); using (Context ctx = new Context()) { if (chidren != null && chidren.Count > 0) { foreach (var second in chidren) { ctx.Module.Where(c => c.ParentID == second.ID).Delete(); //ctx.Delete<U_Module>() // .WhereSet(c => c.ParentID, WhereOperator.Equal, second.ID) // .End() // .Excute(); } } ctx.Module.Where(c => c.ParentID == moduleID).Delete(); //ctx.Delete<U_Module>() // .WhereSet(c => c.ParentID, WhereOperator.Equal, moduleID) // .End() // .Excute(); module.PostDelete(); } } return Content("1"); }
public static List<Module> GetUserModuleByUserName(string userName) { try { using (Context ctx = new Context()) { var data = (from c in ctx.Module join di in ctx.UserModule.Where(f => f.UserName == userName) on c.ID equals di.ModuleID into dt from d in dt.DefaultIfEmpty() where (c.Level == 1 || c.Level == 2) select new { c, d }) .ToList() .Select(u => { var module = new Module(); module.Set(u.c); if (u.d == null || string.IsNullOrEmpty(u.d.UserName)) { module.IsSelect = false; } else { module.IsSelect = true; } return module; }) .ToList(); return data; } } catch (Exception ex) { LogHelper.Write(CommonLogger.Web, ex); } return null; }
public static List<Module> GetModelListByUser(string userName) { return iCache.Get<List<Module>>(String.Format("ModuleBiz.GetModelListByUser:{0}", userName), () => { using (Context ctx = new Context()) { var loginUser = new User().Find(System.Web.HttpContext.Current.User.Identity.Name); if (loginUser == null) { return null; } if (loginUser.Status == ItemStatus.Supper) { var data = new Module().FindAll(); data.ForEach(c => { if (!String.IsNullOrEmpty(c.Url)) { c.Url = c.Url.ToLower(); } }); return data; } else { var data = (from c in ctx.Module join d in ctx.UserModule on c.ID equals d.ModuleID where d.UserName == userName select new { c }).Distinct() .ToList() .Select(e => { var module = new Module().Set(e.c); module.Url = module.Url == null ? "" : module.Url.ToLower(); return module; }) .ToList(); if (data != null && data.Count > 0) { var list = new List<Module>(); foreach (var item in data) { list.Add(item); if (item.Level == 2) { var thirdlist = new Module().FindAll(c => c.ParentID == item.ID); list.AddRange(thirdlist); } } return list; } else { return data; } } } }, 600); }
public static List<Module> GetModelListByUserForMenu(string userName) { try { using (Context ctx = new Context()) { var loginUser = new User().Find(System.Web.HttpContext.Current.User.Identity.Name); if (loginUser == null) { return null; } if (loginUser.Status == ItemStatus.Supper) { var data = new Module().FindAll(c => c.IsDisplay == true && (c.Level == 1 || c.Level == 2)); data.ForEach(c => { if (!String.IsNullOrEmpty(c.Url)) { c.Url = c.Url.ToLower(); } }); return data; } else { var data = (from c in ctx.Module join d in ctx.UserModule on c.ID equals d.ModuleID where d.UserName == userName && c.IsDisplay == true && (c.Level == 1 || c.Level == 2) select new { c }).Distinct() .ToList() .Select(e => { var module = new Module().Set(e.c); module.Url = module.Url == null ? "" : module.Url.ToLower(); return module; }).ToList(); return data; } } } catch (Exception ex) { LogHelper.Write(CommonLogger.Web, ex); } return null; }
public static bool UserAuthorizeDelete(string userName) { bool isTrue = true; try { using (Context ctx = new Context()) { int count = ctx.UserModule.Count(c => c.UserName == userName); if (count == 0) { return true; } int row = ctx.UserModule.Where(c => c.UserName == userName).Delete(); if (row > 0) { isTrue = true; } else { isTrue = false; } } } catch (Exception ex) { LogHelper.Write(CommonLogger.Web, ex); isTrue = false; } return isTrue; }
/// <summary> /// 获取所有用户信息 /// </summary> /// <returns></returns> public static List<User> GetActiveUserList(string key) { try { var loginUser = new User().Find(System.Web.HttpContext.Current.User.Identity.Name); using (Context ctx = new Context()) { if (loginUser.Status == ItemStatus.Supper) { var userList = (from c in ctx.User where (c.Status == (int)ItemStatus.Enable || c.Status == (int)ItemStatus.Supper) && (c.RealName.Contains(key) || c.UserName.Contains(key)) select new { c.UserName, c.RealName }) .ToList() .Select(c => new User() { UserName = c.UserName, RealName = c.RealName }).ToList(); return userList; } else { var userList = (from c in ctx.User where c.Status == (int)ItemStatus.Enable && (c.RealName.Contains(key) || c.UserName.Contains(key)) select new { c.UserName, c.RealName }) .ToList() .Select(c => new User() { UserName = c.UserName, RealName = c.RealName }).ToList(); return userList; } } } catch (Exception ex) { LogHelper.Write(CommonLogger.Web, ex); } return null; }
/// <summary> /// 获取所有用户信息 /// </summary> /// <returns></returns> public static ItemListBox<User> GetUserListByPage(int page, int pageSize, string key, ref int count) { try { using (Context ctx = new Context()) { var loginUser = new User().Find(System.Web.HttpContext.Current.User.Identity.Name); var expression = from c in ctx.User where (string.IsNullOrEmpty(key) || (c.UserName.Contains(key) || c.RealName.Contains(key))) && c.Status != (int)ItemStatus.Delete && c.Status != (int)ItemStatus.Supper orderby c.UserName select c; if (loginUser.Status == ItemStatus.Supper) { expression = from c in ctx.User where (string.IsNullOrEmpty(key) || (c.UserName.Contains(key) || c.RealName.Contains(key))) && c.Status != (int)ItemStatus.Delete orderby c.UserName select c; } count = expression.Count(); var data = expression .Skip(page * pageSize) .Take(pageSize) .ToList().Select(u => new User().Set(u)).ToList(); return new ItemListBox<User>(data).BuildPage(count, page, pageSize, new PageParameter() { Style = "admin" }); } } catch (Exception ex) { LogHelper.Write(CommonLogger.Web, ex); } return null; }