コード例 #1
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            long articleId = 0;

            long.TryParse(httpContext.Request.QueryString["id"], out articleId);
            var articleService = new ArticleService();

            var viewModel = new ArticleDetailViewModel
            {
                Current = articleService.Get(articleId)
            };

            if (viewModel.Current != null)
            {
                var layout = httpContext.GetLayout();
                layout.Page.MetaKeyWorlds   = viewModel.Current.MetaKeyWords;
                layout.Page.MetaDescription = viewModel.Current.MetaDescription;
                layout.Page.Title           = viewModel.Current.Title;

                return(widget.ToWidgetPart(viewModel));
            }
            else
            {
                return(widget.ToWidgetPart(null));
            }
        }
コード例 #2
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            var currentWidget = widget as ArticleTopWidget;
            var page          = new Pagination
            {
                PageIndex = 0,
                PageSize  = currentWidget.Tops ?? 20
            };
            var viewModel = new ArticleTopWidgetViewModel
            {
                Widget = currentWidget
            };
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("CreateDate", OrderType.Descending);
            var articleTypeService = ServiceLocator.Current.GetInstance <IArticleTypeService>();

            var ids = articleTypeService.Get(new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ArticleTypeID)).Select(m => m.ID);

            if (ids.Any())
            {
                filter.Where("ArticleTypeID", OperatorType.In, ids.Concat(new[] { currentWidget.ArticleTypeID }));
            }
            else
            {
                filter.Where("ArticleTypeID", OperatorType.Equal, currentWidget.ArticleTypeID);
            }

            viewModel.Articles = ServiceLocator.Current.GetInstance <IArticleService>().Get(filter, page);
            return(widget.ToWidgetPart(viewModel));
        }
コード例 #3
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            int articleId = controllerContext.RouteData.GetPost();
            var viewModel = new ArticleDetailViewModel
            {
                Current = ServiceLocator.Current.GetInstance <IArticleService>().Get(articleId)
            };

            if (viewModel.Current == null)
            {
                viewModel.Current = new ArticleEntity
                {
                    Title          = "文章明细组件使用说明",
                    ImageUrl       = "~/Modules/Article/Content/Image/Example.png",
                    ArticleContent = "<p>如上图所示,该组件需要一个<code>文章列表组件</code>组合使用,您需要在其它页面添加一个文章列表组件并链接过来,然后点击文章列表中的文章,该组件就可正常显示文章的内容</p>",
                    CreatebyName   = "ZKEASOFT"
                };
            }
            var layout = controllerContext.HttpContext.GetLayout();

            layout.Page.MetaKeyWorlds   = viewModel.Current.MetaKeyWords;
            layout.Page.MetaDescription = viewModel.Current.MetaDescription;
            layout.Page.Title           = viewModel.Current.Title;
            return(widget.ToWidgetPart(viewModel));
        }
コード例 #4
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            long articleId = 0;

            long.TryParse(httpContext.Request.QueryString["id"], out articleId);


            var viewModel = new ArticleDetailViewModel
            {
                Current = ServiceLocator.Current.GetInstance <IArticleService>().Get(articleId)
            };

            if (viewModel.Current != null)
            {
                var layout = httpContext.GetLayout();
                layout.Page.MetaKeyWorlds   = viewModel.Current.MetaKeyWords;
                layout.Page.MetaDescription = viewModel.Current.MetaDescription;
                layout.Page.Title           = viewModel.Current.Title;
            }
            else
            {
                viewModel.Current = new ArticleEntity
                {
                    Title          = "文章明细组件",
                    ImageUrl       = "~/Modules/Article/Content/Image/Example.png",
                    ArticleContent = "<p>如上图所示,该组件需要一个<code>文章列表组件</code>组合使用,您需要在其它页面添加一个文章列表组件并链接过来,然后点击文章列表中的文章,该组件就可正常显示文章的内容</p>",
                    CreatebyName   = "ZKEASOFT"
                };
            }
            return(widget.ToWidgetPart(viewModel));
        }
