Beispiel #1
0
        public virtual void List(int type, long id, int state = 0, int star1 = 0, int star2 = 0, long page = 1)
        {
            SplitPageData <M.Comment> data;

            switch (state)
            {
            case 1:
                data = M.Comment.GetPageByTypeAndIdAndStar(DataSource, type, id, star1, star2, Math.Max(page, 1), 20, 8);
                break;

            case 2:
                data = M.Comment.GetPageByTypeAndIdAndImage(DataSource, type, id, Math.Max(page, 1), 20, 8);
                break;

            default:
                data = M.Comment.GetPageByTypeAndId(DataSource, type, id, Math.Max(page, 1), 20, 8);
                break;
            }
            this["CommentList"] = data;
            this["GetPageUrl"]  = new FuncHandler((args) =>
            {
                return(GetUrl("/comment/list/", type.ToString(), "/", id.ToString(), "/", state.ToString(), "/", star1.ToString(), "/", star2.ToString(), "/", Convert.ToInt64(args[0]).ToString()));
            });
            Render("comment.html");
        }
Beispiel #2
0
        public void List(long page = 1, Arguments args = null)
        {
            string q = Request.QueryString["q"];

            FilterParameters filter = new FilterParameters();

            filter.Load(page, args);

            this["Q"]             = q;
            this["Filter"]        = filter;
            this["RecommendList"] = M.Product.GetTopRecommendByCategory(DataSource, 5, 0);
            this["ProductList"]   = M.Product.GetPageBySearch(DataSource, Request.QueryString, filter, page, 20, 8);
            string requestParam = string.Format("?q={0}&searchType={1}&id={2}", Request.QueryString["q"], Request.QueryString["searchType"], Request.QueryString["id"]);

            this["PageUrl"] = new FuncHandler((object[] ps) =>
            {
                return(string.Concat(GetUrl("/search/list", filter.CopyByPage(Convert.ToInt64(ps[0])).ToString()), requestParam));
            });
            this["BrandUrl"] = new FuncHandler((object[] ps) =>
            {
                return(string.Concat(GetUrl("/search/list", filter.CopyByBrand(Convert.ToInt32(ps[0])).ToString()), requestParam));
            });
            this["OrderUrl"] = new FuncHandler((object[] ps) =>
            {
                return(string.Concat(GetUrl("/search/list", filter.CopyByOrderBy(Convert.ToInt32(ps[0])).ToString()), requestParam));
            });
            this["AttrUrl"] = new FuncHandler((object[] ps) =>
            {
                return(string.Concat(GetUrl("/search/list", filter.Copy(Convert.ToInt64(ps[0]), ps[1] as string).ToString()), requestParam));
            });

            Render("search.html");
        }
Beispiel #3
0
 public void shoplist(long id, int categoryId, int page = 1)
 {
     this["StoreCategoryList"] = M.StoreCategory.GetStoreCategoryListByUserId(DataSource, id);
     this["Supplier"]          = M.Supplier.GetById(DataSource, id);
     this["StoreInfo"]         = M.StoreInfo.GetStoreInfoByUserId(DataSource, id);
     this["ProductList"]       = M.Product.GetProductListByStoreCategoryId(DataSource, categoryId, page, 16, 8, 1);
     this["PageUrl"]           = new FuncHandler((object[] ps) =>
     {
         return(GetUrl("/product/shoplist/", id.ToString(), "/", categoryId.ToString(), "/", ps[0].ToString()));
     });
     this["categoryId"] = categoryId;
     Render("shoplist.html");
 }
Beispiel #4
0
 private void InitVariableScope()
 {
     _vars          = new VariableScope();
     _vars["this"]  = this;
     _vars["isset"] = new FuncHandler((args) =>
     {
         return(_vars.ContainsKey((string)args[0]));
     });
     _vars["url"] = new FuncHandler((args) =>
     {
         return(GetUrl(Array.ConvertAll(args, new Converter <object, string>((x) =>
         {
             return x.ToString();
         }))));
     });
     _vars["res"] = new FuncHandler((args) =>
     {
         return(GetRes(Array.ConvertAll(args, new Converter <object, string>((x) =>
         {
             return x.ToString();
         }))));
     });
     _vars["urlencode"] = new FuncHandler((args) =>
     {
         return(HttpUtility.UrlEncode(Convert.ToString(args[0])));
     });
     _vars["filesystem"] = new FuncHandler((args) =>
     {
         return(GetFileSystemUrl(Array.ConvertAll(args, new Converter <object, string>((x) =>
         {
             return x.ToString();
         }))));
     });
     _vars["passport"] = new FuncHandler((args) =>
     {
         return(GetPassportUrl(Array.ConvertAll(args, new Converter <object, string>((x) =>
         {
             return x.ToString();
         }))));
     });
     _vars["now"] = DateTime.Now;
     //_vars["ext"] = (Settings.Instance.UrlMode != Configuration.SiteUrlMode.Dynamic) ? Utility.DefaultExt : string.Empty;
     _vars["ext"] = Utility.DefaultExt;
 }
