Ejemplo n.º 1
0
        private IEnumerable <Webpage> GetWebpageCopies(Site @from, Site to, SiteCloneContext siteCloneContext,
                                                       Webpage fromParent = null,
                                                       Webpage toParent   = null)
        {
            IQueryOver <Webpage, Webpage> queryOver =
                _session.QueryOver <Webpage>().Where(webpage => webpage.Site.Id == @from.Id);

            queryOver = fromParent == null
                ? queryOver.Where(webpage => webpage.Parent == null)
                : queryOver.Where(webpage => webpage.Parent.Id == fromParent.Id);

            IList <Webpage> webpages = queryOver.List();

            foreach (Webpage webpage in webpages)
            {
                Webpage copy = webpage.GetCopyForSite(to);
                siteCloneContext.AddEntry(webpage, copy);
                copy.Parent = toParent;
                yield return(copy);

                foreach (Webpage child in GetWebpageCopies(@from, to, siteCloneContext, webpage, copy))
                {
                    yield return(child);
                }
            }
        }
Ejemplo n.º 2
0
        private IEnumerable <Layout> GetLayoutCopies(Site @from, Site to, SiteCloneContext siteCloneContext, Layout fromParent = null, Layout toParent = null)
        {
            IQueryOver <Layout, Layout> queryOver = _session.QueryOver <Layout>().Where(layout => layout.Site.Id == @from.Id);

            queryOver = fromParent == null
                ? queryOver.Where(layout => layout.Parent == null)
                : queryOver.Where(layout => layout.Parent.Id == fromParent.Id);

            IList <Layout> layouts = queryOver.List();

            foreach (Layout layout in layouts)
            {
                Layout copy = layout.GetCopyForSite(to);
                siteCloneContext.AddEntry(layout, copy);
                copy.LayoutAreas = layout.LayoutAreas.Select(area =>
                {
                    LayoutArea areaCopy = area.GetCopyForSite(to);
                    siteCloneContext.AddEntry(area, areaCopy);
                    areaCopy.Layout  = copy;
                    areaCopy.Widgets = area.Widgets
                                       .Where(widget => widget.Webpage == null)
                                       .Select(widget =>
                    {
                        Entities.Widget.Widget widgetCopy = widget.GetCopyForSite(to);
                        siteCloneContext.AddEntry(widget, widgetCopy);
                        widgetCopy.LayoutArea = areaCopy;
                        return(widgetCopy);
                    })
                                       .ToList();
                    return(areaCopy);
                }).ToList();
                copy.Parent = toParent;
                yield return(copy);

                foreach (Layout child in GetLayoutCopies(@from, to, siteCloneContext, layout, copy))
                {
                    yield return(child);
                }
            }
        }
Ejemplo n.º 3
0
 public override void ClonePart(Webpage @from, Webpage to, SiteCloneContext siteCloneContext)
 {
     if ([email protected]())
     {
         return;
     }
     _session.Transact(session =>
     {
         foreach (var urlHistory in @from.Urls)
         {
             var copy     = urlHistory.GetCopyForSite(to.Site);
             copy.Webpage = to;
             to.Urls.Add(copy);
             siteCloneContext.AddEntry(urlHistory, copy);
             session.Save(copy);
             session.Update(to);
         }
     });
 }
Ejemplo n.º 4
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            using (new SiteFilterDisabler(_session))
            {
                var existingTemplates =
                    _session.QueryOver <PageTemplate>().Where(template => template.Site.Id == @from.Id).List();

                _session.Transact(session =>
                {
                    foreach (var template in existingTemplates)
                    {
                        var copy = template.GetCopyForSite(to);
                        if (template.Layout != null)
                        {
                            copy.Layout = siteCloneContext.FindNew <Layout>(template.Layout.Id);
                        }
                        session.Save(copy);
                        siteCloneContext.AddEntry(template, copy);
                    }
                });
            }
        }
Ejemplo n.º 5
0
 public override void ClonePart(Webpage @from, Webpage to, SiteCloneContext siteCloneContext)
 {
     if ([email protected]())
     {
         return;
     }
     _session.Transact(session =>
     {
         foreach (var property in @from.FormProperties)
         {
             var copy     = property.GetCopyForSite(to.Site);
             copy.Webpage = to;
             if (to.FormProperties == null)
             {
                 to.FormProperties = new List <FormProperty>();
             }
             to.FormProperties.Add(copy);
             siteCloneContext.AddEntry(property, copy);
             session.Save(copy);
             session.Update(to);
         }
     });
 }
Ejemplo n.º 6
0
        private IEnumerable <MediaCategory> GetMediaCategoryCopies(Site @from, Site to, SiteCloneContext siteCloneContext, MediaCategory fromParent = null, MediaCategory toParent = null)
        {
            IQueryOver <MediaCategory, MediaCategory> queryOver =
                _session.QueryOver <MediaCategory>().Where(layout => layout.Site.Id == @from.Id);

            queryOver = fromParent == null
                ? queryOver.Where(layout => layout.Parent == null)
                : queryOver.Where(layout => layout.Parent.Id == fromParent.Id);

            IList <MediaCategory> categories = queryOver.List();

            foreach (MediaCategory category in categories)
            {
                MediaCategory copy = category.GetCopyForSite(to);
                siteCloneContext.AddEntry(category, copy);
                copy.Parent = toParent;
                yield return(copy);

                foreach (MediaCategory child in GetMediaCategoryCopies(@from, to, siteCloneContext, fromParent: category, toParent: copy))
                {
                    yield return(child);
                }
            }
        }