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.");
        }
示例#2
0
        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();
        }
示例#3
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);
             }
         }
     }
 }
示例#4
0
 public static void Save(ModuleInfo moduleInfo)
 {
     ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName);
     DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath.PhysicalPath);
 }
示例#5
0
        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);
 }
示例#7
0
文件: ModuleInfo.cs 项目: Godoy/CMS
 public static void Save(ModuleInfo moduleInfo)
 {
     var moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName);
     DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath);
 }
示例#8
0
 public IPath GetSiteDataFolder()
 {
     return(ModuleInfo.GetModuleDataPath(this.Site));
 }
示例#9
0
 public IPath GetSharedDataFolder()
 {
     return(ModuleInfo.GetModuleDataPath());
 }
示例#10
0
文件: ModuleInfo.cs 项目: zhq0131/CMS
        public static void Save(ModuleInfo moduleInfo)
        {
            ModuleItemPath moduleInfoPath = GetModuleInfoPath(moduleInfo.ModuleName);

            DataContractSerializationHelper.Serialize(moduleInfo, moduleInfoPath.PhysicalPath);
        }
示例#11
0
 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);
 }