コード例 #5
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            var currentWidget = widget as NavigationWidget;
            var navs          = ServiceLocator.Current.GetInstance <INavigationService>().Get(new DataFilter().OrderBy("DisplayOrder", OrderType.Ascending))
                                .Where(m => m.Status == (int)RecordStatus.Active).ToList();

            string           path    = "~" + controllerContext.HttpContext.Request.Path.ToLower();
            NavigationEntity current = null;
            int length = 0;

            foreach (var navigationEntity in navs)
            {
                if (navigationEntity.Url.IsNotNullAndWhiteSpace() &&
                    path.StartsWith(navigationEntity.Url.ToLower()) &&
                    length < navigationEntity.Url.Length)
                {
                    current = navigationEntity;
                    length  = navigationEntity.Url.Length;
                }
            }
            if (current != null)
            {
                current.IsCurrent = true;
            }
            if (currentWidget.RootID.IsNullOrEmpty() || currentWidget.RootID == "root")
            {
                currentWidget.RootID = "#";
            }
            return(widget.ToWidgetPart(new NavigationWidgetViewModel(navs, currentWidget)));
        }
コード例 #6
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            long productId = 0;

            long.TryParse(httpContext.Request.QueryString["id"], out productId);
            var service = new ProductService();

            return(widget.ToWidgetPart(service.Get(productId)));
        }
コード例 #7
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            if (ParentPages == null)
            {
                ParentPages = new List <PageEntity>();
                GetParentPage(httpContext.GetLayout().Page);
            }

            return(widget.ToWidgetPart(ParentPages));
        }
コード例 #8
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            ProductListWidget pwidget = widget as ProductListWidget;
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("CreateDate", OrderType.Descending);
            int p;

            int.TryParse(httpContext.Request.QueryString["p"], out p);
            int c;

            if (int.TryParse(httpContext.Request.QueryString["pc"], out c))
            {
                filter.Where("ProductCategoryID", OperatorType.Equal, c);
            }
            else
            {
                var categoryService = ServiceLocator.Current.GetInstance <IProductCategoryService>();
                var ids             = categoryService.Get(new DataFilter().Where("ParentID", OperatorType.Equal, pwidget.ProductCategoryID)).Select(m => m.ID);
                if (ids.Any())
                {
                    filter.Where("ProductCategoryID", OperatorType.In, ids);
                }
                else
                {
                    filter.Where("ProductCategoryID", OperatorType.Equal, pwidget.ProductCategoryID);
                }
            }


            var service = ServiceLocator.Current.GetInstance <IProductService>();
            IEnumerable <ProductEntity> products = null;
            var page = new Pagination {
                PageIndex = p, PageSize = pwidget.PageSize ?? 20
            };

            if (pwidget.IsPageable)
            {
                products = service.Get(filter, page);
            }
            else
            {
                products = service.Get(filter);
            }
            return(widget.ToWidgetPart(new ProductListWidgetViewModel
            {
                Products = products,
                Page = page,
                IsPageable = pwidget.IsPageable,
                Columns = pwidget.Columns,
                DetailPageUrl = pwidget.DetailPageUrl
            }));
        }
コード例 #9
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            long articleId = 0;

            long.TryParse(httpContext.Request.QueryString["id"], out articleId);
            var articleService = new ArticleService();

            var viewModel = new ArticleDetailViewModel
            {
                Current = articleService.Get(articleId)
            };

            return(widget.ToWidgetPart(viewModel));
        }
コード例 #10
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            int category = controllerContext.RouteData.GetCategory();
            ProductCategoryWidget currentWidget = widget as ProductCategoryWidget;
            var categoryService = ServiceLocator.Current.GetInstance <IProductCategoryService>();
            var filter          = new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ProductCategoryID);

            return(widget.ToWidgetPart(new ProductCategoryWidgetViewModel
            {
                Categorys = categoryService.Get(filter),
                CurrentCategory = category,
                TargetPage = currentWidget.TargetPage.IsNullOrEmpty() ? controllerContext.HttpContext.Request.Url.PathAndQuery.ToLower() : currentWidget.TargetPage
            }));
        }
