Beispiel #1
0
        public GetItemListResult <NormalMaterialEntity> GetNormalMaterialList(Guid domainId, string appId, GetMaterialListArgs args)
        {
            GetItemListResult <NormalMaterialEntity> result = new GetItemListResult <NormalMaterialEntity>();

            List <AttachedWhereItem> attachedWhere = new List <AttachedWhereItem>();

            attachedWhere.Add(new AttachedWhereItem("Domain", domainId));
            attachedWhere.Add(new AttachedWhereItem("AppId", appId));
            attachedWhere.Add(new AttachedWhereItem("Type", EnumHelper.GetEnumMemberValue(args.Type)));

            SqlExpressionPagingArgs pagingArgs = new SqlExpressionPagingArgs();

            pagingArgs.Page     = args.Page;
            pagingArgs.PageSize = args.PageSize;

            result.ItemList  = _dataBase.Select <NormalMaterialEntity>(attachedWhere, pagingArgs);
            result.TotalPage = pagingArgs.TotalPage;
            result.Page      = pagingArgs.Page;

            if (result.ItemList.Count == 0 && result.Page > 1)
            {
                args.Page--;
                return(GetNormalMaterialList(domainId, appId, args));
            }
            else
            {
                return(result);
            }
        }
Beispiel #2
0
        public List <T> Select <T>(List <AttachedWhereItem> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new()
        {
            SqlExpressionArgs args = new SqlExpressionArgs();

            args.Type          = SqlExpressionType.Select;
            args.GenerateWhere = false;
            args.AttachedWhere = attachedWhere;
            args.PagingArgs    = pagingArgs;

            //不能用 default(T) ,会是null
            SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(new T(), args);

            DataSet  ds       = ExcuteDataSetSqlExpression(sqlExpression);
            List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]);

            if (pagingArgs != null)
            {
                if (ds.Tables.Count > 1)
                {
                    pagingArgs.TotalRow = int.Parse(ds.Tables[1].Rows[0][0].ToString());
                }
                else
                {
                    pagingArgs.TotalRow = ds.Tables[0].Rows.Count;
                }
                pagingArgs.TotalPage = pagingArgs.TotalRow / pagingArgs.PageSize;
                if (pagingArgs.TotalRow % pagingArgs.PageSize > 0)
                {
                    pagingArgs.TotalPage++;
                }
            }

            return(dataList);
        }
Beispiel #3
0
        public GetItemListResult <ArticleMaterialEntity> GetArticleMaterialList(Guid domainId, string appId, GetArticleMaterialListArgs args)
        {
            GetItemListResult <ArticleMaterialEntity> result = new GetItemListResult <ArticleMaterialEntity>();

            List <AttachedWhereItem> attachedWhere = new List <AttachedWhereItem>();

            attachedWhere.Add(new AttachedWhereItem("Domain", domainId));
            attachedWhere.Add(new AttachedWhereItem("AppId", appId));
            if (args.ExceptUnpublished)
            {
                attachedWhere.Add(new AttachedWhereItem("WeixinStatus", 2));
            }

            SqlExpressionPagingArgs pagingArgs = new SqlExpressionPagingArgs();

            pagingArgs.Page     = args.Page;
            pagingArgs.PageSize = args.PageSize;

            result.ItemList  = _dataBase.Select <ArticleMaterialEntity>(attachedWhere, pagingArgs);
            result.TotalPage = pagingArgs.TotalPage;
            result.Page      = pagingArgs.Page;

            if (result.ItemList.Count == 0 && result.Page > 1)
            {
                args.Page--;
                return(GetArticleMaterialList(domainId, appId, args));
            }
            else
            {
                if (result.ItemList.Count > 0)
                {
                    string sql = "SELECT [Id],[ArticleMaterial],[Title],[ThumbMediaId],[ThumbUrl],[ThumbName],[Url],[Index] FROM [ArticleMaterialItem] WHERE ";
                    List <CommandParameter> parameterList = new List <CommandParameter>();
                    for (int i = 0; i < result.ItemList.Count; i++)
                    {
                        parameterList.Add(new CommandParameter("@id" + i, result.ItemList[i].Id));
                        sql += " [ArticleMaterial] = @id" + i;
                        if (i < result.ItemList.Count - 1)
                        {
                            sql += " OR ";
                        }
                    }
                    sql += " ORDER BY [Index]";

                    List <ArticleMaterialItemEntity> itemList =
                        _dataBase.Select <ArticleMaterialItemEntity>(sql, parameterList);

                    foreach (ArticleMaterialEntity item in result.ItemList)
                    {
                        item.ArticleList = (from c in itemList where c.ArticleMaterial == item.Id select c).ToList();
                    }
                }

                return(result);
            }
        }
        public GetItemListResult <PointCommodityEntity> GetPointCommodityList(Guid domainId, string appId, GetPointCommodityListArgs args)
        {
            GetItemListResult <PointCommodityEntity> result = new GetItemListResult <PointCommodityEntity>();

            List <AttachedWhereItem> attachedWhere = new List <AttachedWhereItem>();

            attachedWhere.Add(new AttachedWhereItem("Domain", domainId));
            attachedWhere.Add(new AttachedWhereItem("AppId", appId));
            attachedWhere.Add(new AttachedWhereItem("Remove", false));
            if (String.IsNullOrEmpty(args.Name) == false)
            {
                attachedWhere.Add(new AttachedWhereItem("Name", args.Name)
                {
                    Type = AttachedWhereType.Like
                });
            }
            if (args.ForSale.HasValue)
            {
                attachedWhere.Add(new AttachedWhereItem("ForSale", args.ForSale));
            }

            SqlExpressionPagingArgs pagingArgs = new SqlExpressionPagingArgs();

            pagingArgs.Page     = args.Page;
            pagingArgs.PageSize = args.PageSize;

            result.ItemList  = _dataBase.Select <PointCommodityEntity>(attachedWhere, pagingArgs);
            result.TotalPage = pagingArgs.TotalPage;
            result.Page      = pagingArgs.Page;

            if (result.ItemList.Count == 0 && result.Page > 1)
            {
                args.Page--;
                return(GetPointCommodityList(domainId, appId, args));
            }
            else
            {
                return(result);
            }
        }
Beispiel #5
0
 public List <T> Select <T>(SqlExpressionPagingArgs pagingArgs) where T : class, new()
 {
     return(Select <T>(new List <AttachedWhereItem>(), pagingArgs));
 }
Beispiel #6
0
 public List <T> Select <T>(Dictionary <string, object> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new()
 {
     return(Select <T>(AttachedWhereItem.Parse(attachedWhere), pagingArgs));
 }