public OpResult Publish(string verId, short state) { var obj = Get(verId); if (obj != null) { if (!obj.ProductDictionaryDatas.Any()) { return(OpResult.Fail("请先配置字典!")); } obj.VerStatus = state; var list = ProductDictionaryVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.DictId != obj.DictId).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; } } ProductDictionaryDataRepository.SaveChanges(); return(OpResult.Success()); } return(OpResult.Fail()); }
public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = ProductDictionaryVerRepository.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, ParenCount = x.ProductDictionaryDatas.Count(o => o.DicPSN <= 0), ChildCount = x.ProductDictionaryDatas.Count(o => o.DicPSN > 0), 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.DictId, 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.ParenCount, x.ChildCount, x.Updater, x.Publisher })); }
public List <Entity.ProductVer> GetProductVers() { var queryProduct = ProductVerRepository.GetQuery(); var queryModel = ProductDictionaryVerRepository.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 = ProductDictionaryVerRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductDictionaryDatas).ToList(); if (list.Any(o => o.VerStatus > 0)) { return(OpResult.Fail("该状态不允许删除!")); } ProductDictionaryDataRepository.RemoveRange(list.SelectMany(o => o.ProductDictionaryDatas).ToList(), false); ProductDictionaryVerRepository.RemoveRange(list); return(OpResult.Success()); }
public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = ProductVerRepository.GetQuery(); var queryUse = ProductModuleVerRepository.GetQuery().Select(o => o.ProductId) .Union(ProductDictionaryVerRepository.GetQuery().Select(o => o.ProductId)) .Union(ProductDataVerRepository.GetQuery().Select(o => o.ProductId)) .Union(ProductRoleVerRepository.GetQuery().Select(o => o.ProductId)); var queryUser = UserRepository.GetQuery(); var code = nvl["code"].ToType <int?>(); var state = nvl["state"]; var q = from x in query select new { x.Id, x.ProductId, x.Name, x.SysName, x.Alias, x.CreateDT, x.CreateUID, x.Status, HasUse = queryUse.Any(o => o == x.ProductId) ? "√" : "--", StatusTitle = x.Status == 1 ? "已生效" : x.Status == 2 ? "已失效" : "未生效", x.Memo, Creater = queryUser.Where(o => o.UserId == x.CreateUID).Select(o => o.FullName).FirstOrDefault() }; if (code.HasValue) { q = q.Where(o => o.ProductId == code); } if (!state.IsNullOrEmpty()) { var st = state.Split(',').Select(o => short.Parse(o)).ToList(); q = q.Where(o => st.Contains(o.Status)); } recordCount = q.Count(); return(q.ToPageList()); }
public Entity.ProductDictionaryVer Get(string verId) { return(ProductDictionaryVerRepository.GetQuery(o => o.DictId == verId).Include(o => o.ProductDictionaryDatas).FirstOrDefault()); }