public ActionResult GenerateModuleInfo() { ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.ModuleName = "SampleModule"; moduleInfo.Version = "4.2.0.0"; moduleInfo.KoobooCMSVersion = "4.2.0.0"; moduleInfo.InstallingTemplate = UrlUtility.Combine("~/", "Areas", SampleAreaRegistration.ModuleName, "Views", "Shared", "_OnInstalling.cshtml"); moduleInfo.UninstallingTemplate = UrlUtility.Combine("~/", "Areas", SampleAreaRegistration.ModuleName, "Views", "Shared", "_OnUninstalling.cshtml"); moduleInfo.DefaultSettings = new ModuleSettings() { ThemeName = "Default", Entry = new Entry() { Controller = "Home", Action = "Index" } }; moduleInfo.EntryOptions = new EntryOption[]{ new EntryOption(){ Name="NewsList",Entry = new Entry{ Controller="News",Action ="Index"}}, new EntryOption(){ Name="NewsCategories",Entry = new Entry{ Controller="News",Action ="Categories"}}, new EntryOption(){Name="ArticleCategories",Entry=new Entry{Controller="Article",Action="Categories"}}, new EntryOption(){Name="ArticleList",Entry=new Entry{Controller="Article",Action="List"}}, new EntryOption(){Name="ArticleSearch",Entry=new Entry{Controller="Article",Action="Search"}}, }; moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>(); moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1"; ModuleInfo.Save(moduleInfo); return Content("The module configuration file has been generated."); }
public ActionResult GenerateModuleInfo() { ModuleInfo moduleInfo = new ModuleInfo(); moduleInfo.ModuleName = "SampleModule"; moduleInfo.Version = "4.0.0.0"; moduleInfo.KoobooCMSVersion = "4.0.0.0"; moduleInfo.DefaultSettings = new ModuleSettings() { ThemeName = "Default", Entry = new Entry() { Controller = "Home", Action = "Index" } }; moduleInfo.EntryOptions = new EntryOption[]{ new EntryOption(){ Name="NewsList",Entry = new Entry{ Controller="News",Action ="Index"}}, new EntryOption(){ Name="NewsCategories",Entry = new Entry{ Controller="News",Action ="Categories"}}, new EntryOption(){Name="ArticleCategories",Entry=new Entry{Controller="Article",Action="Categories"}}, new EntryOption(){Name="ArticleList",Entry=new Entry{Controller="Article",Action="List"}}, }; moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>(); moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1"; ModuleInfo.Save(moduleInfo); return View(); }
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); } } } }
public static void Save(ModuleInfo moduleInfo) { ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName); DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath.PhysicalPath); }
public static ModuleActionInvokedContext InvokeAction(ControllerContext controllerContext, Site site, string moduleUrl, ModulePosition modulePosition) { HttpContext context = HttpContext.Current; var moduleSettings = ModuleInfo.Get(modulePosition.ModuleName).GetModuleSettings(site); if (modulePosition.Entry != null) { moduleSettings.Entry = modulePosition.Entry; } var settings = moduleSettings; var positionId = modulePosition.PagePositionId; var moduleName = modulePosition.ModuleName; ModuleContext moduleContext = ModuleContext.Create(site, moduleName, settings, modulePosition); if (string.IsNullOrEmpty(moduleUrl)) { if (settings != null && settings.Entry != null) { moduleUrl = GetEntryUrl(context, moduleContext, settings.Entry); if (!string.IsNullOrEmpty(moduleUrl) && !moduleUrl.StartsWith("~")) { moduleUrl = "~" + moduleUrl; } } } if (string.IsNullOrEmpty(moduleUrl)) { moduleUrl = "~/"; } else if (moduleUrl[0] != '~') { moduleUrl = "~/" + moduleUrl.TrimStart('/'); } var httpContext = new ModuleHttpContext(context , new ModuleHttpRequest(context.Request, moduleUrl, moduleContext, controllerContext), new ModuleHttpResponse(context.Response, moduleContext), moduleContext); var routeData = moduleContext.RouteTable.GetRouteData(httpContext); var requestContext = new ModuleRequestContext(httpContext, routeData, moduleContext) { PageControllerContext = controllerContext }; string controllerName = requestContext.RouteData.GetRequiredString("controller"); string actionName = requestContext.RouteData.GetRequiredString("action"); var controller = (Controller)ControllerBuilder.Current.GetControllerFactory().CreateController(requestContext, controllerName); if (controller == null) { throw new Exception(string.Format("The module '{0}' controller for path '{1}' does not found or does not implement IController.", moduleName, moduleUrl)); } //if (!(controller is ModuleControllerBase)) //{ // throw new Exception(string.Format("The controller type '{0}' must be inherited from ModuleControllerBase.", controller.GetType().FullName)); //} //ModuleControllerBase moduleController = (ModuleControllerBase)controller; //ControllerContext moduleControllerContext = new ControllerContext(requestContext, moduleController); InitializeController(controller, requestContext); var result = actionInvoker.InvokeActionWithoutExecuteResult(controller.ControllerContext, actionName); if (result == null) { HandleUnknownAction(controller, actionName); } return(result); }
private bool NotCommerce(ModuleInfo module) { return !module.ModuleName.Equals("Commerce", StringComparison.OrdinalIgnoreCase); }
public static void Save(ModuleInfo moduleInfo) { var moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName); DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath); }
public IPath GetSiteDataFolder() { return(ModuleInfo.GetModuleDataPath(this.Site)); }
public IPath GetSharedDataFolder() { return(ModuleInfo.GetModuleDataPath()); }
public virtual ActionResult Uninstall(ModuleInfo[] model, string @return) { var data = new JsonResultData(ModelState); data.RunWithTry((resultData) => { foreach (var item in model) { if (!string.IsNullOrEmpty(item.ModuleName)) { Manager.Uninstall(item.ModuleName); } } resultData.RedirectUrl = @return; }); return Json(data); }