Exemplo n.º 1
0
        public static ModuleInfo Get(string moduleName)
        {
            ModulePath modulePath = new ModulePath(moduleName);

            if (!Directory.Exists(modulePath.PhysicalPath))
            {
                throw new Exception(string.Format("The module does not exist.Module name:{0}".Localize(), moduleName));
            }
            ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleName);
            var            moduleInfo     = DataContractSerializationHelper.Deserialize <ModuleInfo>(moduleInfoPath.PhysicalPath);

            moduleInfo.ModuleName = moduleName;
            return(moduleInfo);
        }
Exemplo n.º 2
0
 private static void CopyAssembies(ModuleInfo moduleInfo, ref StringBuilder log)
 {
     ModulePath modulePath = new ModulePath(moduleInfo.ModuleName);
     ModuleItemPath moduleBinPath = new ModuleItemPath(moduleInfo.ModuleName, "Bin");
     var binPath = Settings.BinDirectory;
     if (Directory.Exists(moduleBinPath.PhysicalPath))
     {
         foreach (var file in Directory.EnumerateFiles(moduleBinPath.PhysicalPath))
         {
             string fileName = Path.GetFileName(file);
             if (!Assemblies.Defaults.Any(it => it.EqualsOrNullEmpty(fileName, StringComparison.CurrentCultureIgnoreCase)))
             {
                 File.Copy(file, Path.Combine(binPath, fileName), true);
             }
         }
     }
 }