Beispiel #5
0
        private object Excute(object value, TemplateContext context, object[] args, Type[] types)
        {
            if (value != null)
            {
                FuncHandler handler = value as FuncHandler;
                if (handler != null)
                {
                    return(handler.Invoke(args));
                }

                if (value is ClrTag)
                {
                    return(ReflectionHelpers.InvokeMethod(ReflectionHelpers.GetMethod(context, ((ClrTag)value).TargetType, this.Name, types, true), null, args));
                }

                return(ReflectionHelpers.InvokeMethod(ReflectionHelpers.GetMethod(context, value.GetType(), this.Name, types, false), value, args));
            }

            return(null);
        }
Beispiel #6
0
        private Object Excute(Object value, TemplateContext context, Object[] args, Type[] types)
        {
            if (value != null)
            {
                //MethodInfo method = null;// ParserAccessor.GetMethod(value.GetType(), list[list.Length - 1], types);F:\Work\工作区\我的项目\JinianNet.JNTemplate\JinianNet.JNTemplate1.2\src\JinianNet.JNTemplate\Parser\Node\FunctaionTag.cs

                FuncHandler handler = value as FuncHandler;
                //判断是否委托
                if (handler != null)
                {
                    return(handler.Invoke(args));
                }



                //不是委托,则在取方法
                MethodInfo method = Common.ReflectionHelpers.GetMethod(value.GetType(), this.Name, types);
                if (method != null)
                {
                    return(method.Invoke(value, args));
                }
            }
            return(null);
        }
Beispiel #7
0
        public virtual void List(int id, long page = 1, Arguments args = null)
        {
            //int temp;
            //do
            //{
            //    temp = M.ProductCategory.GetDefaultChild(DataSource, id);
            //    if (temp > 0)
            //        id = temp;
            //}
            //while (temp > 0);

            IList <M.ProductCategory> cates = M.ProductCategory.GetAllParentsById(DataSource, id);

            IList <M.ProductAttribute> attrs  = M.ProductAttribute.GetAllByCategory(DataSource, id);
            FilterParameters           filter = new FilterParameters(attrs);

            filter.Load(page, args);

            this["Filter"]          = filter;
            this["Category"]        = M.ProductCategory.GetById(DataSource, id);
            this["CategoryList"]    = cates;
            this["BigCategoryList"] = M.ProductCategory.GetAll(DataSource, cates[0].Id);
            if (cates.Count > 1)
            {
                this["SmallCategoryList"] = M.ProductCategory.GetAll(DataSource, cates[1].Id);
            }
            if (cates.Count > 2)
            {
                this["ThreeCategoryList"] = M.ProductCategory.GetAll(DataSource, cates[2].Id);
            }
            this["BrandList"]     = M.ProductBrand.GetAllByCategory(DataSource, id);
            this["AttributeList"] = attrs;
            this["RecommendList"] = M.Product.GetTopRecommendByCategory(DataSource, 5, id);
            this["ProductList"]   = M.Product.GetBrandPageByArguments(DataSource, id, false, filter, cates.Count, 5);

            this["PageUrl"] = new FuncHandler((object[] ps) =>
            {
                return(GetUrl("/category/list/", id.ToString(), filter.CopyByPage(Convert.ToInt64(ps[0])).ToString()));
            });
            this["BrandUrl"] = new FuncHandler((object[] ps) =>
            {
                return(GetUrl("/category/list/", id.ToString(), filter.CopyByBrand(Convert.ToInt32(ps[0])).ToString()));
            });
            this["OrderUrl"] = new FuncHandler((object[] ps) =>
            {
                return(GetUrl("/category/list/", id.ToString(), filter.CopyByOrderBy(Convert.ToInt32(ps[0])).ToString()));
            });
            this["AttrUrl"] = new FuncHandler((object[] ps) =>
            {
                return(GetUrl("/category/list/", id.ToString(), filter.Copy(Convert.ToInt64(ps[0]), ps[1] as string).ToString()));
            });

            long index = filter.Page;

            filter.Page = 1;
            SplitPageData <DataJoin <M.Product, S.StatisticData> > BrandList = M.Product.GetBrandPageByArguments(DataSource, id, true, filter, cates.Count, 4, 8);

            if (BrandList.PagesCount >= index)
            {
                filter.Page = index;
            }
            else
            {
                filter.Page = BrandList.PagesCount;
            }
            this["BrandProductList"] = M.Product.GetBrandPageByArguments(DataSource, id, true, filter, cates.Count, 4, 8);
            Render("category.html");
        }