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

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

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

                    if (cmbLearnerModule.SelectedIndex >= 0)
                    {
                        if (cmbLearnerModule.SelectedValue != "default")
                        {
                            _settings.LearnerModuleId = Convert.ToInt32(cmbLearnerModule.SelectedValue);
                        }
                        else
                        {
                            _settings.LearnerModuleId = -1;
                        }
                    }
                    else
                    {
                        _settings.LearnerModuleId = -1;
                    }

                    _settings.ShowDateFilter = chkShowDateFilters.Checked;
                    _settings.ShowPaging     = chbShowPaging.Checked;

                    _settings.BeginDate = ctlCompletionDate.StartDate;
                    _settings.EndDate   = ctlCompletionDate.EndDate;
                    _settings.DateRange = ctlCompletionDate.DateRange;

                    int pageSize = 0; if (!String.IsNullOrEmpty(txtPageSize.Text) && Int32.TryParse(txtPageSize.Text, out pageSize))
                    {
                        _settings.PageSize = pageSize;
                    }

                    _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.ActivitySummaryModuleSettings.Load(ModuleId);
         SetupPortalsList(ddrPortalId, _settings.PortalId);
     }
     catch (Exception ex) // catch exceptions
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
 }
Esempio 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/ActivitySummary.resx";
                {
                    _settings = Infrastructure.ActivitySummaryModuleSettings.Load(ModuleId);
                }

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

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

                DirectoryInfo rootDirectory = null;

                string path = String.Format("{0}\\ActivitySummary\\{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);
            }
        }