コード例 #11
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            var currentWidget      = widget as ArticleListWidget;
            var articleTypeService = ServiceLocator.Current.GetInstance <IArticleTypeService>();
            int pageIndex          = controllerContext.RouteData.GetPage();
            int category           = controllerContext.RouteData.GetCategory();
            var filter             = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("CreateDate", OrderType.Descending);
            var articleService = ServiceLocator.Current.GetInstance <IArticleService>();
            var pagin          = new Pagination {
                PageIndex = pageIndex, PageSize = currentWidget.PageSize ?? 20
            };

            if (category != 0)
            {
                filter.Where("ArticleTypeID", OperatorType.Equal, category);
            }
            else
            {
                var ids = articleTypeService.Get(new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ArticleTypeID)).Select(m => m.ID);
                if (ids.Any())
                {
                    filter.Where("ArticleTypeID", OperatorType.In, ids.Concat(new[] { currentWidget.ArticleTypeID }));
                }
                else
                {
                    filter.Where("ArticleTypeID", OperatorType.Equal, currentWidget.ArticleTypeID);
                }
            }

            var categoryEntity = articleTypeService.Get(category == 0 ? currentWidget.ArticleTypeID : category);

            if (categoryEntity != null)
            {
                var page = controllerContext.HttpContext.GetLayout().Page;
                page.Title = (page.Title ?? "") + " - " + categoryEntity.Title;
            }

            return(widget.ToWidgetPart(new ArticleListWidgetViewModel
            {
                Articles = currentWidget.IsPageable ? articleService.Get(filter, pagin) : articleService.Get(filter),
                Widget = currentWidget,
                Pagin = pagin,
                CategoryTitle = categoryEntity == null ? "" : categoryEntity.Title,
                IsPageable = currentWidget.IsPageable
            }));
        }
コード例 #12
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            ProductCategoryWidget currentWidget = widget as ProductCategoryWidget;
            int c;
            var categoryService = ServiceLocator.Current.GetInstance <IProductCategoryService>();

            int.TryParse(httpContext.Request.QueryString["pc"], out c);
            var filter = new Data.DataFilter().Where("ParentID", Data.OperatorType.Equal, currentWidget.ProductCategoryID);

            return(widget.ToWidgetPart(new ProductCategoryWidgetViewModel
            {
                Categorys = categoryService.Get(filter),
                CurrentCategory = c,
                TargetPage = currentWidget.TargetPage.IsNullOrEmpty() ? httpContext.Request.Url.PathAndQuery.ToLower() : currentWidget.TargetPage
            }));
        }
コード例 #13
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            int category = controllerContext.RouteData.GetCategory();

            ArticleTypeWidget currentWidget = widget as ArticleTypeWidget;
            var service = ServiceLocator.Current.GetInstance <IArticleTypeService>();
            var filter  = new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ArticleTypeID);

            return(widget.ToWidgetPart(new ArticleTypeWidgetViewModel
            {
                ArticleTypes = service.Get(filter),
                CurrentType = service.Get(currentWidget.ArticleTypeID),
                TargetPage = currentWidget.TargetPage.IsNullOrEmpty() ? controllerContext.HttpContext.Request.Url.PathAndQuery.ToLower() : currentWidget.TargetPage,
                ArticleTypeID = category
            }));
        }
コード例 #14
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            ArticleTypeWidget currentWidget = widget as ArticleTypeWidget;
            var service = new ArticleTypeService();
            var filter  = new Data.DataFilter().Where("ParentID", Data.OperatorType.Equal, currentWidget.ArticleTypeID);
            int ac      = 0;

            int.TryParse(httpContext.Request.QueryString["ac"], out ac);
            return(widget.ToWidgetPart(new ArticleTypeWidgetViewModel
            {
                ArticleTypes = service.Get(filter),
                CurrentType = service.Get(currentWidget.ArticleTypeID),
                TargetPage = currentWidget.TargetPage.IsNullOrEmpty() ? httpContext.Request.Url.PathAndQuery.ToLower() : currentWidget.TargetPage,
                ArticleTypeID = ac
            }));
        }
コード例 #15
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            var currentWidget      = widget as ArticleListWidget;
            var articleTypeService = ServiceLocator.Current.GetInstance <IArticleTypeService>();
            var categoryEntity     = articleTypeService.Get(currentWidget.ArticleTypeID);
            int pageIndex          = 0;
            int ac = 0;

            int.TryParse(httpContext.Request.QueryString["ac"], out ac);
            int.TryParse(httpContext.Request.QueryString["p"], out pageIndex);
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("CreateDate", OrderType.Descending);
            var articleService = ServiceLocator.Current.GetInstance <IArticleService>();
            var page           = new Pagination {
                PageIndex = pageIndex, PageSize = currentWidget.PageSize ?? 20
            };

            if (ac != 0)
            {
                filter.Where("ArticleTypeID", OperatorType.Equal, ac);
            }
            else
            {
                var ids = articleTypeService.Get(new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ArticleTypeID)).Select(m => m.ID);
                if (ids.Any())
                {
                    filter.Where("ArticleTypeID", OperatorType.In, ids);
                }
                else
                {
                    filter.Where("ArticleTypeID", OperatorType.Equal, currentWidget.ArticleTypeID);
                }
            }
            return(widget.ToWidgetPart(new ArticleListWidgetViewModel
            {
                Articles = currentWidget.IsPageable ? articleService.Get(filter, page) : articleService.Get(filter),
                Widget = currentWidget,
                Pagin = page,
                CategoryTitle = categoryEntity == null ? "" : categoryEntity.Title,
                IsPageable = currentWidget.IsPageable
            }));
        }
