private void ArrangeDatabaseService(
            IEnumerable <CmsSettingsKey> cmsSettingsKeys,
            IEnumerable <CmsSettingsCategory> cmsSettingsCategories
            )
        {
            var cmsSettingsKeysNames = new SettingsKeyAnalyzers(null)
                                       .Analyzers
                                       .Select(analyzer => analyzer.Parameters[0].Name);

            _mockDatabaseService.SetupExecuteSqlFromFileWithListParameter(
                Scripts.GetSecurityCmsSettings,
                nameof(cmsSettingsKeysNames),
                cmsSettingsKeysNames,
                cmsSettingsKeys);

            var cmsSettingsCategoryIdsOnPaths = cmsSettingsCategories
                                                .Select(category => category.CategoryID.ToString());

            _mockDatabaseService.SetupExecuteSqlFromFileWithListParameter(
                Scripts.GetCmsSettingsCategories,
                nameof(cmsSettingsCategoryIdsOnPaths),
                cmsSettingsCategoryIdsOnPaths,
                cmsSettingsCategories
                );
        }
Example #2
0
        private IEnumerable <CmsSettingsKeyResult> GetCmsSettingsKeyResults(IEnumerable <CmsSettingsKey> cmsSettingsKeys)
        {
            var analyzersObject = new SettingsKeyAnalyzers(Metadata.Terms);

            foreach (var analyzer in analyzersObject.Analyzers)
            {
                var analysisResult = analyzersObject.GetAnalysis(analyzer, cmsSettingsKeys, key => key.KeyName);

                if (analysisResult is CmsSettingsKeyResult cmsSettingsKeyResult)
                {
                    yield return(cmsSettingsKeyResult);
                }
            }
        }
Example #3
0
        public override ReportResults GetResults()
        {
            var cmsSettingsKeysNames = new SettingsKeyAnalyzers(null)
                                       .Analyzers
                                       .Select(analyzer => analyzer.Parameters[0].Name);

            var cmsSettingsKeys = databaseService.ExecuteSqlFromFile <CmsSettingsKey>(
                Scripts.GetSecurityCmsSettings,
                new { cmsSettingsKeysNames }
                );

            var cmsSettingsKeyResults = GetCmsSettingsKeyResults(cmsSettingsKeys);

            var cmsSettingsCategoryIdsOnPaths = cmsSettingsKeyResults
                                                .SelectMany(cmsSettingsKeyResult => cmsSettingsKeyResult.GetCategoryIdsOnPath())
                                                .Distinct();

            var cmsSettingsCategories = databaseService.ExecuteSqlFromFile <CmsSettingsCategory>(
                Scripts.GetCmsSettingsCategories,
                new { cmsSettingsCategoryIdsOnPaths }
                );

            var sites = instanceService
                        .GetInstanceDetails(instanceService.CurrentInstance)
                        .Sites
                        .Append(new Site()
            {
                Id   = 0,
                Name = Metadata.Terms.GlobalSiteName
            });

            var instancePath = instanceService.CurrentInstance.Path;

            var resxValues = cmsFileService.GetResourceStringsFromResx(instancePath);

            var localizedCmsSettingsKeyResults = cmsSettingsKeyResults
                                                 .Select(cmsSettingsKeyResult => new CmsSettingsKeyResult(
                                                             cmsSettingsKeyResult,
                                                             cmsSettingsCategories,
                                                             sites,
                                                             resxValues
                                                             ));

            var webConfigXml = cmsFileService.GetXmlDocument(instancePath, DefaultKenticoPaths.WebConfigFile);

            var webConfigSettingsResults = GetWebConfigSettingsResults(webConfigXml);

            return(CompileResults(localizedCmsSettingsKeyResults, webConfigSettingsResults));
        }