Ejemplo n.º 1
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ZoneWidgetCollection zones = new ZoneWidgetCollection();

            //Page
            string pageId = filterContext.RequestContext.HttpContext.Request.QueryString["ID"];
            PageService pageService = new PageService();
            PageEntity page = pageService.Get(pageId);

            if (page != null)
            {
                LayoutService layoutService = new LayoutService();
                var layout = layoutService.Get(page.LayoutId);
                layout.Page = page;
                WidgetService widgetService = new WidgetService();
                IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where<WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID));
                Action<WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver;
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            WidgetCollection partCollection = new WidgetCollection();
                            partCollection.Add(part);
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                widgets.Each(processWidget);

                IEnumerable<WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where<WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId));

                Layoutwidgets.Each(processWidget);

                layout.ZoneWidgets = zones;
                ViewResult viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Ejemplo n.º 2
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ZoneWidgetCollection zones = new ZoneWidgetCollection();

            //Page
            string      pageId      = filterContext.RequestContext.HttpContext.Request.QueryString["ID"];
            PageService pageService = new PageService();
            PageEntity  page        = pageService.Get(pageId);

            if (page != null)
            {
                LayoutService layoutService = new LayoutService();
                var           layout        = layoutService.Get(page.LayoutId);
                layout.Page = page;
                WidgetService            widgetService = new WidgetService();
                IEnumerable <WidgetBase> widgets       = widgetService.Get(new DataFilter().Where <WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID));
                Action <WidgetBase>      processWidget = m =>
                {
                    IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver;
                    WidgetPart        part       = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            WidgetCollection partCollection = new WidgetCollection();
                            partCollection.Add(part);
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                widgets.Each(processWidget);

                IEnumerable <WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where <WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId));

                Layoutwidgets.Each(processWidget);

                layout.ZoneWidgets = zones;
                ViewResult viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Ejemplo n.º 3
0
        public void TheWidgetShouldBeReturned()
        {
            //Arrange
            List<DomainWidget> values = new List<DomainWidget>
            {
                new DomainWidget
                {
                    Name = "Test Widget",
                    Description = "A test widget",
                    Manufacturer = "Radix2"
                },
                new DomainWidget
                {
                    Name = "Second Widget",
                    Description = "A second widget",
                    Manufacturer = "Radix2"
                }

            };
            IQueryable<DomainWidget> valuesQueryable = values.AsQueryable();

            var mockRepository = new Mock<IRepository>();
            mockRepository
                .Setup(x => x.All<DomainWidget>(It.IsAny<String[]>()))
                .Returns(()=> valuesQueryable);

            var widgetService = new WidgetService(mockRepository.Object);

            //Act
            var widgets = widgetService.Get();

            //Assert
            Assert.IsInstanceOf<List<DomainWidget>>(widgets);
        }
Ejemplo n.º 4
0
        public override int Delete(params object[] primaryKeys)
        {
            LayoutEntity layout            = Get(primaryKeys);
            var          layoutHtmlService = new LayoutHtmlService();

            layoutHtmlService.Delete(new Data.DataFilter().Where <LayoutHtml>(m => m.LayoutId, OperatorType.Equal, layout.ID));

            var zoneService = new ZoneService();

            zoneService.Delete(new Data.DataFilter().Where <ZoneEntity>(m => m.LayoutId, OperatorType.Equal, layout.ID));


            var pageService = new Page.PageService();

            pageService.Delete(new DataFilter().Where("LayoutId", OperatorType.Equal, layout.ID));

            var widgetService = new WidgetService();
            var widgets       = widgetService.Get(new DataFilter().Where("LayoutId", OperatorType.Equal, layout.ID));

            widgets.Each(m =>
            {
                m.CreateServiceInstance().DeleteWidget(m.ID);
            });
            Signal.Trigger(LayoutChanged);
            return(base.Delete(primaryKeys));
        }
Ejemplo n.º 5
0
        public JsonResult DeleteWidget(string ID)
        {
            WidgetService widgetService = new WidgetService();
            WidgetBase    widget        = widgetService.Get(ID);

            if (widget != null)
            {
                widget.CreateServiceInstance().DeleteWidget(ID);
                return(Json(true));
            }
            return(Json(false));
        }
Ejemplo n.º 6
0
        public void DeleteVersion(string ID)
        {
            PageEntity page = Get(ID);

            if (page != null)
            {
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                DataArchivedService.Delete(CacheTrigger.PageWidgetsArchivedKey.FormatWith(page.ID));
            }
            base.Delete(ID);
        }
Ejemplo n.º 7
0
 public ActionResult Edit(string ID, string ReturnUrl)
 {
     var widgetService = new WidgetService();
     var widgetBase = widgetService.Get(ID);
     var widget = widgetBase.CreateServiceInstance().GetWidget(widgetBase);
     ViewBag.ReturnUrl = ReturnUrl;
     if (widget.FormView.IsNotNullAndWhiteSpace())
     {
         return View(widget.FormView, widget);
     }
     return View(widget);
 }
Ejemplo n.º 8
0
        public void DeleteVersion(string ID)
        {
            PageEntity page = Get(ID);

            if (page != null)
            {
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                StaticPageCache.Delete(page.ID);
            }
            base.Delete(ID);
        }
Ejemplo n.º 9
0
        public ActionResult Edit(string ID, string ReturnUrl)
        {
            var widgetService = new WidgetService();
            var widgetBase    = widgetService.Get(ID);
            var widget        = widgetBase.CreateServiceInstance().GetWidget(widgetBase);

            ViewBag.ReturnUrl = ReturnUrl;
            if (widget.FormView.IsNotNullAndWhiteSpace())
            {
                return(View(widget.FormView, widget));
            }
            return(View(widget));
        }
        public IActionResult OnGet()
        {
            var widget = service.Get(Id);

            if (widget == null)
            {
                return(NotFound());
            }

            Name = widget.Name;

            return(Page());
        }