コード例 #16
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            ProductListWidget pwidget = widget as ProductListWidget;
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            int p;

            int.TryParse(httpContext.Request.QueryString["p"], out p);
            int c;

            if (int.TryParse(httpContext.Request.QueryString["pc"], out c))
            {
                filter.Where("ProductCategoryID", OperatorType.Equal, c);
            }
            else
            {
                filter.Where("ProductCategoryID", OperatorType.Equal, pwidget.ProductCategoryID);
            }


            var service = new ProductService();
            IEnumerable <Models.Product> products = null;
            var page = new Pagination {
                PageIndex = p, PageSize = pwidget.PageSize ?? 20
            };

            if (pwidget.IsPageable)
            {
                products = service.Get(filter, page);
            }
            else
            {
                products = service.Get(filter);
            }
            return(widget.ToWidgetPart(new ProductListWidgetViewModel()
            {
                Products = products,
                Page = page,
                IsPageable = pwidget.IsPageable,
                Columns = pwidget.Columns,
                DetailPageUrl = pwidget.DetailPageUrl
            }));
        }
コード例 #17
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            var currentWidget = widget as ArticleTopWidget;
            var page          = new Pagination
            {
                PageIndex = 0,
                PageSize  = currentWidget.Tops ?? 20
            };
            var viewModel = new ArticleTopWidgetViewModel
            {
                Widget = currentWidget
            };
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("PublishDate", OrderType.Descending);
            viewModel.Articles = new ArticleService().Get(filter.Where("ArticleCategoryID", OperatorType.Equal, currentWidget.ArticleCategoryID), page);
            return(widget.ToWidgetPart(viewModel));
        }
コード例 #18
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            int productId = controllerContext.RouteData.GetPost();
            var service   = ServiceLocator.Current.GetInstance <IProductService>();
            var product   = service.Get(productId) ?? new ProductEntity
            {
                Title          = "产品明细组件使用说明",
                ImageUrl       = "~/Modules/Product/Content/Image/Example.png",
                ProductContent = "<p>如上图所示,该组件需要一个<code>产品列表组件</code>组合使用,您需要在其它页面添加一个产品列表组件并链接过来,然后点击产品列表中的产品,该组件就可正常显示产品的内容</p>",
                CreatebyName   = "ZKEASOFT"
            };

            var page = controllerContext.HttpContext.GetLayout().Page;

            page.MetaDescription = product.SEODescription;
            page.MetaKeyWorlds   = product.SEOKeyWord;
            page.Title           = product.SEOTitle ?? product.Title;

            return(widget.ToWidgetPart(product));
        }
コード例 #19
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            long productId = 0;

            long.TryParse(httpContext.Request.QueryString["id"], out productId);
            var service = ServiceLocator.Current.GetInstance <IProductService>();
            var product = service.Get(productId);

            if (product != null)
            {
                var page = httpContext.GetLayout().Page;
                if (product.SEODescription.IsNotNullAndWhiteSpace())
                {
                    page.MetaDescription = product.SEODescription;
                }
                if (product.SEOKeyWord.IsNotNullAndWhiteSpace())
                {
                    page.MetaKeyWorlds = product.SEOKeyWord;
                }
                if (product.SEOTitle.IsNotNullAndWhiteSpace())
                {
                    page.Title = product.SEOTitle;
                }
            }
            else
            {
                product = new ProductEntity
                {
                    Title          = "产品明细组件",
                    ImageUrl       = "~/Modules/Product/Content/Image/Example.png",
                    ProductContent = "<p>如上图所示,该组件需要一个<code>产品列表组件</code>组合使用,您需要在其它页面添加一个产品列表组件并链接过来,然后点击产品列表中的产品,该组件就可正常显示产品的内容</p>",
                    CreatebyName   = "ZKEASOFT"
                };
            }

            return(widget.ToWidgetPart(product));
        }
