/// <summary>
        /// Updates settings.
        /// </summary>
        public override void UpdateSettings()
        {
            try // try to handle UpdateSettings
            {
                if (!Page.IsValid)
                {
                    return;
                }

                _settings = Infrastructure.ProfileModuleSettings.Load(ModuleId);
                {
                    if (ddrPortalId.SelectedIndex >= 0)
                    {
                        _settings.PortalId = Convert.ToInt32(ddrPortalId.SelectedValue);
                    }

                    if (ddrTemplateDirectory.SelectedIndex >= 0)
                    {
                        _settings.TemplateDirectory = ddrTemplateDirectory.SelectedValue;
                    }

                    _settings.ShowChart = chbShowChart.Checked;

                    _settings.Update();
                }
            }
            catch (Exception ex) // catch exceptions
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
 /// <summary>
 /// Loads settings.
 /// </summary>
 public override void LoadSettings()
 {
     try // try to handle LoadSettings
     {
         _settings = Infrastructure.ProfileModuleSettings.Load(ModuleId);
         SetupPortalsList(ddrPortalId, _settings.PortalId);
     }
     catch (Exception ex) // catch exceptions
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// OnInit handler.
        /// </summary>
        protected override void OnInit(EventArgs e)
        {
            try // try to handle OnInit
            {
                string[] patterns = { "*.js", "*.css", "*.cshtml" };

                LocalResourceFile = TemplateSourceDirectory + "/App_LocalResources/Profile.resx";
                {
                    _settings = Infrastructure.ProfileModuleSettings.Load(ModuleId);
                }

                ClientResourceManager.RegisterScript(Page, TemplateSourceDirectory + "/Scripts/profile.js", FileOrder.Js.DefaultPriority + 1);
                {
                    ClientResourceManager.RegisterStyleSheet(Page, TemplateSourceDirectory + "/Css/profile.css", FileOrder.Css.DefaultPriority + 1);
                }

                _razor = new ProfileEvaluator(ModuleContext, LocalResourceFile);
                {
                    _templates = new Dictionary <string, string>();
                }

                DirectoryInfo rootDirectory = null;

                string path = String.Format("{0}\\Profile\\{1}", TEMPLATES_PATH, _settings.TemplateDirectory);
                {
                    rootDirectory = new DirectoryInfo(Server.MapPath(path));
                }

                foreach (var file in rootDirectory.EnumerateFiles(patterns[0], SearchOption.AllDirectories))
                {
                    ClientResourceManager.RegisterScript(Page, ToRelativeUrl(file), FileOrder.Js.DefaultPriority + 2);
                }
                foreach (var file in rootDirectory.EnumerateFiles(patterns[1], SearchOption.AllDirectories))
                {
                    ClientResourceManager.RegisterStyleSheet(Page, ToRelativeUrl(file), FileOrder.Css.DefaultPriority + 2);
                }

                foreach (var file in rootDirectory.EnumerateFiles(patterns[2], SearchOption.AllDirectories))
                {
                    _templates.Add(Path.GetFileNameWithoutExtension(file.Name), ToRelativeUrl(file));
                }

                base.OnInit(e);
            }
            catch (Exception ex) // catch exceptions
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }