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)); } ModuleEntryPath moduleInfoPath = GetModuleInfoPath(moduleName); var moduleInfo = DataContractSerializationHelper.Deserialize <ModuleInfo>(moduleInfoPath.PhysicalPath); moduleInfo.ModuleName = moduleName; return(moduleInfo); }
private static void CopyAssembies(ModuleInfo moduleInfo, ref StringBuilder log) { ModulePath modulePath = new ModulePath(moduleInfo.ModuleName); ModuleEntryPath moduleBinPath = new ModuleEntryPath(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); } } } }
//public bool Verify(string moduleName) //{ // if (!File.Exists(RouteTables.GetRoutesFilePath(moduleName).PhysicalPath)) // { // return false; // } // if (!File.Exists(ModuleInfo.GetModuleInfoPath(moduleName).PhysicalPath)) // { // return false; // } // return true; //} //public bool Verify(ZipFile zipFile) //{ // var moduleConfigEntry = zipFile[RouteTables.RouteFile]; // var routesConfigEntry = zipFile[ModuleInfo.ModuleInfoFileName]; // if (moduleConfigEntry == null || routesConfigEntry == null) // { // return false; // } // return true; //} //public void Upload(string moduleName, Stream zipStream, bool @override) //{ // if (!@override && All().Any(it => it.EqualsOrNullEmpty(moduleName, StringComparison.CurrentCultureIgnoreCase))) // { // throw new KoobooException(string.Format("The module '{0}' already exists.", moduleName)); // } // ModulePath modulePath = new ModulePath(moduleName); // using (ZipFile zipFile = ZipFile.Read(zipStream)) // { // if (!Verify(zipFile)) // { // throw new KoobooException("The module is invalid."); // } // var webconfigEntry = zipFile["web.config"]; // if (webconfigEntry != null) // { // zipFile.RemoveEntry(webconfigEntry); // } // zipFile.ExtractAll(modulePath.PhysicalPath, ExtractExistingFileAction.OverwriteSilently); // } //} 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 ModuleEntryPath(moduleName, ModuleInfo.ModuleInfoFileName); if (File.Exists(moduleConfigFile.PhysicalPath)) { yield return moduleName; } } } }
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)) { ModuleEntryPath moduleMenuFile = new ModuleEntryPath(moduleName, "menu.config"); MenuFactory.RegisterAreaMenu(areaName, moduleMenuFile.PhysicalPath); } } } var menu = MenuFactory.BuildMenu(controllerContext, areaName); return menu; }
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)) { ModuleEntryPath moduleMenuFile = new ModuleEntryPath(moduleName, "menu.config"); MenuFactory.RegisterAreaMenu(areaName, moduleMenuFile.PhysicalPath); } } } var menu = MenuFactory.BuildMenu(controllerContext, areaName); return(menu); }
private static void RemoveAssemblies(string moduleName) { ModulePath modulePath = new ModulePath(moduleName); ModuleEntryPath moduleBinPath = new ModuleEntryPath(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); } } } } }
public ModuleEntryPath(ModuleEntryPath parent, string entryName) { EntryName = entryName; PhysicalPath = Path.Combine(parent.PhysicalPath, EntryName); VirtualPath = UrlUtility.Combine(parent.VirtualPath, EntryName); }
private static string GetSitesModuleRelationDataFile(string moduleName) { ModuleEntryPath entryPath = new ModuleEntryPath(moduleName, "Sites.config"); return entryPath.PhysicalPath; }
private string ThemeRuleBody(string moduleName, string themeName) { ModuleEntryPath themePath = GetThemePath(moduleName, themeName); ModuleEntryPath themeRuleFile = new ModuleEntryPath(themePath, "Theme.rule"); if (File.Exists(themeRuleFile.PhysicalPath)) { return File.ReadAllText(themeRuleFile.PhysicalPath); } return string.Empty; }
public virtual IEnumerable<ModuleEntryPath> AllScripts(string moduleName) { ModuleEntryPath scriptsPath = new ModuleEntryPath(moduleName, "Scripts"); if (Directory.Exists(scriptsPath.PhysicalPath)) { foreach (var file in Directory.EnumerateFiles(scriptsPath.PhysicalPath, "*.js")) { yield return new ModuleEntryPath(scriptsPath, Path.GetFileName(file)); } } }
public static void Save(ModuleInfo moduleInfo) { ModuleEntryPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName); DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath.PhysicalPath); }