public static String Run( MvcContext ctx, aAction action )
        {
            ControllerBase targetController = action.Target as ControllerBase;

            ControllerFactory.InjectController( targetController, ctx );
            targetController.view( action.Method.Name );
            action();
            return targetController.utils.getActionResult();
        }
        /// <summary>
        /// 监控其他 action
        /// </summary>
        /// <param name="action"></param>
        protected void observe( aAction action )
        {
            Type t = action.Target.GetType();

            String actions;
            dic.TryGetValue( t, out actions );

            dic[t] = strUtil.Join( actions, action.Method.Name );
        }
        /// <summary>
        /// 运行某 action
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static String Run( MvcContext ctx, aAction action )
        {
            ControllerBase targetController = action.Target as ControllerBase;
            ControllerFactory.InjectController( targetController, ctx );
            //ctx.utils.setController( targetController ); // 此处不能改成ctx,在loadHtml中,如果改变ctx,会造成Layout出错

            targetController.view( action.Method.Name );
            action();
            return targetController.utils.getActionResult();
        }
        public static String getPoll_Actions() {
            Forum.Users.PollController t = new Forum.Users.PollController();
            aAction[] arrActions = new aAction[] { t.Add, t.Create };
            aActionWithId[] arrActions2 = new aActionWithId[] { t.Vote, t.Voter };
            StringBuilder sb = new StringBuilder();

            addActions( sb, arrActions );
            addActions( sb, arrActions2 );

            return sb.ToString();
        }
Exemple #5
0
        public static String getPath( aAction action, String rootNamespace )
        {
            String nsString;

            MethodInfo method = action.Method;

            nsString = strUtil.TrimStart( action.Target.GetType().FullName, rootNamespace );
            nsString = strUtil.TrimEnd( nsString, "Controller" );
            nsString = strUtil.TrimStart( nsString, "." ).Replace( ".", "/" );

            String path = strUtil.Join( nsString, method.Name );
            return path;
        }
Exemple #6
0
        public static void runAction( MvcContext ctx, ControllerBase controller, MethodInfo actionMethod, aAction run, Boolean isLayout )
        {
            if (isLayout) {
                run();
                return;
            }

            List<IActionFilter> filters = controller.utils.getActionFilters( actionMethod );
            //filters.Insert( 0, new CacheUrlAttribute() ); // Ĭ��������ַ������ͨ���޸����ý��л���

            if (filters.Count == 0) {
                run();
                return;
            }

            for (int i = 0; i < filters.Count; i++) {

                filters[i].BeforeAction( controller );

                if (ctx.utils.isEnd()) {
                    return;
                }

            }

            try {
                if (controller.utils.IsRunAction()) {
                    run();
                }
            }
            catch (Exception ex) {
                ctx.utils.setException( ex );
            }
            finally {

                for (int i = filters.Count - 1; i >= 0; i--) {

                    filters[i].AfterAction( controller );

                    if (ctx.utils.isEnd()) {
                        break;
                    }

                }

                Exception ex = ctx.utils.getException();
                if (ex != null) throw ctx.utils.getException();
            }
        }
        public static String getAdminActions() {

            Forum.Edits.TopicController ut = new Forum.Edits.TopicController();
            Forum.Edits.PostController up = new Forum.Edits.PostController();
            Forum.Edits.AttachmentController ac = new Forum.Edits.AttachmentController();
            Forum.Edits.TagController tc = new Forum.Edits.TagController();

            Forum.Moderators.TopicController t = new Forum.Moderators.TopicController();
            Forum.Moderators.TopicSaveController ts = new Forum.Moderators.TopicSaveController();
            Forum.Moderators.PostController p = new Forum.Moderators.PostController();
            Forum.Moderators.PostSaveController ps = new Forum.Moderators.PostSaveController();

            aActionWithId[] arrActions = new aActionWithId[] {


                // (admin) post
                p.AddCredit,
                ps.SaveCredit, ps.Ban, ps.UnBan, ps.Lock, ps.UnLock, ps.DeletePost, ps.DeleteTopic,

                // (edit) topic/post
                ut.Edit, ut.Update, up.Edit, up.Update,
                //up.SetReward, up.AddReward, up.SaveReward, 

                // (edit) attachment
                ac.Admin, ac.SetPermission, ac.SavePermission, ac.SaveSort, ac.Add, ac.SaveAdd, ac.Rename, ac.SaveRename, ac.Upload, ac.SaveUpload, ac.Delete,

                // (edit) tag
                tc.SaveTag
            };

            aAction[] otherActions = new aAction[] { 

                // (admin) topic 
                t.Sticky, t.Picked, t.Lock, t.Delete, t.Highlight, t.Category, t.SortSticky, t.GlobalSticky, t.Move,
                ts.Sticky, ts.StickyUndo, ts.Lock, ts.LockUndo, ts.GlobalSticky, ts.GlobalStickyUndo, ts.Pick, ts.PickedUndo, ts.Highlight, ts.HighlightUndo, ts.Delete,
                ts.Move, ts.SaveStickySort, ts.Category,
                t.GlobalSortSticky, ts.SaveGlobalStickySort
            };

            StringBuilder sb = new StringBuilder();
            addActions( sb, arrActions );
            addActions( sb, otherActions );

            return sb.ToString();
        }
