public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = ProductModelVerRepository.GetQuery(); var queryProduct = ProductVerRepository.GetQuery(); var queryUser = UserRepository.GetQuery(); var productId = nvl["productId"].ToType <int?>(); var state = nvl["state"]; var verstate = nvl["verstate"]; var q = from x in query join y in queryProduct on x.ProductId equals y.ProductId select new { x.Id, x.CreateDT, x.ProductId, x.Status, x.VerStatus, x, MenuCount = x.ProductMenuLimits.Count(o => o.Type != 3), LimitCount = x.ProductMenuLimits.Count(o => o.Type == 3), y.SysName, Updater = queryUser.Where(o => o.UserId == x.UpdateUID).Select(o => o.FullName).FirstOrDefault(), Publisher = queryUser.Where(o => o.UserId == x.PublishUID).Select(o => o.FullName).FirstOrDefault() }; if (productId.HasValue) { q = q.Where(o => o.ProductId == productId); } if (!state.IsNullOrEmpty()) { var st = state.Split(',').Select(o => short.Parse(o)).ToList(); q = q.Where(o => st.Contains(o.Status)); } if (!verstate.IsNullOrEmpty()) { var st = verstate.Split(',').Select(o => short.Parse(o)).ToList(); q = q.Where(o => st.Contains(o.VerStatus)); } recordCount = q.Count(); return(q.ToPageList().Select(x => new{ x.Id, x.x.ModuleId, x.ProductId, x.SysName, x.x.VerCode, x.CreateDT, x.x.CreateUID, x.Status, x.VerStatus, x.x.UpdateDT, x.x.PublishDT, x.x.StatusTitle, x.x.VerStatusTitle, x.MenuCount, x.LimitCount, x.Updater, x.Publisher })); }
public List <Entity.ProductVer> GetProductVers() { var queryProduct = ProductVerRepository.GetQuery(); var queryModel = ProductModelVerRepository.GetQuery(); var query = from x in queryProduct where !queryModel.Any(o => o.ProductId == x.ProductId) && x.Status == 1 select x; return(query.ToList()); }
public OpResult Deletes(int[] ids) { var list = ProductModelVerRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductMenuLimits).ToList(); if (list.Any(o => o.VerStatus > 0)) { return(OpResult.Fail("该状态不允许删除!")); } ProductMenuLimitRepository.RemoveRange(list.SelectMany(o => o.ProductMenuLimits).ToList(), false); //ProductUpdateLogRepository.RemoveRange(list.SelectMany(o => o.ProductUpdateLogs).ToList(), false); ProductModelVerRepository.RemoveRange(list); return(OpResult.Success()); }
public OpResult SaveMenu(Entity.ProductMenuLimit obj) { if (obj.Id == 0) { if (ProductModelVerRepository.IsExists(o => o.ProductId == obj.ProductId && o.Status == 0 && o.ModuleId != obj.ModuleId)) { return(OpResult.Fail("已存在未发布的版本")); } obj.ModuleId = obj.ModuleId ?? CommonService.GUID; obj.MenuId = ProductMenuLimitRepository.GetMaxInt(o => (int?)o.MenuId, whereLambda: o => o.ProductId == obj.ProductId && o.ModuleId == obj.ModuleId); obj.CreateDT = DateTime.Now; obj.CreateUID = CurrentUser.UID; obj.SortOrder = ProductMenuLimitRepository.GetMaxInt(o => (int?)o.SortOrder, whereLambda: o => o.ProductId == obj.ProductId && o.ModuleId == obj.ModuleId); ProductMenuLimitRepository.Add(obj, false); } else { var menu = ProductMenuLimitRepository.Get(obj.Id); obj.ToCopyProperty(menu, new List <string>() { "CreateDT", "CreateUID", "MenuId", "SortOrder" }); obj.ModuleId = menu.ModuleId; } var model = ProductModelVerRepository.Find(o => o.ModuleId == obj.ModuleId); if (model != null) { model.UpdateDT = DateTime.Now; model.UpdateUID = CurrentUser.UID; } else { ProductModelVerRepository.Add(new Entity.ProductModuleVer() { ModuleId = obj.ModuleId, ProductId = obj.ProductId, CreateDT = obj.CreateDT, UpdateDT = obj.CreateDT, UpdateUID = obj.CreateUID, CreateUID = obj.CreateUID, }, false); } ProductMenuLimitRepository.SaveChanges(); return(OpResult.Success()); }
public OpResult SaveOrUpdate(Entity.ProductModuleVer obj) { if (obj.Id == 0) { obj.ModuleId = CommonService.GUID; obj.CreateDT = DateTime.Now; obj.UpdateDT = obj.CreateDT; obj.UpdateUID = CurrentUser.UID; obj.CreateUID = obj.UpdateUID; ProductModelVerRepository.Add(obj, false); } else { var product = ProductModelVerRepository.Find(o => o.Id == obj.Id); product.UpdateUID = CurrentUser.UID; product.UpdateDT = DateTime.Now; } ProductModelVerRepository.SaveChanges(); return(OpResult.Success()); }
public OpResult Publish(string modelId, short state) { var obj = Get(modelId); if (obj != null) { if (!obj.ProductMenuLimits.Any(o => o.Type != 3)) { return(OpResult.Fail("请先配置菜单!")); } if (!obj.ProductMenuLimits.Any(o => o.Type == 3)) { return(OpResult.Fail("请先配置权限!")); } obj.VerStatus = state; var list = ProductModelVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.ModuleId != obj.ModuleId).ToList(); list.Where(o => o.VerStatus == obj.VerStatus).Each(o => o.Status = 2); if (state == 1)//测试 { obj.PublishDT = DateTime.Now; obj.PublishUID = CurrentUser.UID; obj.Status = 1; var source = list.OrderByDescending(o => o.VerCode).FirstOrDefault(o => o.VerCode > 0); if (source == null) { obj.VerCode = 1; } else { obj.VerCode = source.VerCode + 0.1m; } } ProductVerRepository.SaveChanges(); return(OpResult.Success()); } return(OpResult.Fail()); }
public Entity.ProductModuleVer GetOfficialLast(int productId) { return(ProductModelVerRepository.GetOfficialLast(productId)); }
public Entity.ProductModuleVer Get(string modelId) { return(ProductModelVerRepository.GetQuery(o => o.ModuleId == modelId).Include(o => o.ProductMenuLimits).FirstOrDefault()); }