예제 #1
0
        public IEnumerable <string> GetStyleSheetIncludes(bool includePrivateCssFiles, bool includePublicCssFiles, Type moduleDescriptorType = null)
        {
            var allIncludes = new List <CssIncludeDescriptor>();

            if (moduleDescriptorType != null)
            {
                var modules = modulesRegistration.GetModules();
                foreach (var module in modules)
                {
                    if (module.ModuleDescriptor.GetType() == moduleDescriptorType)
                    {
                        allIncludes.AddRange(module.ModuleDescriptor.RegisterCssIncludes());
                    }
                }
            }
            else
            {
                allIncludes.AddRange(modulesRegistration.GetStyleSheetIncludes());
            }

            var includes = allIncludes
                           .Where(f => f.IsPublic && includePublicCssFiles || !f.IsPublic && includePrivateCssFiles);

            if (cmsConfiguration.UseMinifiedResources)
            {
                return(includes.Select(f => string.IsNullOrEmpty(f.MinPath)
                                                ? f.ContainerModule.MinifiedCssPath
                                                : f.MinPath)
                       .Distinct());
            }

            return(includes.Select(f => f.Path).Distinct());
        }
예제 #2
0
 /// <summary>
 /// Updates database.
 /// </summary>
 private void MigrateDatabase()
 {
     try
     {
         var descriptors = modulesRegistration.GetModules().Select(m => m.ModuleDescriptor).ToList();
         migrationRunner.MigrateStructure(descriptors);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
예제 #3
0
        public ModulesListViewModel Execute()
        {
            var modules = modulesRegistration.GetModules()
                          .Select(
                m =>
                new ModuleViewModel
            {
                Assembly    = m.ModuleDescriptor.AssemblyName.Name,
                Description = m.ModuleDescriptor.Description,
                Name        = m.ModuleDescriptor.Name,
                Type        = m.ModuleDescriptor is WebModuleDescriptor ? "Core.Web" : "Core"
            })
                          .ToList();

            return(new ModulesListViewModel {
                Modules = modules
            });
        }
예제 #4
0
 public void AddAvailableMappings(FluentConfiguration fluentConfiguration)
 {
     foreach (var module in modulesRegistry.GetModules())
     {
         try
         {
             var assembly = assemblyLoader.Load(module.ModuleDescriptor.AssemblyName);
             if (assembly != null)
             {
                 fluentConfiguration = fluentConfiguration.Mappings(m => m.FluentMappings.AddFromAssembly(assembly));
             }
         }
         catch (Exception ex)
         {
             Logger.ErrorFormat("Failed to load mappings from module {0} (assembly {1}).", ex, module.ModuleDescriptor.Name, module.ModuleDescriptor.AssemblyName);
         }
     }
 }
예제 #5
0
        private void LoadFromDatabase()
        {
            isLoadedFromDatabase = true;
            Log.Trace("Loading migration files list from database");

            // Select which tables are available
            var tablesQuery = string.Format("SELECT TABLE_SCHEMA AS SchemaName FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}'", VersionInfo.TableName);
            var schemas     = unitOfWork
                              .Session
                              .CreateSQLQuery(tablesQuery)
                              .SetResultTransformer(Transformers.AliasToBean <VersionInfo>())
                              .List <VersionInfo>();

            if (!schemas.Any())
            {
                return;
            }

            // Construct query with existing tables
            var sqlQueryBuilder = new StringBuilder();
            var first           = true;

            foreach (var module in modulesRegistration.GetModules())
            {
                var schemaName = module.ModuleDescriptor.SchemaName;
                if (!string.IsNullOrWhiteSpace(schemaName) && schemas.Any(s => s.SchemaName.ToLowerInvariant() == schemaName.ToLowerInvariant()))
                {
                    if (!first)
                    {
                        sqlQueryBuilder.AppendLine("UNION ALL");
                    }

                    sqlQueryBuilder
                    .AppendFormat("SELECT {0}, '{1}' AS {2} FROM {3}.{4}",
                                  VersionInfo.VersionFieldName,
                                  module.ModuleDescriptor.Name,
                                  VersionInfo.ModuleFieldName,
                                  module.ModuleDescriptor.SchemaName,
                                  VersionInfo.TableName)
                    .AppendLine();

                    first = false;
                }
            }

            var sqlQuery = sqlQueryBuilder.ToString();

            if (!string.IsNullOrWhiteSpace(sqlQuery))
            {
                var versions = unitOfWork
                               .Session
                               .CreateSQLQuery(sqlQuery)
                               .SetResultTransformer(Transformers.AliasToBean <VersionInfo>())
                               .List <VersionInfo>();

                foreach (var version in versions)
                {
                    if (!VersionExists(version.ModuleName, version.Version))
                    {
                        AddVersion(version.ModuleName, version.Version, true);
                    }
                }
            }
        }