public OpResult Publish(string verId, short state) { var obj = Get(verId); if (obj != null) { if (!obj.ProductDataSqls.Any()) { return(OpResult.Fail("请先配置初始数据!")); } obj.VerStatus = state; var list = ProductDataVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.DataId != obj.DataId).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; } } ProductDataSqlRepository.SaveChanges(); return(OpResult.Success()); } return(OpResult.Fail()); }
public List <Models.ProductDataSqlModel> DataList(string verId) { var query = ProductDataSqlRepository.GetQuery(o => o.DataId == verId); var queryVer = ProductDataVerRepository.GetQuery(o => o.DataId == verId); var queryMenu = ProductMenuLimitRepository.GetQuery(); var q = from x in query join y in queryVer on x.DataId equals y.DataId orderby x.RunSort select new Models.ProductDataSqlModel() { Id = x.Id, MenuId = x.MenuId, RunSort = x.RunSort, RunSql = x.RunSql, DataId = x.DataId, Title = queryMenu.Where(o => o.ModuleId == y.ModuleId && o.MenuId == x.MenuId).Select(o => o.Title).FirstOrDefault() }; var ms = q.ToList(); var menus = new List <Models.ProductDataSqlModel>(); int i = 0; foreach (var m in ms) { m.SqlMore = m.RunSql.TrimMore(200); m.Count = ms.Count; m.Index = i; i++; menus.Add(m); } return(menus); }
public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = ProductDataVerRepository.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, ModelCount = x.ProductDataSqls.Count, 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.DataId, 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.ModelCount, x.Updater, x.Publisher })); }
public List <Entity.ProductVer> GetProductVers() { var queryProduct = ProductVerRepository.GetQuery(); var queryModel = ProductDataVerRepository.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 = ProductDataVerRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductDataSqls).ToList(); if (list.Any(o => o.VerStatus > 0)) { return(OpResult.Fail("该状态不允许删除!")); } ProductDataSqlRepository.RemoveRange(list.SelectMany(o => o.ProductDataSqls).ToList(), false); ProductDataVerRepository.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.ProductDataVer Get(string verId) { return(ProductDataVerRepository.GetQuery(o => o.DataId == verId).Include(o => o.ProductDataSqls).FirstOrDefault()); }