Ejemplo n.º 11
0
        public override int Delete(DataFilter filter)
        {
            var deletes = Get(filter).ToList(m => m.ID);

            if (deletes.Any() && Get(new DataFilter().Where("ParentId", OperatorType.In, deletes)).Any())
            {
                Delete(new DataFilter().Where("ParentId", OperatorType.In, deletes));
                Delete(new DataFilter().Where("ReferencePageID", OperatorType.In, deletes));
            }
            if (deletes.Any())
            {
                var widgets = WidgetService.Get(new DataFilter().Where("PageID", OperatorType.In, deletes));
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));

                deletes.Each(p => DataArchivedService.Delete(CacheTrigger.PageWidgetsArchivedKey.FormatWith(p)));
            }
            return(base.Delete(filter));
        }
Ejemplo n.º 12
0
        public override int Delete(params object[] primaryKeys)
        {
            PageEntity page = Get(primaryKeys);

            if (page != null)
            {
                Delete(m => m.ParentId == page.ID);
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                if (page.PublishDate.HasValue)
                {
                    Delete(m => m.ReferencePageID == page.ID);
                }
                DataArchivedService.Delete(CacheTrigger.PageWidgetsArchivedKey.FormatWith(page.ID));
            }


            return(base.Delete(primaryKeys));
        }
Ejemplo n.º 13
0
        public override int Delete(DataFilter filter)
        {
            var deletes = Get(filter).ToList(m => m.ID);

            if (deletes.Any() && Get(new DataFilter().Where("ParentId", OperatorType.In, deletes)).Any())
            {
                Delete(new DataFilter().Where("ParentId", OperatorType.In, deletes));
                Delete(new DataFilter().Where("ReferencePageID", OperatorType.In, deletes));
            }
            if (deletes.Any())
            {
                var widgets = WidgetService.Get(new DataFilter().Where("PageID", OperatorType.In, deletes));
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));

                deletes.Each(p =>
                {
                    StaticPageCache.Delete(p);
                });
            }
            return(base.Delete(filter));
        }
Ejemplo n.º 14
0
        public override int Delete(params object[] primaryKeys)
        {
            PageEntity page = Get(primaryKeys);

            if (page != null)
            {
                Delete(m => m.ParentId == page.ID);
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                if (page.PublishDate.HasValue)
                {
                    Delete(m => m.ReferencePageID == page.ID);
                }
                if (StaticPageCache != null)
                {
                    StaticPageCache.Delete(page.ID);
                }
            }


            return(base.Delete(primaryKeys));
        }
Ejemplo n.º 15
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var zones = new ZoneWidgetCollection();
            var cache = new StaticCache();
            //Page
            string path = filterContext.RequestContext.HttpContext.Request.Path;

            if (path.EndsWith("/") && path.Length > 1)
            {
                path = path.Substring(0, path.Length - 1);
                //filterContext.HttpContext.Response.Redirect(path);
                filterContext.Result = new RedirectResult(path);
                return;
            }
            bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase);
            var  page    = new PageService().GetByPath(path, publish);

            if (page != null)
            {
                var          layoutService = new LayoutService();
                LayoutEntity layout        = layoutService.Get(page.LayoutId);
                layout.Page = page;

                Action <WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                                                             Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                                                             );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection {
                                part
                            };
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var layoutWidgetsTask = Task.Factory.StartNew(layoutId =>
                {
                    var widgetServiceIn = new WidgetService();
                    IEnumerable <WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId));
                    layoutwidgets.Each(processWidget);
                }, page.LayoutId);


                var widgetService = new WidgetService();
                IEnumerable <WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID));
                int middle          = widgets.Count() / 2;
                var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget));
                widgets.Take(middle).Each(processWidget);
                Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask });

                layout.ZoneWidgets = zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Ejemplo n.º 16
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var zones = new ZoneWidgetCollection();
            var cache = new StaticCache();
            //Page
            string path = filterContext.RequestContext.HttpContext.Request.Path;
            if (path.EndsWith("/") && path.Length > 1)
            {
                path = path.Substring(0, path.Length - 1);
                //filterContext.HttpContext.Response.Redirect(path);
                filterContext.Result = new RedirectResult(path);
                return;
            }
            bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase);
            var page = new PageService().GetByPath(path, publish);
            if (page != null)
            {
                var layoutService = new LayoutService();
                LayoutEntity layout = layoutService.Get(page.LayoutId);
                layout.Page = page;

                Action<WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                         Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                    );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection { part };
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var layoutWidgetsTask = Task.Factory.StartNew(layoutId =>
                {
                    var widgetServiceIn = new WidgetService();
                    IEnumerable<WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId));
                    layoutwidgets.Each(processWidget);
                }, page.LayoutId);


                var widgetService = new WidgetService();
                IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID));
                int middle = widgets.Count() / 2;
                var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget));
                widgets.Take(middle).Each(processWidget);
                Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask });

                layout.ZoneWidgets = zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Ejemplo n.º 17
0
 public JsonResult DeleteWidget(string ID)
 {
     WidgetService widgetService = new WidgetService();
     WidgetBase widget = widgetService.Get(ID);
     if (widget != null)
     {
         widget.CreateServiceInstance().DeleteWidget(ID);
         return Json(true);
     }
     return Json(false);
 }