示例#1
0
        public OpResult Publish(string verId, short state)
        {
            var obj = Get(verId);

            if (obj != null)
            {
                if (!obj.ProductRoles.Any())
                {
                    return(OpResult.Fail("请先配置角色!"));
                }
                obj.VerStatus = state;
                var list = ProductRoleVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.RoleVerId != obj.RoleVerId).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());
        }
示例#2
0
        public List <Entity.ProductVer> GetProductVers()
        {
            var queryProduct = ProductVerRepository.GetQuery();
            var queryModel   = ProductRoleVerRepository.GetQuery();
            var query        = from x in queryProduct
                               where !queryModel.Any(o => o.ProductId == x.ProductId) &&
                               x.Status == 1
                               select x;

            return(query.ToList());
        }
示例#3
0
        public OpResult Deletes(int[] ids)
        {
            var list = ProductRoleVerRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductRoles).Include("ProductRoles.ProductRoleDatas").ToList();

            if (list.Any(o => o.VerStatus > 0))
            {
                return(OpResult.Fail("该状态不允许删除!"));
            }
            ProductRoleDataRepository.RemoveRange(list.SelectMany(o => o.ProductRoles.SelectMany(i => i.ProductRoleDatas)).ToList(), false);
            ProductRoleRepository.RemoveRange(list.SelectMany(o => o.ProductRoles).ToList(), false);
            ProductRoleVerRepository.RemoveRange(list);
            return(OpResult.Success());
        }
示例#4
0
        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());
        }
示例#5
0
        public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount)
        {
            var query        = ProductRoleVerRepository.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,
                RoleCount  = x.ProductRoles.Count(),
                LimitCount = x.ProductRoles.SelectMany(o => o.ProductRoleDatas).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.RoleVerId,
                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.RoleCount,
                x.LimitCount,
                x.Updater,
                x.Publisher
            }));
        }
示例#6
0
        public List <Models.ProductRoleMenuModel> FindMenuList(int productId, int roleId, string verId, bool isdetail)
        {
            lock (_objlock)
            {
                var queryMenu     = ProductMenuLimitRepository.GetQuery();
                var queryRoleVer  = ProductRoleVerRepository.GetQuery(o => o.RoleVerId == verId);
                var queryRole     = ProductRoleRepository.GetQuery(o => o.RoleId == roleId);
                var queryRoleData = ProductRoleDataRepository.GetQuery();
                var ver           = Get(verId);
                var ms            = new List <Models.ProductRoleMenuModel>();
                if (ver != null && !ver.ModuleId.IsNullOrEmpty())
                {
                    queryMenu = queryMenu.Where(o => o.ModuleId == ver.ModuleId);
                    var q = from x in queryRoleData
                            join z in queryRole on x.RoleDataId equals z.Id
                            join y in queryMenu on x.MenuId equals y.MenuId
                            where z.RoleVerId == verId && queryRoleVer.Any(o => o.ModuleId == y.ModuleId)
                            orderby x.SortOrder
                            select new Models.ProductRoleMenuModel()
                    {
                        Id           = y.MenuId,
                        MenuId       = y.MenuId,
                        PMenuId      = y.PMenuId,
                        Title        = y.Title,
                        LimitSelects = z.Limitids,
                        ParentId     = x.HasSelected ? 1 : 0
                    };
                    ms = q.ToList();
                    var limits = queryMenu.Where(o => o.Type == 3).ToList();
                    ms.Each(o =>
                    {
                        o.Limitids      = string.Join(",", limits.Where(i => i.PMenuId == o.MenuId).Select(i => i.Title + ":" + i.MenuId));
                        o.MenuIdSelects = string.Join(",", ms.Where(i => i.ParentId == 1).Select(i => i.MenuId));
                    });
                    ms.Each(o =>
                    {
                        o.ParentId = 0;
                    });
                }
                if (!ms.Any())
                {
                    var modelVer = ProductModelVerService.GetOfficialLast(productId);
                    if (modelVer != null && ver != null)
                    {
                        var role = ver.ProductRoles.FirstOrDefault(o => o.RoleId == roleId);
                        if (!role.ProductRoleDatas.Any())
                        {
                            role.ProductRoleDatas.AddRange(modelVer.ProductMenuLimits.Where(o => o.Type != 3).Select(o => new ProductRoleData()
                            {
                                PMenuId   = o.PMenuId,
                                MenuId    = o.MenuId,
                                SortOrder = o.SortOrder,
                            }));
                            ver.ModuleId = modelVer.ModuleId;
                            ProductRoleVerRepository.SaveChanges();
                        }

                        ms.AddRange(modelVer.ProductMenuLimits.Where(o => o.Type != 3).OrderBy(o => o.SortOrder).Select(o => new Models.ProductRoleMenuModel()
                        {
                            Id       = o.MenuId,
                            MenuId   = o.MenuId,
                            PMenuId  = o.PMenuId,
                            Title    = o.Title,
                            Limitids = string.Join(",", modelVer.ProductMenuLimits.Where(i => i.PMenuId == o.MenuId && i.Type == 3).Select(i => i.Title + ":" + i.MenuId))
                        }));
                    }
                }
                var list = new List <Models.ProductRoleMenuModel>();
                foreach (var menu in ms.Where(o => o.PMenuId <= 0))
                {
                    SetChilds(menu, ms);
                    menu.Index = list.Count;
                    list.Add(menu);
                }
                return(list);
            }
        }
示例#7
0
 public Entity.ProductRoleVer Get(string verId)
 {
     return(ProductRoleVerRepository.GetQuery(o => o.RoleVerId == verId).Include(o => o.ProductRoles).Include("ProductRoles.ProductRoleDatas").FirstOrDefault());
 }