Exemple #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);
                }
            }
        }
Exemple #2
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            ConfigurationProvider fromProvider = new ConfigurationProvider(@from, _legacySettingsProvider);
            ConfigurationProvider toProvider   = new ConfigurationProvider(@to, _legacySettingsProvider);

            System.Collections.Generic.List <SiteSettingsBase> siteSettingsBases = fromProvider.GetAllSiteSettings();
            siteSettingsBases.ForEach(toProvider.SaveSettings);
        }
Exemple #3
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var fromProvider      = new ConfigurationProvider(@from, _legacySettingsProvider);
            var toProvider        = new ConfigurationProvider(@to, _legacySettingsProvider);
            var siteSettingsBases = fromProvider.GetAllSiteSettings();

            siteSettingsBases.ForEach(toProvider.SaveSettings);
        }
Exemple #4
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));
 }
Exemple #5
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();
        }
Exemple #6
0
 public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
 {
     System.Collections.Generic.IList <Webpage> webpages = _session.QueryOver <Webpage>().Where(webpage => webpage.Site.Id == to.Id).List();
     foreach (Webpage webpage in webpages)
     {
         Webpage original = siteCloneContext.GetOriginal(webpage);
         if (original != null)
         {
             _cloneWebpageSiteParts.Clone(original, webpage, siteCloneContext);
         }
     }
 }
Exemple #7
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);
                }
            }
        }
Exemple #8
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            IEnumerable <Layout> copies = GetLayoutCopies(@from, to, siteCloneContext);

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

            System.Collections.Generic.List <string> keys = pageDefaultsSettings.Layouts.Keys.ToList();
            foreach (string key in keys.Where(key => pageDefaultsSettings.Layouts[key].HasValue))
            {
                Layout layout = siteCloneContext.FindNew <Layout>(pageDefaultsSettings.Layouts[key].Value);
                if (layout != null)
                {
                    pageDefaultsSettings.Layouts[key] = layout.Id;
                }
            }

            toProvider.SaveSettings(pageDefaultsSettings);
        }
Exemple #10
0
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            var toProvider           = new ConfigurationProvider(@to, _legacySettingsProvider);
            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);
        }
Exemple #11
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);
         }
     });
 }
Exemple #12
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);
         }
     }
 }
Exemple #13
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);
                }
            }
        }
Exemple #14
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);
                    }
                });
            }
        }
Exemple #15
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);
         }
     });
 }
        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))
                    )
                {
                    CloneWebpagePart part = cloneWebpagePart as CloneWebpagePart;
                    if (part != null)
                    {
                        part.ClonePartBase(from, to, siteCloneContext);
                    }
                }
            }
        }
        public void Clone(Site @from, Site to, SiteCloneContext siteCloneContext)
        {
            ConfigurationProvider fromProvider     = new ConfigurationProvider(@from, _legacySettingsProvider);
            SiteSettings          fromSiteSettings = fromProvider.GetSiteSettings <SiteSettings>();
            ConfigurationProvider toProvider       = new ConfigurationProvider(@to, _legacySettingsProvider);
            SiteSettings          toSiteSettings   = toProvider.GetSiteSettings <SiteSettings>();

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

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

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

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

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

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

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

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

            toProvider.SaveSettings(toSiteSettings);
        }
Exemple #18
0
        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);
        }
Exemple #19
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)));
        }
Exemple #20
0
 public abstract void ClonePartBase(Webpage @from, Webpage to, SiteCloneContext siteCloneContext);
        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);
                }
            }
        }
        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)));
        }