Exemple #1
0
        /// <summary>
        /// 运行其他 action,并将运行结果作为当前 action 的内容
        /// </summary>
        /// <param name="action"></param>
        /// <param name="id"></param>
        protected void run(aActionWithId action, int id)
        {
            if (ctx.utils.isAjax)
            {
                if (ctx.HasErrors)
                {
                    echoError();
                }
                else
                {
                    echoAjaxOk();
                }
                return;
            }

            if (isSameType(action.Method))
            {
                setView(action.Method);
                action(id);
            }
            else
            {
                //ControllerBase mycontroller = ControllerFactory.FindController( action.Method.DeclaringType, ctx );
                //mycontroller.view( action.Method.Name );
                //action.Method.Invoke( mycontroller, new object[] { id } );
                //actionContent( mycontroller.utils.getActionResult() );

                content(ControllerRunner.Run(ctx, action, id));
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取某 action 的内容
        /// </summary>
        /// <param name="action"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public String loadHtml(aActionWithId action, int id)
        {
            String result;

            if (isSameType(action.Method))
            {
                String   actionName   = action.Method.Name;
                Template originalView = utils.getCurrentView();

                setView(action.Method);

                action(id);

                Template resultView = utils.getCurrentView();
                utils.setCurrentView(originalView);
                result = resultView.ToString();
            }
            else
            {
                //ControllerBase targetController = action.Target as ControllerBase;
                //ControllerFactory.InjectController( targetController, ctx );
                //targetController.view( action.Method.Name );
                //action( id );
                //result = targetController.utils.getCurrentView().ToString();

                result = ControllerRunner.Run(ctx, action, id);
            }

            return(result);
        }
Exemple #3
0
 public static string To( string memberType, string memberUrl, aActionWithId action, long id, long appId )
 {
     String ownerPath = LinkHelper.GetMemberPathPrefix( memberType, memberUrl );
     String url = toPrivate( action, id );
     if (url == null) return null;
     url = LinkHelper.addAppId( url, appId );
     return appendExt( strUtil.Join( ownerPath, url ) );
 }
Exemple #4
0
        public static String To( IMember member, aActionWithId action, int id )
        {
            String x = LinkMap.To( member, action, id, 0 );
            if (x != null) return x;

            String ownerPath = LinkHelper.GetMemberPathPrefix( member );
            return LinkHelper.AppendApp( -1, LinkHelper.GetController( action.Target.GetType() ), action.Method.Name, id, ownerPath );
        }
Exemple #5
0
 //-------------------------------------------------------------------------
 public static String To( IMember member, aActionWithId action, int id, int appId )
 {
     String ownerPath = LinkHelper.GetMemberPathPrefix( member );
     String url = toPrivate( action, id );
     if (url == null) return null;
     url = LinkHelper.addAppId( url, appId );
     return appendExt( strUtil.Join( ownerPath, url ) );
 }
 public static String Run( MvcContext ctx, aActionWithId action, int id )
 {
     ControllerBase targetController = action.Target as ControllerBase;
     ControllerFactory.InjectController( targetController, ctx );
     targetController.view( action.Method.Name );
     action( id );
     return targetController.utils.getActionResult();
 }
Exemple #7
0
        public static String Run(MvcContext ctx, aActionWithId action, int id)
        {
            ControllerBase targetController = action.Target as ControllerBase;

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

            String actions;

            dic.TryGetValue(t, out actions);

            dic[t] = strUtil.Join(actions, action.Method.Name);
        }
        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 #10
0
        public void test()
        {
            aAction       a = myAction;
            aActionWithId b = myActionWithId;

            object action  = a;
            object actionB = b;

            testAction(action, 9);
            testAction(actionB, 19);
        }
Exemple #11
0
        public static string To(string memberType, string memberUrl, aActionWithId action, long id, long appId)
        {
            String ownerPath = LinkHelper.GetMemberPathPrefix(memberType, memberUrl);
            String url       = toPrivate(action, id);

            if (url == null)
            {
                return(null);
            }
            url = LinkHelper.addAppId(url, appId);
            return(appendExt(strUtil.Join(ownerPath, url)));
        }
        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 #13
0
        public static String To(IMember member, aActionWithId action, long id, long appId)
        {
            String x = LinkMap.To(member, action, id, appId);

            if (x != null)
            {
                return(x);
            }

            String ownerPath = LinkHelper.GetMemberPathPrefix(member);

            return(LinkHelper.AppendApp(appId, LinkHelper.GetController(action.Target.GetType()), action.Method.Name, id, ownerPath));
        }
Exemple #14
0
        private static String toPrivate(aActionWithId action, long id)
        {
            Dictionary <String, String> map = getMap();

            if (map.Count == 0)
            {
                return(null);
            }

            String controller = action.Target.GetType().FullName;
            String actionName = isLinkToLow ? action.Method.Name.ToLower() : action.Method.Name;

            return(getLinkActionStr(map, controller, actionName, id));
        }
Exemple #15
0
        private void testAction(object obj, long id)
        {
            aAction action = obj as aAction;

            if (action != null)
            {
                action();
                return;
            }

            aActionWithId actionb = obj as aActionWithId;

            if (actionb != null)
            {
                actionb(id);
            }
        }
Exemple #16
0
        /// <summary>
        /// 运行其他 action,并将运行结果作为当前 action 的内容
        /// </summary>
        /// <param name="action"></param>
        /// <param name="id"></param>
        protected void run(aActionWithId action, long id)
        {
            if (ctx.utils.isAjax)
            {
                if (ctx.HasErrors)
                {
                    echoError();
                }
                else
                {
                    echoAjaxOk();
                }
                return;
            }

            content(ControllerRunner.Run(this, action, id));
        }
        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 #18
0
        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 #19
0
        /// <summary>
        /// 运行某 action
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="action"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static String Run( ControllerBase thisController, aActionWithId action, int id )
        {
            ControllerBase targetController = action.Target as ControllerBase;

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

                return result;
            }
            else {

                ControllerFactory.InjectController( targetController, thisController.ctx );
                targetController.view( action.Method.Name );
                action( id );
                return targetController.utils.getActionResult();
            }
        }
Exemple #20
0
        /// <summary>
        /// 运行某 action
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="action"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static String Run(ControllerBase thisController, aActionWithId action, int id)
        {
            ControllerBase targetController = action.Target as ControllerBase;

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

                return(result);
            }
            else
            {
                ControllerFactory.InjectController(targetController, thisController.ctx);
                targetController.view(action.Method.Name);
                action(id);
                return(targetController.utils.getActionResult());
            }
        }
