/// <summary> /// 显示 json 信息给客户端,提示是否 valid ,返回 {"IsValid":true, "Msg":"", "Info":{这里是具体的json对象信息}} /// </summary> /// <param name="msg"></param> /// <param name="isValid"></param> /// <param name="otherObject"></param> protected void echoJsonMsg(String msg, Boolean isValid, Object otherObject) { echoJson(MvcUtil.renderValidatorJsonObject(msg, isValid, otherObject)); }
/// <summary> /// 显示 json 信息给客户端,提示是否 valid ,返回 {"IsValid":true, "Msg":"", "Info":"这里是字符串"} /// </summary> /// <param name="msg"></param> /// <param name="isValid"></param> /// <param name="otherInfo"></param> protected void echoJsonMsg(String msg, Boolean isValid, String otherInfo) { echoJson(MvcUtil.renderValidatorJson(msg, isValid, otherInfo)); }
public override void Process(ProcessContext context) { MvcEventPublisher.Instance.BeginProcessAction(context.ctx); if (context.ctx.utils.isSkipCurrentProcessor()) { return; } MvcContext ctx = context.ctx; ControllerBase controller = context.getController(); // 检查缓存 CacheInfo ci = CacheInfo.Init(ctx); Object cacheContent = ci.CheckCache(); if (cacheContent != null) { logger.Info("load from actionCache=" + ci.CacheKey); context.setContent(cacheContent.ToString()); getPageMetaFromCache(ctx, ci.CacheKey); return; } MethodInfo actionMethod = ctx.ActionMethodInfo; // context.getActionMethod(); // 设值模板并载入全局变量 setControllerView(controller, actionMethod); // 运行并处理post值 ActionRunner.runAction(ctx, controller, actionMethod, controller.utils.runAction); String actionContent = controller.utils.getActionResult(); // 加入缓存 if (ci.IsActionCache) { ci.AddContentToCache(actionContent); // 加入PageMeta addPageMetaToCache(ctx, ci.CacheKey); } actionContent = PostValueProcessor.ProcessPostValue(actionContent, ctx); if (ctx.utils.isAjax) { context.showEnd(actionContent); } else if (ctx.utils.isFrame()) { int intNoLayout = ctx.utils.getNoLayout(); if (intNoLayout == 0) { String content = MvcUtil.getFrameContent(actionContent); context.showEnd(content); } else { context.setContent(actionContent); } } else if (ctx.utils.isEnd()) { context.showEnd(actionContent); } else { context.setContent(actionContent); } updateActionCache(ctx); MvcEventPublisher.Instance.EndProcessAction(context.ctx); }
private static ISymbolTable GetReferenceSymbolTable(IPsiServices psiServices, [CanBeNull] string area, [CanBeNull] string controller, [CanBeNull] string view, MvcKind mvcKind, [CanBeNull] IProject project, Version version) { if (project == null) { return(EmptySymbolTable.INSTANCE); } ISolution solution = project.GetSolution(); var component = solution.GetComponent <MvcCache>(); IEnumerable <IProject> searcheableProjects = GetSearcheableProjects(project); bool hasExtension = false; if (view != null) { if (view.IndexOfAny(FileSystemDefinition.InvalidPathChars) != -1) { return(EmptySymbolTable.INSTANCE); } if (view == "???") { return(EmptySymbolTable.INSTANCE); } hasExtension = Path.HasExtension(view); } ISymbolTable symbolTable = EmptySymbolTable.INSTANCE; foreach (IProject current in searcheableProjects) { ISymbolTable symbolTable2 = EmptySymbolTable.INSTANCE; string text = null; if (view != null) { string text2 = Path.IsPathRooted(view) ? ("~" + view) : view; text = HtmlPathReferenceUtil.ExpandRootName(text2.Replace('/', '\\'), current); if (Path.IsPathRooted(text)) { FileSystemPath fileSystemPath = FileSystemPath.Parse(text); if (!fileSystemPath.IsAbsolute) { fileSystemPath = WebPathReferenceUtil.GetRootPath(project).Combine(fileSystemPath); } symbolTable2 = symbolTable2.Merge(new DeclaredElementsSymbolTable <PathDeclaredElement>(psiServices, new[] { new PathDeclaredElement(psiServices, fileSystemPath) }, 0, null)); } } List <string> list = null; if (hasExtension) { list = component.GetDisplayModes(current).ToList(); } string[] arg_152_0; if (!area.IsEmpty()) { var array = new string[2]; array[0] = area; arg_152_0 = array; } else { arg_152_0 = new[] { area }; } string[] array2 = arg_152_0; for (int i = 0; i < array2.Length; i++) { string area2 = array2[i]; foreach ( string current2 in component.GetLocations(current, MvcUtil.GetViewLocationType(mvcKind, area2), true)) { using ( IEnumerator <Pair <string, string> > enumerator3 = ParseLocationFormatString(current2, mvcKind, controller, area2).GetEnumerator()) { while (enumerator3.MoveNext()) { Pair <string, string> location = enumerator3.Current; FileSystemPath fileSystemPath2 = FileSystemPath.TryParse(location.First); FileSystemPath location2 = (location.First.LastIndexOf('\\') == location.First.Length - 1) ? fileSystemPath2 : fileSystemPath2.Directory; var projectFolder = current.FindProjectItemByLocation(location2) as IProjectFolder; if (projectFolder != null) { Func <IProjectItem, bool> extensionFilter = item => item.Location.FullPath.EndsWith(location.Second, StringComparison.OrdinalIgnoreCase); Func <IProjectItem, bool> preFilter = extensionFilter; if (view != null) { string text3 = Path.IsPathRooted(text) ? text : (location.First + text + location.Second); string extension = Path.GetExtension(text3); var possibleNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase) { text3 }; if (list != null) { foreach (string current3 in list) { possibleNames.Add(Path.ChangeExtension(text3, current3 + extension)); } } preFilter = item => extensionFilter(item) && possibleNames.Contains(item.Location.FullPath); } // todo tmp var referenceContext = new PathReferenceContext(psiServices, projectFolder.Location); symbolTable2 = symbolTable2.Merge(PathReferenceUtil.GetSymbolTableByPath(referenceContext, false, true, projectItem => GetViewName(projectItem.Location, location), preFilter)); } } } } } symbolTable = symbolTable.Merge(symbolTable2.Filter(new[] { FileFilters.FileExists, new FileFilters.ItemInProjectFilter(current) })); } return(symbolTable.Distinct(PathInfoComparer.Instance)); }
public void TestGetSiteControllerNamesPattern() { Web.Write(MvcUtil.GetSiteControllerNamesPattern()); Assert.Pass(); }
public override void Process(ProcessContext context) { MvcEventPublisher.Instance.BeginProcessAction(context.ctx); if (context.ctx.utils.isSkipCurrentProcessor()) { return; } MvcContext ctx = context.ctx; ControllerBase controller = ctx.controller; // 1) 检查 action 缓存 ActionCacheChecker xChecker = ActionCacheChecker.InitAction(ctx); Object cacheContent = xChecker.GetCache(); if (cacheContent != null) { logger.Info("load from actionCache=" + xChecker.CacheKey); context.setContent(cacheContent.ToString()); setPageMeta_FromCache(ctx, xChecker.CacheKey); return; } // 2) 运行 before action (获取所有的 ActionObserver) List <ActionObserver> actionObservers = ControllerMeta.GetActionObservers(controller.GetType(), ctx.route.action); if (actionObservers != null) { foreach (ActionObserver x in actionObservers) { ActionObserver ob = (ActionObserver)ObjectContext.Create(x.GetType()); obList.Add(ob); Boolean isContinue = ob.BeforeAction(ctx); if (!isContinue) { return; } } } // 3) 运行 action MethodInfo actionMethod = ctx.ActionMethodInfo; // context.getActionMethod(); // 设值模板并载入全局变量 setControllerView(controller, actionMethod); // 运行并处理post值 ActionRunner.runAction(ctx, controller, actionMethod, controller.utils.runAction); if (ctx.utils.isEnd()) { afterAction(ctx); return; } String actionContent = controller.utils.getActionResult(); // 4) 后续缓存处理 if (xChecker.IsActionCache) { xChecker.AddCache(actionContent); addPageMeta_ToCache(ctx, xChecker.CacheKey); } actionContent = PostValueProcessor.ProcessPostValue(actionContent, ctx); if (ctx.utils.isAjax) { context.showEnd(actionContent); } else if (ctx.utils.isFrame()) { int intNoLayout = ctx.utils.getNoLayout(); if (intNoLayout == 0) { String content = MvcUtil.getFrameContent(actionContent); context.showEnd(content); } else { context.setContent(actionContent); } } else { context.setContent(actionContent); } afterAction(ctx); }
public static void RegisterRoutes(RouteCollection routes) { string[] siteNamespace = new string[] { "Site.Controllers" }; // when set to TRUE this means that if a file exists and also a route matches, the routes win routes.RouteExistingFiles = false; routes.MapRoute("Robots", "robots.txt", new { controller = "UrlRedirect", action = "Robotos" }); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*staticfiles}", new { staticfiles = @".*\.(css|js|gif|jpg|ico|txt)" }); // removed png for dynamicimages //routes.IgnoreRoute("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"}); //routes.IgnoreRoute("{*allasp}", new {allasp=@".*\.asp"}); // leave classic asp //routes.IgnoreRoute(""); // don't take over the root // errors routes.MapRoute("LogJavascriptError", "Error/LogJavascriptError", new { controller = "Error", action = "LogJavascriptError" }); routes.MapRoute("FixError", "Error/FixError", new { controller = "Error", action = "FixError" }); if (Util.GetSettingBool("404GoesToHomepage", false)) { routes.MapRoute("errorNotFound", "Error/NotFound", new { controller = "Home", action = "NotFound" }); routes.MapRoute("error404", "Error/404", new { controller = "Home", action = "NotFound" }); } else { routes.MapRoute("errorNotFound", "Error/NotFound", new { controller = "Error", action = "NotFound" }); routes.MapRoute("error404", "Error/404", new { controller = "Error", action = "NotFound" }); } routes.MapRoute("error", "Error/{errorPage}", new { controller = "Error", action = "ShowErrorPage" }); routes.MapRoute("trackingGif", "Track/{guid}", new { controller = "Common", action = "TrackingGif" }); // images routes.MapRoute("RenderDynamicImage", "i/{id}_{version}/{crunched_title}.png", new { controller = "Images", action = "RenderDynamicImage" }); // ---------------------- // home routes.MapRoute("home", "", new { controller = "Home", action = "Index" }); routes.MapRoute("default.aspx", "default.aspx", new { controller = "Home", action = "Index" }); // ---------------------- // document downloads // root categories, must be assigned to a page with a template of 'documentrepository' routes.MapRoute("documentrepository", "DocumentRepository", new { controller = "DocumentCategory", action = "ByPageID" }); // all other sub categories and documents routes.MapRoute("documentcategory", "DocumentCategory/{enccategoryid}", new { controller = "DocumentCategory", action = "ByCategoryID" }); routes.MapRoute("downloaddocument", "DownloadDocument/{encryptedID}", new { controller = "Download", action = "DownloadDocument" }); // search routes.MapRoute("search", "Search", new { controller = "Search", action = "Search" }); // XML Sitemap routes.MapRoute("XMLSitemap", "XMLSitemap", new { controller = "XML", action = "GetSitemapXML" }); routes.MapRoute( "pageid", // Route name "Page/{id}/{crunched_title}", // URL with parameters new { controller = "StandardPage", action = "ByPageID" }, // match pattern new { id = @"\d+" } // Parameter defaults ); //pages routes.MapRoute("page", "Page/{*urlRewriteTitle}", new { controller = "StandardPage", action = "Index" }); // standard beweb route routes.MapRoute( "BewebModels", // Route name "{controller}/{id}/{crunched_title}", // URL with parameters new { action = "Index" }, // Parameter defaults new { controller = MvcUtil.GetSiteControllerNamesPattern(), id = @"\d+" }, // match pattern siteNamespace // namespaces ); // standard MVC route routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new { controller = MvcUtil.GetSiteControllerNamesPattern() }, siteNamespace // namespaces ); // note this will take precedence over the UrlRedirectController below for any single word path (eg "/whatever") // good to use for small sites where UrlRedirectController is not used //routes.MapRoute("pagecode", "{pagecode}", new {controller = "StandardPage", action = "ByPageCode"}); routes.MapRoute("catchall", "{*incomingUrl}", new { controller = "UrlRedirect", action = "CantBeRouted" }, siteNamespace); }