Beispiel #1
0
        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
            }));
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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());
        }
Beispiel #5
0
 public OpResult SaveOrUpdate(Entity.ProductDictionaryVer obj)
 {
     if (obj.Id == 0)
     {
         obj.DictId    = CommonService.GUID;
         obj.CreateDT  = DateTime.Now;
         obj.UpdateDT  = obj.CreateDT;
         obj.UpdateUID = CurrentUser.UID;
         obj.CreateUID = obj.UpdateUID;
         ProductDictionaryVerRepository.Add(obj, false);
     }
     else
     {
         var product = ProductDictionaryVerRepository.Find(o => o.Id == obj.Id);
         product.UpdateUID = CurrentUser.UID;
         product.UpdateDT  = DateTime.Now;
     }
     ProductDictionaryVerRepository.SaveChanges();
     return(OpResult.Success());
 }
Beispiel #6
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());
        }
Beispiel #7
0
 public Entity.ProductDictionaryVer Get(string verId)
 {
     return(ProductDictionaryVerRepository.GetQuery(o => o.DictId == verId).Include(o => o.ProductDictionaryDatas).FirstOrDefault());
 }
Beispiel #8
0
        public OpResult SaveData(Entity.ProductDictionaryData obj, int productId)
        {
            if (obj.Id == 0)
            {
                if (ProductDictionaryVerRepository.IsExists(o => o.ProductId == productId && o.Status == 0 && o.DictId != obj.DictId))
                {
                    return(OpResult.Fail("已存在未发布的版本"));
                }
                obj.DictId = obj.DictId ?? CommonService.GUID;
                obj.DicSN  = ProductDictionaryDataRepository.GetMaxInt(o => (int?)o.DicSN, whereLambda: o => o.DictId == obj.DictId);
                if (obj.DicPSN > 0)
                {
                    var parent = ProductDictionaryDataRepository.Find(o => o.DictId == obj.DictId && o.DicSN == obj.DicPSN);
                    if (parent != null)
                    {
                        parent.HasChild = true;
                    }
                }
                obj.CreateDT  = DateTime.Now;
                obj.CreateUID = CurrentUser.UID;
                obj.SortOrder = ProductDictionaryDataRepository.GetMaxInt(o => (int?)o.SortOrder, whereLambda: o => o.DictId == obj.DictId);
                ProductDictionaryDataRepository.Add(obj, false);
            }
            else
            {
                var menu = ProductDictionaryDataRepository.Get(obj.Id);
                if (ProductDictionaryDataRepository.IsExists(o => o.Title == obj.Title && o.DictId == menu.DictId && o.DicPSN == menu.DicPSN && o.Id != obj.Id))
                {
                    return(OpResult.Fail("该分类名称已存在"));
                }
                if (menu.HasChild != obj.HasChild && ProductDictionaryDataRepository.IsExists(o => o.DictId == menu.DictId && o.DicPSN == menu.DicSN))
                {
                    return(OpResult.Fail("存在下级不允许修改!"));
                }
                //obj.ToCopyProperty(menu, new List<string>() { "CreateDT", "CreateUID", "MenuId", "SortOrder" });
                menu.Title    = obj.Title;
                menu.HasChild = obj.HasChild;
                obj.DictId    = menu.DictId;
            }
            var model = ProductDictionaryVerRepository.Find(o => o.DictId == obj.DictId);

            if (model != null)
            {
                model.UpdateDT  = DateTime.Now;
                model.UpdateUID = CurrentUser.UID;
            }
            else
            {
                ProductDictionaryVerRepository.Add(new Entity.ProductDictionaryVer()
                {
                    DictId    = obj.DictId,
                    ProductId = productId,
                    CreateDT  = obj.CreateDT,
                    UpdateDT  = obj.CreateDT,
                    UpdateUID = obj.CreateUID,
                    CreateUID = obj.CreateUID,
                }, false);
            }
            ProductDictionaryDataRepository.SaveChanges();
            return(OpResult.Success());
        }
Beispiel #9
0
 public OpResult SaveVer(Entity.ProductPublishVer obj)
 {
     if (ProductPublishVerRepository.IsExists(o => o.ProductId == obj.ProductId && o.VerStatus == 0 && o.Id != obj.Id))
     {
         return(OpResult.Fail("已存在未发布的版本"));
     }
     if (obj.HasModelId == "1")
     {
         if (obj.ModuleId.IsNullOrEmpty())
         {
             var model = ProductModuleVerRepository.GetOfficialLast(obj.ProductId);
             if (model == null)
             {
                 return(OpResult.Fail("功能升级未发布正式版!"));
             }
             obj.ModuleId = model.ModuleId;
         }
     }
     else
     {
         obj.ModuleId = "";
     }
     if (obj.HasRoleId == "1")
     {
         if (obj.RoleId.IsNullOrEmpty())
         {
             var model = ProductRoleVerRepository.GetOfficialLast(obj.ProductId);
             if (model == null)
             {
                 return(OpResult.Fail("角色升级未发布正式版!"));
             }
             obj.RoleId = model.RoleVerId;
         }
     }
     else
     {
         obj.RoleId = "";
     }
     if (obj.HasDictId == "1")
     {
         if (obj.DictId.IsNullOrEmpty())
         {
             var model = ProductDictionaryVerRepository.GetOfficialLast(obj.ProductId);
             if (model == null)
             {
                 return(OpResult.Fail("字典升级未发布正式版!"));
             }
             obj.DictId = model.DictId;
         }
     }
     else
     {
         obj.DictId = "";
     }
     if (obj.HasDataId == "1")
     {
         if (obj.DataId.IsNullOrEmpty())
         {
             var model = ProductDataVerRepository.GetOfficialLast(obj.ProductId);
             if (model == null)
             {
                 return(OpResult.Fail("初始数据升级未发布正式版!"));
             }
             obj.DataId = model.DataId;
         }
     }
     else
     {
         obj.DataId = "";
     }
     return(SaveOrUpdate(obj));
 }