public void MoveLimitItem(short mode, int limitId, string modelId)
        {
            var obj  = ProductMenuLimitRepository.Find(o => o.ModuleId == modelId && o.MenuId == limitId);
            var list = ProductMenuLimitRepository.GetQuery(o => o.ModuleId == modelId && o.Type == 3 && o.PMenuId == obj.PMenuId).OrderBy(o => o.SortOrder).ToList();

            switch (mode)
            {
            case 2:    //下移
                var obj1 = list.LastOrDefault();
                if (obj.Id != obj1.Id)
                {
                    Entity.ProductMenuLimit next = null;
                    for (var i = 0; i < list.Count; i++)
                    {
                        if (obj.Id == list[i].Id)
                        {
                            next = list[i + 1]; break;
                        }
                    }
                    if (next != null)
                    {
                        var sort = obj.SortOrder;
                        obj.SortOrder  = next.SortOrder;
                        next.SortOrder = sort;
                        ProductMenuLimitRepository.SaveChanges();
                    }
                }
                break;

            default:    //上移
                var obj2 = list.FirstOrDefault();
                if (obj.Id != obj2.Id)
                {
                    Entity.ProductMenuLimit prev = null;
                    for (var i = 0; i < list.Count; i++)
                    {
                        if (obj.Id == list[i].Id)
                        {
                            prev = list[i - 1]; break;
                        }
                    }
                    if (prev != null)
                    {
                        var sort = obj.SortOrder;
                        obj.SortOrder  = prev.SortOrder;
                        prev.SortOrder = sort;
                        ProductMenuLimitRepository.SaveChanges();
                    }
                }
                break;
            }
        }
        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());
        }