Пример #1
0
        public OpResult Publish(int verId, short state, bool forced)
        {
            var obj = Get(verId);

            if (obj != null)
            {
                obj.VerStatus = state;
                var list = ProductPublishVerRepository.GetQuery(o => o.ProductId == obj.ProductId && o.PublishId != obj.PublishId).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;
                    obj.Forced     = forced;
                    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;
                    }
                }
                obj.CompanyCount = CompanyAuthorizeRepository.GetQuery(o => o.OpenVersionId == obj.ProductId && o.Status == 1).Count();
                ProductPublishSqlRepository.SaveChanges();
                return(OpResult.Success());
            }
            return(OpResult.Fail());
        }
Пример #2
0
        public List <Models.ProductDataSqlModel> DataList(int verId)
        {
            var query     = ProductPublishSqlRepository.GetQuery(o => o.PublishId == verId);
            var queryVer  = ProductPublishVerRepository.GetQuery(o => o.PublishId == verId);
            var queryMenu = ProductMenuLimitRepository.GetQuery();
            var q         = from x in query
                            join y in queryVer on x.PublishId equals y.PublishId
                            orderby x.RunSort
                            select new Models.ProductDataSqlModel()
            {
                Id      = x.Id,
                MenuId  = x.MenuId,
                RunSort = x.RunSort,
                RunSql  = x.RunSql,
                Index   = x.PublishId,
                Title   = queryMenu.Where(o => o.ModuleId == y.MenuModuleId && 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.DataId  = m.Index.ToString();
                m.SqlMore = m.RunSql.TrimMore(200);
                m.Count   = ms.Count;
                m.Index   = i;
                i++;
                menus.Add(m);
            }
            return(menus);
        }
Пример #3
0
        public OpResult SaveData(Entity.ProductPublishSql obj)
        {
            if (obj.Id == 0)
            {
                obj.CreateDT  = DateTime.Now;
                obj.CreateUID = CurrentUser.UID;
                obj.RunSort   = ProductPublishSqlRepository.GetMaxInt(o => (int?)o.RunSort, whereLambda: o => o.PublishId == obj.PublishId);
                ProductPublishSqlRepository.Add(obj, false);
            }
            else
            {
                var menu = ProductPublishSqlRepository.Get(obj.Id);
                if (ProductPublishSqlRepository.IsExists(o => o.MenuId == obj.MenuId && o.PublishId == menu.PublishId && o.Id != obj.Id))
                {
                    return(OpResult.Fail("该菜单模块已存在"));
                }
                menu.RunSql = obj.RunSql;
            }
            var menuModelId = System.Web.HttpContext.Current.Request["menuModelId"];

            if (obj.PublishId > 0 && !menuModelId.IsNullOrEmpty())
            {
                var ver = Get(obj.PublishId);
                if (ver != null)
                {
                    ver.MenuModuleId = menuModelId;
                    ver.RunSqlWay    = System.Web.HttpContext.Current.Request["runSqlWay"].ToType <short>();
                    ver.UpdateDT     = DateTime.Now;
                    ver.UpdateUID    = CurrentUser.UID;
                }
            }
            ProductPublishSqlRepository.SaveChanges();
            return(OpResult.Success());
        }
Пример #4
0
        public OpResult Deletes(int[] ids)
        {
            var list = ProductPublishVerRepository.GetQuery(o => ids.Contains(o.Id)).Include(o => o.ProductPublishSqls).ToList();

            if (list.Any(o => o.VerStatus > 0))
            {
                return(OpResult.Fail("该状态不允许删除"));
            }
            ProductPublishSqlRepository.RemoveRange(list.SelectMany(o => o.ProductPublishSqls).ToList(), false);
            ProductPublishVerRepository.RemoveRange(list);
            return(OpResult.Success());
        }
Пример #5
0
        public void MoveItem(short mode, int sn, int verId)
        {
            var list = ProductPublishSqlRepository.GetQuery(o => o.PublishId == verId).OrderBy(o => o.RunSort).ToList();
            var obj  = list.FirstOrDefault(o => o.MenuId == sn);

            switch (mode)
            {
            case 2:    //下移
                var obj1 = list.LastOrDefault();
                if (obj.Id != obj1.Id)
                {
                    Entity.ProductPublishSql 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.RunSort;
                        obj.RunSort  = next.RunSort;
                        next.RunSort = sort;
                        ProductPublishSqlRepository.SaveChanges();
                    }
                }
                break;

            default:    //上移
                var obj2 = list.FirstOrDefault();
                if (obj.Id != obj2.Id)
                {
                    Entity.ProductPublishSql 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.RunSort;
                        obj.RunSort  = prev.RunSort;
                        prev.RunSort = sort;
                        ProductPublishSqlRepository.SaveChanges();
                    }
                }
                break;
            }
        }
Пример #6
0
 public Entity.ProductPublishSql SeeData(int id)
 {
     return(ProductPublishSqlRepository.Find(o => o.Id == id));
 }
Пример #7
0
        public void RemoveData(int id)
        {
            var obj = ProductPublishSqlRepository.Find(o => o.Id == id);

            ProductPublishSqlRepository.Remove(obj);
        }