Exemple #8
0
        /// <summary>
        /// 运行某 action
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static String Run( ControllerBase thisController, aAction action )
        {
            ControllerBase targetController = action.Target as ControllerBase;

            // 如果是当前controller,则直接调用;因为必须允许内部成员变量共享
            if (Object.ReferenceEquals( thisController, targetController )) {
                Template originalView = thisController.utils.getCurrentView();
                thisController.view( action.Method.Name );
                action();
                String result = thisController.utils.getActionResult();
                thisController.utils.setCurrentView( originalView );

                return result;
            }
            else {
                ControllerFactory.InjectController( targetController, thisController.ctx );
                targetController.view( action.Method.Name );
                action();
                return targetController.utils.getActionResult();
            }
        }
Exemple #9
0
 /// <summary>
 /// 加载其他 action 内容,到当前html代码处
 /// </summary>
 /// <param name="action"></param>
 public static void load( aAction action )
 {
 }
 public SiteAdminOperation(long id, string name, long menuId, aAction action, string rootNamespace)
 {
     init( id, name, menuId );
     this.Url = SecurityUtils.getPath( action.Method, rootNamespace );
     checkLowerUrl();
 }
Exemple #11
0
 private static String lnkToUser( User user, aAction action )
 {
     return Link.To( user, action, 0 );
 }
        public static ForumAction Get(aAction action, String rootNamespace)
        {
            String typeFullName = action.Target.GetType().FullName;

            return(getForumAction(typeFullName, action.Method.Name, rootNamespace));
        }
Exemple #13
0
 public String To(aAction action)
 {
     return(To(action, _appId));
 }
Exemple #14
0
 public SiteDataAdminMenu( aAction action, String rootNamespace )
 {
     String url = SecurityUtils.getPath( action, rootNamespace );
     init( 0, "", "", url );
 }
Exemple #15
0
 public static String To( IMember member, aAction action, long appId )
 {
     String ownerPath = LinkHelper.GetMemberPathPrefix( member );
     String url = toPrivate( action );
     if (url == null) return null;
     url = LinkHelper.addAppId( url, appId );
     return appendExt( strUtil.Join( ownerPath, url ) );
 }