Exemplo n.º 3
0
        public virtual IEnumerable<string> All()
        {
            var baseDirectory = ModulePath.BaseDirectory;
            if (Directory.Exists(baseDirectory))
            {
                foreach (var dir in IO.IOUtility.EnumerateDirectoriesExludeHidden(baseDirectory))
                {
                    var moduleName = dir.Name;

                    var moduleConfigFile = new ModuleItemPath(moduleName, ModuleInfo.ModuleInfoFileName);

                    if (File.Exists(moduleConfigFile.PhysicalPath))
                    {
                        yield return moduleName;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static void CopyAssembies(ModuleInfo moduleInfo, ref StringBuilder log)
        {
            ModulePath     modulePath    = new ModulePath(moduleInfo.ModuleName);
            ModuleItemPath moduleBinPath = new ModuleItemPath(moduleInfo.ModuleName, "Bin");
            var            binPath       = Settings.BinDirectory;

            if (Directory.Exists(moduleBinPath.PhysicalPath))
            {
                foreach (var file in Directory.EnumerateFiles(moduleBinPath.PhysicalPath))
                {
                    string fileName = Path.GetFileName(file);
                    if (!Assemblies.Defaults.Any(it => it.EqualsOrNullEmpty(fileName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        File.Copy(file, Path.Combine(binPath, fileName), true);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private static Menu GetModuleMenu(string moduleName, ControllerContext controllerContext)
        {
            var areaName = string.Format("module-{0}", moduleName);
            if (!MenuFactory.ContainsAreaMenu(areaName))
            {
                lock (lockerHelper)
                {
                    if (!MenuFactory.ContainsAreaMenu(areaName))
                    {
                        ModuleItemPath moduleMenuFile = new ModuleItemPath(moduleName, "menu.config");
                        MenuFactory.RegisterAreaMenu(areaName, moduleMenuFile.PhysicalPath);
                    }
                }
            }
            var menu = MenuFactory.BuildMenu(controllerContext, areaName);

            return menu;
        }
Exemplo n.º 6
0
        private static Menu GetModuleMenu(string moduleName, ControllerContext controllerContext)
        {
            var areaName = string.Format("module-{0}", moduleName);

            if (!MenuFactory.ContainsAreaMenu(areaName))
            {
                lock (lockerHelper)
                {
                    if (!MenuFactory.ContainsAreaMenu(areaName))
                    {
                        ModuleItemPath moduleMenuFile = new ModuleItemPath(moduleName, "menu.config");
                        MenuFactory.RegisterAreaMenu(areaName, moduleMenuFile.PhysicalPath);
                    }
                }
            }
            var menu = MenuFactory.BuildMenu(controllerContext, areaName);

            return(menu);
        }
Exemplo n.º 7
0
 private static void RemoveAssemblies(string moduleName)
 {
     ModulePath modulePath = new ModulePath(moduleName);
     ModuleItemPath moduleBinPath = new ModuleItemPath(moduleName, "Bin");
     var binPath = Settings.BinDirectory;
     if (Directory.Exists(moduleBinPath.PhysicalPath))
     {
         foreach (var file in Directory.EnumerateFiles(moduleBinPath.PhysicalPath))
         {
             string fileName = Path.GetFileName(file);
             if (!Assemblies.Defaults.Any(it => it.EqualsOrNullEmpty(fileName, StringComparison.CurrentCultureIgnoreCase)))
             {
                 var binFile = Path.Combine(binPath, fileName);
                 if (File.Exists(binFile))
                 {
                     File.Delete(binFile);
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        private static void RemoveAssemblies(string moduleName)
        {
            ModulePath     modulePath    = new ModulePath(moduleName);
            ModuleItemPath moduleBinPath = new ModuleItemPath(moduleName, "Bin");
            var            binPath       = Settings.BinDirectory;

            if (Directory.Exists(moduleBinPath.PhysicalPath))
            {
                foreach (var file in Directory.EnumerateFiles(moduleBinPath.PhysicalPath))
                {
                    string fileName = Path.GetFileName(file);
                    if (!Assemblies.Defaults.Any(it => it.EqualsOrNullEmpty(fileName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        var binFile = Path.Combine(binPath, fileName);
                        if (File.Exists(binFile))
                        {
                            File.Delete(binFile);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 public virtual IEnumerable<ModuleItemPath> AllScripts(string moduleName)
 {
     ModuleItemPath scriptsPath = new ModuleItemPath(moduleName, "Scripts");
     if (Directory.Exists(scriptsPath.PhysicalPath))
     {
         foreach (var file in Directory.EnumerateFiles(scriptsPath.PhysicalPath, "*.js"))
         {
             yield return new ModuleItemPath(scriptsPath, Path.GetFileName(file));
         }
     }
 }
Exemplo n.º 10
0
 private static string GetSitesModuleRelationDataFile(string moduleName)
 {
     ModuleItemPath entryPath = new ModuleItemPath(moduleName, "Sites.config");
     return entryPath.PhysicalPath;
 }
Exemplo n.º 11
0
 private string ThemeRuleBody(string moduleName, string themeName)
 {
     ModuleItemPath themePath = GetThemePath(moduleName, themeName);
     ModuleItemPath themeRuleFile = new ModuleItemPath(themePath, "Theme.rule");
     if (File.Exists(themeRuleFile.PhysicalPath))
     {
         return File.ReadAllText(themeRuleFile.PhysicalPath);
     }
     return string.Empty;
 }
Exemplo n.º 12
0
 public virtual IEnumerable<ModuleItemPath> AllScripts(string moduleName)
 {
     ModuleItemPath scriptsPath = new ModuleItemPath(moduleName, "Scripts");
     if (Directory.Exists(scriptsPath.PhysicalPath))
     {
         var files = Directory.EnumerateFiles(scriptsPath.PhysicalPath, "*.js").Select(it => Path.GetFileName(it));
         var orderFilePath = Path.Combine(scriptsPath.PhysicalPath, FileOrderHelper.OrderFileName);
         if (File.Exists(orderFilePath))
         {
             files = FileOrderHelper.OrderFiles(orderFilePath, files);
         }
         foreach (var file in files)
         {
             yield return new ModuleItemPath(scriptsPath, file);
         }
     }
 }
Exemplo n.º 13
0
 public ModuleItemPath(ModuleItemPath parent, string entryName)
 {
     EntryName    = entryName;
     PhysicalPath = Path.Combine(parent.PhysicalPath, EntryName);
     VirtualPath  = UrlUtility.Combine(parent.VirtualPath, EntryName);
 }
Exemplo n.º 14
0
 public ModuleItemPath(ModuleItemPath parent, string entryName)
 {
     EntryName = entryName;
     PhysicalPath = Path.Combine(parent.PhysicalPath, EntryName);
     VirtualPath = UrlUtility.Combine(parent.VirtualPath, EntryName);
 }
Exemplo n.º 15
0
        public static void Save(ModuleInfo moduleInfo)
        {
            ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName);

            DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath.PhysicalPath);
        }