コード例 #20
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            var currentWidget      = widget as ArticleListWidget;
            var articleTypeService = new ArticleTypeService();
            var categoryEntity     = articleTypeService.Get(currentWidget.ArticleCategoryID);
            int pageIndex          = 0;
            int ac = 0;

            int.TryParse(httpContext.Request.QueryString["ac"], out ac);
            int.TryParse(httpContext.Request.QueryString["p"], out pageIndex);
            var filter = new Data.DataFilter();

            filter.Where("IsPublish=true");
            filter.OrderBy("PublishDate", OrderType.Descending);
            var articleService = new ArticleService();
            var page           = new Data.Pagination {
                PageIndex = pageIndex, PageSize = currentWidget.PageSize ?? 20
            };

            if (ac != 0)
            {
                filter.Where("ArticleCategoryID", OperatorType.Equal, ac);
            }
            else if (currentWidget.ArticleCategoryID.HasValue)
            {
                filter.Where("ArticleCategoryID", OperatorType.Equal, currentWidget.ArticleCategoryID);
            }
            return(widget.ToWidgetPart(new ArticleListWidgetViewModel
            {
                Articles = currentWidget.IsPageable ? articleService.Get(filter, page) : articleService.Get(filter),
                Widget = currentWidget,
                Pagin = page,
                CategoryTitle = categoryEntity == null ? "" : categoryEntity.Title,
                IsPageable = currentWidget.IsPageable
            }));
        }
コード例 #21
0
        public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
        {
            ProductListWidget currentWidget = widget as ProductListWidget;
            var filter = new DataFilter();

            filter.Where("IsPublish", OperatorType.Equal, true);
            filter.OrderBy("CreateDate", OrderType.Descending);
            var categoryService = ServiceLocator.Current.GetInstance <IProductCategoryService>();

            int pageIndex = controllerContext.RouteData.GetPage();
            int category  = controllerContext.RouteData.GetCategory();

            if (category > 0)
            {
                filter.Where("ProductCategoryID", OperatorType.Equal, category);
            }
            else
            {
                var ids = categoryService.Get(new DataFilter().Where("ParentID", OperatorType.Equal, currentWidget.ProductCategoryID)).Select(m => m.ID);
                if (ids.Any())
                {
                    filter.Where("ProductCategoryID", OperatorType.In, ids.Concat(new[] { currentWidget.ProductCategoryID }));
                }
                else
                {
                    filter.Where("ProductCategoryID", OperatorType.Equal, currentWidget.ProductCategoryID);
                }
            }


            var service = ServiceLocator.Current.GetInstance <IProductService>();
            IEnumerable <ProductEntity> products = null;
            var pagin = new Pagination {
                PageIndex = pageIndex, PageSize = currentWidget.PageSize ?? 20
            };

            if (currentWidget.IsPageable)
            {
                products = service.Get(filter, pagin);
            }
            else
            {
                products = service.Get(filter);
            }

            var categoryEntity = categoryService.Get(category == 0 ? currentWidget.ProductCategoryID : category);

            if (categoryEntity != null)
            {
                var page = controllerContext.HttpContext.GetLayout().Page;
                page.Title = (page.Title ?? "") + " - " + categoryEntity.Title;
            }

            return(widget.ToWidgetPart(new ProductListWidgetViewModel
            {
                Products = products,
                Page = pagin,
                IsPageable = currentWidget.IsPageable,
                Columns = currentWidget.Columns,
                DetailPageUrl = currentWidget.DetailPageUrl
            }));
        }
コード例 #22
0
 public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
 {
     return(widget.ToWidgetPart(new MessageEntity()));
 }
コード例 #23
0
        public override WidgetPart Display(WidgetBase widget, HttpContextBase httpContext)
        {
            var navs = new NavigationService().Get(new Data.DataFilter().OrderBy("DisplayOrder", OrderType.Ascending));

            return(widget.ToWidgetPart(new NavigationWidgetViewModel(navs, widget as NavigationWidget)));
        }
コード例 #24
0
 public override WidgetPart Display(WidgetBase widget, ControllerContext controllerContext)
 {
     return(widget.ToWidgetPart(ServiceLocator.Current.GetInstance <IMessageService>().Get(m => m.Status == (int)Constant.RecordStatus.Active)));
 }