Exemple #16
0
 public static String To( aAction action )
 {
     return appendExt( toPrivate( action ) );
 }
 public static void runAction( MvcContext ctx, ControllerBase controller, MethodInfo actionMethod, aAction run )
 {
     runAction( ctx, controller, actionMethod, run, false );
 }
 public static String getAction(aAction a)
 {
     return(getAction(a.Method));
 }
 //-------------------------------------- 绑定(加载)局部页面内容 ----------------------------------------------
 /// <summary>
 /// 将某 action 的内容加载到指定位置
 /// </summary>
 /// <param name="sectionName">需要加载内容的位置</param>
 /// <param name="action">被加载的 action</param>
 protected void load( String sectionName, aAction action )
 {
     set( sectionName, loadHtml( action ) );
 }
 /// <summary>
 /// 手动指定当前 action 的视图文件(指定视图文件之后,默认的模板将被忽略)
 /// </summary>
 /// <param name="action"></param>
 public void view( aAction action )
 {
     view( action.Method );
 }
 //-------------------------------------- 内部链接(快捷方式) ----------------------------------------------
 /// <summary>
 /// 链接到某个 action
 /// </summary>
 /// <param name="action"></param>
 /// <returns>返回一个链接</returns>
 public String to( aAction action )
 {
     return ctx.link.To( action );
 }
Exemple #22
0
 public String To(aAction action, long appId)
 {
     return(Link.To(_owner, getController(action.Target.GetType()), action.Method.Name, -1, appId));
 }
 public static void runLayoutAction( MvcContext ctx, ControllerBase layoutController, aAction action )
 {
     runAction( ctx, layoutController, action.Method, action, true );
 }
 private static void addActions( StringBuilder sb, aAction[] arrActions )
 {
     foreach (aAction a in arrActions) {
         sb.Append( getAction( a.Method ) );
     }
 }
Exemple #25
0
        private static String toPrivate( aAction action )
        {
            Dictionary<String, String> map = getMap();
            if (map.Count == 0) return null;

            String actionName = isLinkToLow ? action.Method.Name.ToLower() : action.Method.Name;

            String controller = action.Target.GetType().FullName;

            return getLinkActionStr( map, controller, actionName );
        }
 public static String getAction( aAction a )
 {
     return getAction( a.Method );
 }
Exemple #27
0
 public SiteDataAdminMenu( int id, String logo, String name, aAction action, String rootNamespace )
 {
     String url = SecurityUtils.getPath( action, rootNamespace );
     init( id, logo, name, url );
 }
Exemple #28
0
 public static String To( aAction action )
 {
     return To( null, action, -1 );
 }
 public static String getTopicNew_Actions()
 {
     Forum.Users.TopicController t = new Forum.Users.TopicController();
     aAction[] arrActions = new aAction[] { t.NewTopic, t.Create };
     return getActionStr( arrActions );
 }
Exemple #30
0
        public SiteAdminMenu(long id, String logo, String name, aAction action, String rootNamespace)
        {
            String url = SecurityUtils.getPath(action, rootNamespace);

            init(id, logo, name, url);
        }
 private static String getActionStr( aAction[] arrActions )
 {
     StringBuilder sb = new StringBuilder();
     addActions( sb, arrActions );
     return sb.ToString();
 }
        //-----------------------------------------------------------------------------

        public static SecurityAction GetByAction( aAction a ) {

            return GetByUrl( SecurityActionHelper.getAction( a ) );
        }
 public static String getQuestion_Actions()
 {
     Forum.Users.TopicController t = new Forum.Users.TopicController();
     aAction[] arrActions = new aAction[] { t.NewQ };
     return getActionStr( arrActions );
 }
Exemple #34
0
 /// <summary>
 /// 生成到某个action的链接
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public static String to( aAction action )
 {
     return "";
 }
Exemple #35
0
 public static String To( IMember member, aAction action, int appId )
 {
     return To( member, LinkHelper.GetController( action.Target.GetType() ), action.Method.Name, -1, appId );
 }
Exemple #36
0
 private static String lnkToUser(User user, aAction action)
 {
     return(Link.To(user, action, 0));
 }