Esempio 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);
        }
Esempio 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);
             }
         }
     }
 }
Esempio 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;
                    }
                }
            }
        }
Esempio 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);
                    }
                }
            }
        }
Esempio 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;
        }
Esempio 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);
        }
Esempio 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);
                 }
             }
         }
     }
 }
Esempio 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);
                        }
                    }
                }
            }
        }
Esempio 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));
         }
     }
 }
Esempio n. 10
0
 private static string GetSitesModuleRelationDataFile(string moduleName)
 {
     ModuleItemPath entryPath = new ModuleItemPath(moduleName, "Sites.config");
     return entryPath.PhysicalPath;
 }
Esempio 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;
 }
Esempio 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);
         }
     }
 }
Esempio n. 13
0
 public ModuleItemPath(ModuleItemPath parent, string entryName)
 {
     EntryName    = entryName;
     PhysicalPath = Path.Combine(parent.PhysicalPath, EntryName);
     VirtualPath  = UrlUtility.Combine(parent.VirtualPath, EntryName);
 }
Esempio n. 14
0
 public ModuleItemPath(ModuleItemPath parent, string entryName)
 {
     EntryName = entryName;
     PhysicalPath = Path.Combine(parent.PhysicalPath, EntryName);
     VirtualPath = UrlUtility.Combine(parent.VirtualPath, EntryName);
 }
Esempio n. 15
0
        public static void Save(ModuleInfo moduleInfo)
        {
            ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName);

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