Beispiel #1
0
        //protected virtual ActionResult OnAuthorization(ControllerContext controllerContext, IEnumerable<FunctionAttribute> functions)
        //{
        //    if (functions != null && functions.Count() > 0)
        //    {
        //        var lastFunction = functions.Last();
        //        var modulePermission = ModuleInfo.Permissions.Where(mp => mp.FunctionName == lastFunction.Name).FirstOrDefault();
        //        var user = controllerContext.RequestContext.HttpContext.User;
        //        bool authorizated = ModuleInfo.IsAuthorized(lastFunction.Name, user);
        //        if (!authorizated)
        //        {
        //            ActionResult actionResult = null;

        //            if (actionResult == null && !StringExtensions.IsNullOrEmptyTrim(ModuleInfo.ModuleSettings.UnauthorizedUrl))
        //            {
        //                actionResult = ((ModuleController)controllerContext.Controller).ActionResultHelper.Redirect(controllerContext.HttpContext.Response.ApplyAppPathModifier(ModuleInfo.ModuleSettings.UnauthorizedUrl));
        //            }
        //            if (actionResult == null)
        //            {
        //                actionResult = new ContentResult() { Content = Resources.ModuleUnauthorizated };
        //            }
        //            return actionResult;
        //        }
        //    }
        //    return null;
        //}
        #endregion

        #region ExecuteActionResult
        /// <summary>
        /// Executes the action result.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="actionName">Name of the action.</param>
        /// <param name="actionResult">The action result.</param>
        public ModuleResultExecutedContext ExecuteActionResult(ModuleActionInvokedContext actionInvokedContext)
        {
            var        actionName = actionInvokedContext.ControllerContext.RouteData.GetRequiredString("action");
            FilterInfo filters    = this.GetFilters(actionInvokedContext.ControllerContext, actionName);

            return(this.CustomInvokeActionResultWithFilters(actionInvokedContext.ControllerContext, filters.ResultFilters, actionInvokedContext.ActionResult));
        }
Beispiel #2
0
        public static ModuleResultExecutedContext ExecuteActionResult(ModuleActionInvokedContext actionInvokedContext)
        {
            try
            {
                //switch the module context for the view render.
                ModuleContext.Current = actionInvokedContext.ControllerContext.GetModuleContext();

                return(actionInvoker.ExecuteActionResult(actionInvokedContext));
            }
            catch (Exception e)
            {
                if (actionInvokedContext.ModulePosition.SkipError)
                {
                    return(new ModuleResultExecutedContext(actionInvokedContext.ControllerContext, actionInvokedContext.ActionResult, false, e, ""));
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #3
0
        public static ModuleResultExecutedContext ExecuteActionResult(ModuleActionInvokedContext actionInvokedContext)
        {
            try
            {
                //switch the module context for the view render.
                ModuleContext.Current = actionInvokedContext.ControllerContext.GetModuleContext();

                return actionInvoker.ExecuteActionResult(actionInvokedContext);
            }
            catch (Exception e)
            {
                if (actionInvokedContext.ModulePosition.SkipError)
                {
                    return new ModuleResultExecutedContext(actionInvokedContext.ControllerContext, actionInvokedContext.ActionResult, false, e, "");
                }
                else
                {
                    throw;
                }
            }
        }