Exemple #21
0
 /// <summary>
 /// 生成到某个action的链接
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static String to(aActionWithId action, long id)
 {
     return("");
 }
Exemple #22
0
 /// <summary>
 /// 手动指定当前 action 的视图文件(指定视图文件之后,默认的模板将被忽略)
 /// </summary>
 /// <param name="action"></param>
 public void view(aActionWithId action)
 {
     view(action.Method);
 }
Exemple #23
0
 public String To( String memberType, String memberUrl, aActionWithId action, int id, int appId )
 {
     String ownerPath = GetMemberPathPrefix( memberType, memberUrl );
     return AppendApp( appId, getController( action.Target.GetType() ), action.Method.Name, id, ownerPath );
 }
Exemple #24
0
 /// <summary>
 /// 设置模板中表单提交的target
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 protected void target(aActionWithId action, long id)
 {
     set("ActionLink", to(action, id));
 }
Exemple #25
0
 /// <summary>
 /// 加载其他 action 内容,到当前html代码处
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 public static void load( aActionWithId action, int id )
 {
 }
Exemple #26
0
        private Boolean passAction(aActionWithId action)
        {
            String fullName = strUtil.Join(action.Method.DeclaringType.FullName, action.Method.Name, ".");

            return(ctx.route.getControllerAndActionFullName().Equals(fullName));
        }
Exemple #27
0
 public static String To(aActionWithId action, long id)
 {
     return(To(null, action, id, -1));
 }
Exemple #28
0
 /// <summary>
 /// 生成到某个action的链接
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static String to( aActionWithId action, long id )
 {
     return "";
 }
Exemple #29
0
 public String To( IMember member, aActionWithId action, int id )
 {
     String ownerPath = GetMemberPathPrefix( member );
     return AppendApp( _appId, getController( action.Target.GetType() ), action.Method.Name, id, ownerPath );
 }
Exemple #30
0
 /// <summary>
 /// 链接到某个 action,链接中不包含 appId 信息
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public string t2(aActionWithId action, long id)
 {
     return(ctx.link.T2(action, id));
 }
 private static void addActions( StringBuilder sb, aActionWithId[] arrActions )
 {
     foreach (aActionWithId a in arrActions) {
         sb.Append( getAction( a.Method ) );
     }
 }
Exemple #32
0
 public static String To( aActionWithId action, long id )
 {
     return appendExt( toPrivate( action, id ) );
 }
 public SiteAdminOperation(int id, String name, int menuId, aActionWithId action, String rootNamespace)
 {
     init(id, name, menuId);
     this.Url = SecurityUtils.getPath(action.Method, rootNamespace);
 }
Exemple #34
0
 /// <summary>
 /// 将某 action 的内容加载到指定位置
 /// </summary>
 /// <param name="sectionName">需要加载内容的位置</param>
 /// <param name="action">被加载的 action</param>
 /// <param name="id"></param>
 protected void load(string sectionName, aActionWithId action, long id)
 {
     set(sectionName, loadHtml(action, id));
 }
        public static SecurityAction GetByAction( aActionWithId a ) {

            return GetByUrl( SecurityActionHelper.getAction( a ) );
        }
 public SiteAdminOperation(long id, string name, long menuId, aActionWithId action, string rootNamespace)
 {
     init( id, name, menuId );
     this.Url = SecurityUtils.getPath( action.Method, rootNamespace );
     checkLowerUrl();
 }
Exemple #37
0
 public static SecurityAction GetByAction(aActionWithId a)
 {
     return(GetByUrl(SecurityActionHelper.getAction(a)));
 }
 /// <summary>
 /// 链接到某个 action,链接中不包含 appId 信息
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public String t2(aActionWithId action, int id)
 {
     return(this.Link.T2(action, id));
 }
 public static String getAction( aActionWithId a )
 {
     return getAction( a.Method );
 }
