Пример #1
0
        public PortalsDTO TranslateRb_PortalsIntoPortalDTO(rb_Portals portal)
        {
            PortalsDTO _portal = new PortalsDTO();

            _portal.AlwaysShowEditButton = portal.AlwaysShowEditButton;
            _portal.PortalAlias          = portal.PortalAlias;
            _portal.PortalID             = portal.PortalID;
            _portal.PortalName           = portal.PortalName;
            _portal.PortalPath           = portal.PortalPath;

            List <PagesDTO> pages = new List <PagesDTO>();

            foreach (rb_Pages p in portal.rb_Pages)
            {
                pages.Add(TranslateRb_PagesIntoPagesDTO(p));
            }
            _portal.Pages = pages;

            List <PortalSettingsDTO> settings = new List <PortalSettingsDTO>();

            foreach (rb_PortalSettings p in portal.rb_PortalSettings)
            {
                settings.Add(TranslateRb_PortalSettingsIntoPortalSettingsDTO(p));
            }
            _portal.PortalSettings = settings;

            return(_portal);
        }
Пример #2
0
        /// <summary>
        /// Saves the content of the module.
        /// </summary>
        /// <param name="portal">
        /// The portal.
        /// </param>
        /// <param name="desktopSources">
        /// The desktop sources.
        /// </param>
        /// <param name="contentModules">
        /// The content modules.
        /// </param>
        private void SaveModuleContent(
            rb_Portals portal, IDictionary <Guid, string> desktopSources, IDictionary <int, string> contentModules)
        {
            var modules = portal.rb_Pages.SelectMany(page => page.rb_Modules);

            SaveModuleContentAux(modules, desktopSources, contentModules);
        }
Пример #3
0
        private static void AlterModuleSettingsPage(rb_Portals portal,
                                                    rb_Pages pages, IDictionary <int, int> pageList, IDictionary <Guid, string> desktopSources)
        {
            var db      = new PortalTemplateDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            var modules = db.rb_Modules.Where(m => m.rb_Pages.PageID == pages.PageID).ToList();

            AlterModuleSettingsAux(modules, portal, pageList, desktopSources);
        }
Пример #4
0
        private static void AlterModuleSettingsAux(
            IEnumerable <rb_Modules> modules, rb_Portals portal, IDictionary <int, int> pageList, IDictionary <Guid, string> desktopSources)
        {
            var p  = new Page();
            var db = new PortalTemplateDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

            foreach (var module in modules)
            {
                var portalModuleName = string.Concat(
                    Path.ApplicationRoot, "/", desktopSources[module.rb_ModuleDefinition.GeneralModDefID]);
                if (!portalModuleName.Contains("/Areas/") && !portalModuleName.StartsWith("Areas/"))
                {
                    var portalModule = (PortalModuleControl)p.LoadControl(portalModuleName);
                    foreach (var key in
                             portalModule.BaseSettings.Keys.Cast <string>().Where(
                                 key =>
                                 key.Equals("TARGETURL") ||
                                 portalModule.BaseSettings[key] is PageListDataType))
                    {
                        try
                        {
                            var setting   = module.rb_ModuleSettings.First(s => s.SettingName.Equals(key));
                            var oldPageId =
                                Regex.Match(setting.SettingValue, "(/\\d+/)|(^\\d+$)", RegexOptions.IgnoreCase).Value.
                                Replace("/", string.Empty);
                            var newPageId = portal.rb_Pages[pageList[Convert.ToInt16(oldPageId)]].PageID;
                            setting.SettingValue = setting.SettingValue.Replace(oldPageId, newPageId.ToString());
                        }
                        catch (Exception e)
                        {
                            ErrorHandler.Publish(
                                LogLevel.Error,
                                string.Format(
                                    "There was an error on modifying the module settings for moduleID= {0} and setting= {1}",
                                    module.ModuleID,
                                    key),
                                e);
                        }
                    }
                }
            }

            try
            {
                db.SubmitChanges(ConflictMode.FailOnFirstConflict);
            }
            catch (Exception e)
            {
                ErrorHandler.Publish(LogLevel.Error, "There was an error on modifying the module settings", e);
            }
        }
Пример #5
0
        public rb_Portals TranslatePortalDTOIntoRb_Portals(PortalsDTO portal)
        {
            rb_Portals _portal = new rb_Portals();

            _portal.AlwaysShowEditButton = portal.AlwaysShowEditButton;
            _portal.PortalAlias          = portal.PortalAlias;
            _portal.PortalName           = portal.PortalName;
            _portal.PortalPath           = portal.PortalPath;
            _portal.PortalID             = portal.PortalID;
            _portal.rb_Pages             = new EntitySet <rb_Pages>();

            moduleIndex                        = 0;
            this.ContentModules                = new Dictionary <int, string>();
            this.ModulesNotInserted            = new Dictionary <int, string>();
            this.PageList                      = new Dictionary <int, int>();
            this.ModuleDefinitionsDeserialized = new Dictionary <Guid, rb_ModuleDefinition>();
            int index = 0;

            foreach (PagesDTO p in portal.Pages)
            {
                _portal.rb_Pages.Add(TranslatePagesDTOIntoRb_Pages(p));
                this.PageList.Add(p.PageID, index);
                index++;
            }
            foreach (rb_Pages pages in _portal.rb_Pages)
            {
                if (pages.ParentPageID != null)
                {
                    pages.rb_Page1 = _portal.rb_Pages.First(p => p.PageID == pages.ParentPageID.Value);
                }
            }

            _portal.rb_PortalSettings = new EntitySet <rb_PortalSettings>();
            foreach (PortalSettingsDTO p in portal.PortalSettings)
            {
                _portal.rb_PortalSettings.Add(TranslatePortalSettingsDTOIntoRb_PortalSettings(p));
            }

            return(_portal);
        }