Beispiel #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);
                }
            }
        }
Beispiel #2
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var fromProvider      = new SqlConfigurationProvider(_session, @from); // _legacySettingsProvider);
            var toProvider        = new SqlConfigurationProvider(_session, @to);   //, _legacySettingsProvider);
            var siteSettingsBases = fromProvider.GetAllSiteSettings();

            siteSettingsBases.ForEach(toProvider.SaveSettings);
            //AppDataConfigurationProvider.ClearCache();
        }
Beispiel #3
0
 public override void ClonePart(Webpage @from, Webpage to, SiteCloneContext siteCloneContext)
 {
     if (@from.PageTemplate == null)
     {
         return;
     }
     to.PageTemplate = siteCloneContext.FindNew <PageTemplate>(@from.PageTemplate.Id);
     _session.Transact(session => session.Update(to));
 }
Beispiel #4
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var webpages = _session.QueryOver <Webpage>().Where(webpage => webpage.Site.Id == to.Id).List();

            foreach (var webpage in webpages)
            {
                var original = siteCloneContext.GetOriginal(webpage);
                if (original != null)
                {
                    _cloneWebpageSiteParts.Clone(original, webpage, siteCloneContext);
                }
            }
        }
Beispiel #5
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var copies = GetLayoutCopies(@from, to, siteCloneContext);

            _session.Transact(session => copies.ForEach(layout =>
            {
                session.Save(layout);
                var layoutAreas = layout.LayoutAreas.ToList();
                foreach (var layoutArea in layoutAreas)
                {
                    session.Save(layoutArea);
                    layoutArea.Widgets.ForEach(widget => session.Save(widget));
                }
            }));
        }
Beispiel #6
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var toProvider           = new SqlConfigurationProvider(_session, @to);
            var pageDefaultsSettings = toProvider.GetSiteSettings <PageDefaultsSettings>();

            var keys = pageDefaultsSettings.Layouts.Keys.ToList();

            foreach (var key in keys.Where(key => pageDefaultsSettings.Layouts[key].HasValue))
            {
                var layout = siteCloneContext.FindNew <Layout>(pageDefaultsSettings.Layouts[key].Value);
                if (layout != null)
                {
                    pageDefaultsSettings.Layouts[key] = layout.Id;
                }
            }

            toProvider.SaveSettings(pageDefaultsSettings);
        }
 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);
         }
     });
 }
Beispiel #8
0
 public void CloneData(Site site, List <SiteCopyOption> options)
 {
     using (new SiteFilterDisabler(_session))
     {
         var siteCopyOptionInfos =
             options.Select(option => GetSiteCopyOptionInfo(option, _kernel))
             .Where(info => info != null)
             .OrderBy(x => x.Order);
         var siteCloneContext = new SiteCloneContext();
         foreach (var info in siteCopyOptionInfos)
         {
             var @from = _session.Get <Site>(info.SiteId);
             if (@from == null)
             {
                 continue;
             }
             info.CloneSiteParts.Clone(@from, site, siteCloneContext);
         }
     }
 }
Beispiel #9
0
        private IEnumerable <Layout> GetLayoutCopies(Site @from, Site to, SiteCloneContext siteCloneContext, Layout fromParent = null, Layout toParent = null)
        {
            var 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);

            var layouts = queryOver.List();

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

                foreach (var child in GetLayoutCopies(@from, to, siteCloneContext, layout, copy))
                {
                    yield return(child);
                }
            }
        }
Beispiel #10
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);
                    }
                });
            }
        }
Beispiel #11
0
        public void Clone(Webpage @from, Webpage to, SiteCloneContext siteCloneContext)
        {
            if (from == null || to == null)
            {
                return;
            }
            Type type = from.GetType();

            if (CloneWebpagePartTypes.ContainsKey(type))
            {
                foreach (
                    object cloneWebpagePart in
                    CloneWebpagePartTypes[type].Select(service => _kernel.Get(service))
                    )
                {
                    var part = cloneWebpagePart as CloneWebpagePart;
                    if (part != null)
                    {
                        part.ClonePartBase(from, to, siteCloneContext);
                    }
                }
            }
        }
 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);
         }
     });
 }
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var fromProvider     = new SqlConfigurationProvider(_session, @from);
            var fromSiteSettings = fromProvider.GetSiteSettings <SiteSettings>();
            var toProvider       = new SqlConfigurationProvider(_session, @to);
            var toSiteSettings   = toProvider.GetSiteSettings <SiteSettings>();

            var error403 = siteCloneContext.FindNew <Webpage>(fromSiteSettings.Error403PageId);

            if (error403 != null)
            {
                toSiteSettings.Error403PageId = error403.Id;
            }

            var error404 = siteCloneContext.FindNew <Webpage>(fromSiteSettings.Error404PageId);

            if (error404 != null)
            {
                toSiteSettings.Error404PageId = error404.Id;
            }

            var error500 = siteCloneContext.FindNew <Webpage>(fromSiteSettings.Error500PageId);

            if (error500 != null)
            {
                toSiteSettings.Error500PageId = error500.Id;
            }

            var layout = siteCloneContext.FindNew <Layout>(fromSiteSettings.DefaultLayoutId);

            if (layout != null)
            {
                toSiteSettings.DefaultLayoutId = layout.Id;
            }

            toProvider.SaveSettings(toSiteSettings);
        }
Beispiel #14
0
 public abstract void ClonePartBase(Webpage @from, Webpage to, SiteCloneContext siteCloneContext);
Beispiel #15
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            IEnumerable <MediaCategory> copies = GetMediaCategoryCopies(@from, to, siteCloneContext);

            _session.Transact(session => copies.ForEach(category => session.Save(category)));
        }
Beispiel #16
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);
                }
            }
        }
Beispiel #17
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            IEnumerable <Webpage> copies = GetWebpageCopies(@from, to, siteCloneContext).ToList();

            _session.Transact(session => copies.ForEach(webpage => session.Save(webpage)));
        }