Exemple #40
0
 /// <summary>
 /// 跳转页面到指定 action
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 public void redirect(aActionWithId action, long id)
 {
     redirectUrl(ctx.link.To(action, id));
 }
Exemple #41
0
 public static String To(aActionWithId action, long id)
 {
     return(appendExt(toPrivate(action, id)));
 }
Exemple #42
0
        public static String To( String memberType, String memberUrl, aActionWithId action, int id, int appId )
        {
            String x = LinkMap.To( memberType, memberUrl, action, id, appId );
            if (x != null) return x;

            String ownerPath = LinkHelper.GetMemberPathPrefix( memberType, memberUrl );
            return LinkHelper.AppendApp( appId, LinkHelper.GetController( action.Target.GetType() ), action.Method.Name, id, ownerPath );
        }
 /// <summary>
 /// 跳转页面到指定 action
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 public void redirect(aActionWithId action, int id)
 {
     redirectUrl(Link.To(action, id));
 }
Exemple #44
0
 /// <summary>
 /// 链接到某个 action,链接中不包含 appId 信息
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public String t2(aActionWithId action, int id)
 {
     return(ctx.link.T2(action, id));
 }
Exemple #45
0
 public SiteAdminOperation(long id, string name, long menuId, aActionWithId action, string rootNamespace)
 {
     init(id, name, menuId);
     this.Url = SecurityUtils.getPath(action.Method, rootNamespace);
     checkLowerUrl();
 }
Exemple #46
0
 private Boolean passAction( aActionWithId action )
 {
     String fullName = strUtil.Join( action.Method.DeclaringType.FullName, action.Method.Name, "." );
     return ctx.route.getControllerAndActionFullName().Equals( fullName );
 }
        /// <summary>
        /// 运行其他 action,并将运行结果作为当前 action 的内容
        /// </summary>
        /// <param name="action"></param>
        /// <param name="id"></param>
        protected void run(aActionWithId action, long id)
        {
            if (ctx.utils.isAjax) {
                if (ctx.HasErrors)
                    echoError();
                else
                    echoAjaxOk();
                return;
            }

            content( ControllerRunner.Run( this, action, id ) );
        }
Exemple #48
0
 /// <summary>
 /// 获取某 action 的内容
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public string loadHtml(aActionWithId action, long id)
 {
     return(ControllerRunner.Run(this, action, id));
 }
Exemple #49
0
        private static String toPrivate( aActionWithId action, long id )
        {
            Dictionary<String, String> map = getMap();
            if (map.Count == 0) return null;

            String controller = action.Target.GetType().FullName;
            String actionName = isLinkToLow ? action.Method.Name.ToLower() : action.Method.Name;

            return getLinkActionStr( map, controller, actionName, id );
        }
 /// <summary>
 /// 设置模板中表单提交的target
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 protected void target(aActionWithId action, long id)
 {
     set( "ActionLink", to( action, id ) );
 }
 public static String getReply_Actions()
 {
     Forum.Users.PostController p = new Forum.Users.PostController();
     aActionWithId[] arrActions = new aActionWithId[] { p.ReplyPost, p.QuotePost, p.ReplyTopic, p.QuoteTopic };
     return getActionStr( arrActions );
 }
 /// <summary>
 /// 获取某 action 的内容
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public string loadHtml(aActionWithId action, long id)
 {
     return ControllerRunner.Run( this, action, id );
 }
 //------------------------------------------------------------------------------
 private static String getActionStr( aActionWithId[] arrActions )
 {
     StringBuilder sb = new StringBuilder();
     addActions( sb, arrActions );
     return sb.ToString();
 }
 /// <summary>
 /// 跳转页面到指定 action
 /// </summary>
 /// <param name="action"></param>
 /// <param name="id"></param>
 public void redirect(aActionWithId action, long id)
 {
     redirectUrl( ctx.link.To( action, id ) );
 }
Exemple #55
0
        protected void observe( aActionWithId 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="action"></param>
 /// <param name="id"></param>
 /// <returns>返回一个链接</returns>
 public string to(aActionWithId action, long id)
 {
     return ctx.link.To( action, id );
 }
Exemple #57
0
 public static String To( aActionWithId action, int id )
 {
     return To( null, action, id, -1 );
 }
 /// <summary>
 /// 手动指定当前 action 的视图文件(指定视图文件之后,默认的模板将被忽略)
 /// </summary>
 /// <param name="action"></param>
 public void view( aActionWithId action )
 {
     view( action.Method );
 }
Exemple #59
0
 private static String getMethodName(aActionWithId action)
 {
     return(action.Method.Name);
 }
 /// <summary>
 /// 将某 action 的内容加载到指定位置
 /// </summary>
 /// <param name="sectionName">需要加载内容的位置</param>
 /// <param name="action">被加载的 action</param>
 /// <param name="id"></param>
 protected void load(string sectionName, aActionWithId action, long id)
 {
     set( sectionName, loadHtml( action, id ) );
 }