예제 #1
0
 private String checkFrame(MvcContext ctx, String content)
 {
     if (ctx.utils.isFrame())
     {
         return(MvcUtil.getFrameContent(content));
     }
     return(content);
 }
예제 #2
0
        public override void Process(ProcessContext context)
        {
            MvcEventPublisher.Instance.BeginAddNsLayout(context.ctx);
            if (context.ctx.utils.isSkipCurrentProcessor())
            {
                return;
            }

            MvcContext ctx = context.ctx;

            String content = context.getContent();

            int intNoLayout = ctx.utils.getNoLayout();

            if (intNoLayout < 0)
            {
                intNoLayout = 0;
            }

            IList paths     = ctx.utils.getLayoutPath();
            int   pathCount = paths.Count - intNoLayout;

            for (int i = 0; i < pathCount; i++)
            {
                Boolean isLastLayout = i == pathCount - 1;

                content = addLayoutPrivate(paths[i].ToString(), content, ctx, isLastLayout);

                if (ctx.utils.isEnd())
                {
                    context.endMsgByView(content);
                    return;
                }
            }



            if (intNoLayout > 0)
            {
                if (ctx.utils.isFrame())
                {
                    content = MvcUtil.getFrameContent(content);
                }
                else
                {
                    content = MvcUtil.getNoLayoutContent(content);
                }
            }

            context.setContent(content);
        }
예제 #3
0
        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.CreateObject(x.GetType());
                    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);
        }
예제 #4
0
        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);
        }