public override void OnActionExecuted(ActionExecutedContext context) {
     base.OnActionExecuted(context);
     var controller = context.Controller as Controller;
     if (controller != null) {
         controller.ViewData[ParsleyValidationAttributesGenerator.USE_PARSLEY_KEY] = true;
     }
 }
コード例 #2
0
        /// <inheritdoc />
        public void OnActionExecuted(ActionExecutedContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var httpResponseException = context.Exception as HttpResponseException;
            if (httpResponseException != null)
            {
                var request = context.HttpContext.GetHttpRequestMessage();
                var response = httpResponseException.Response;

                if (response != null && response.RequestMessage == null)
                {
                    response.RequestMessage = request;
                }

                var objectResult = new ObjectResult(response)
                {
                    DeclaredType = typeof(HttpResponseMessage)
                };

                context.Result = objectResult;

                // Its marked as handled as in webapi because an HttpResponseException
                // was considered as a 'success' response.
                context.ExceptionHandled = true;
            }
        }
コード例 #3
0
ファイル: ActionFilters.cs プロジェクト: mperrenoud/packt
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var controller = filterContext.Controller as Controller;
            //Only export when ModelState is not valid
            if (!controller.ViewData.ModelState.IsValid)
            {
                //Export if we are redirecting
                if ((filterContext.Result is RedirectResult) ||
                    (filterContext.Result is RedirectToRouteResult) ||
                    (filterContext.Result is RedirectToActionResult))
                {
                    var modelState = JsonConvert.SerializeObject(
                        controller.ViewData
                            .ModelState
                            .Select(x =>
                            {
                                return new KeyValuePair<string, List<string>>(x.Key,
                                    x.Value.Errors.Select(y => y.ErrorMessage).ToList());
                            })
                            .ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
                    controller.TempData[Key] = modelState;
                }
            }

            base.OnActionExecuted(filterContext);
        }
コード例 #4
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     var time = _timer.ElapsedMilliseconds;
     context.HttpContext.Response.Headers.Add(
         "ActionElapsedTime",
         new string[] { time.ToString(CultureInfo.InvariantCulture) + " ms" });
 }
コード例 #5
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ControllerBase controller = filterContext.Controller as ControllerBase;

              if (controller != null)
              {
            string serializedModelState = controller.TempData[Key] as string;

            if (!string.IsNullOrEmpty(serializedModelState))
            {
              IEnumerable<ModelStateWrapper> modelStateWrappers = JsonConvert.DeserializeObject<IEnumerable<ModelStateWrapper>>(serializedModelState, new JsonSerializerSettings() { Error = DeserializationErrorHandler });

              if (modelStateWrappers != null)
              {
            ModelStateDictionary modelState = new ModelStateDictionary();

            foreach (ModelStateWrapper modelStateWrapper in modelStateWrappers)
            {
              ModelStateEntry ms = new ModelStateEntry();

              ms.ValidationState = modelStateWrapper.ValidationState;
              ms.AttemptedValue = modelStateWrapper.Value;
              modelState.Add(modelStateWrapper.Key, ms);
            }

            if (filterContext.Result is ViewResult)
              controller.ViewData.ModelState.Merge(modelState);

            else controller.TempData.Remove(Key);
              }
            }
              }

              base.OnActionExecuted(filterContext);
        }
コード例 #6
0
ファイル: ActionFilters.cs プロジェクト: mperrenoud/packt
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var controller = filterContext.Controller as Controller;

            var tempModelState = controller.TempData[Key] as string;
            if (tempModelState == null)
            {
                return;
            }

            Dictionary<string, List<string>> modelState = (Dictionary<string, List<string>>)JsonConvert.DeserializeObject(
                tempModelState, typeof(Dictionary<string, List<string>>));

            if (modelState.Keys.Count > 0)
            {
                //Only Import if we are viewing
                if (filterContext.Result is ViewResult)
                {
                    foreach (var entry in modelState)
                    {
                        foreach (var error in entry.Value)
                        {
                            controller.ViewData.ModelState.AddModelError(entry.Key, error);
                        }
                    }
                }
                else
                {
                    //Otherwise remove it.
                    controller.TempData.Remove(Key);
                }
            }

            base.OnActionExecuted(filterContext);
        }
    public override void OnActionExecuted(ActionExecutedContext context) {
      var exception = context.Exception as CommandRejectedException;
      if (exception == null) return;

      context.Result = new BadRequestObjectResult(exception.Errors);
      context.ExceptionHandled = true;
    }
コード例 #8
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            if (context.Result == null || context.Result is NoContentResult)
            {
                return;
            }

            if (BadActionResultTransformer.IsBadAction(context.Result))
            {
                var transformed = BadActionResultTransformer.Transform(context.Result);

                context.Result = new ObjectResult(transformed)
                {
                    StatusCode = transformed.Errors.First().Status
                };
                return;
            }

            var responseResult = (ObjectResult)context.Result;
            var relationshipPaths = FindRelationshipPathsToInclude(context.HttpContext.Request);

            if (!configuration.ValidateIncludedRelationshipPaths(relationshipPaths, responseResult.Value))
            {
                context.Result = new HttpStatusCodeResult(400);
                return;
            }

            var jsonApiContext = new Context(
                new Uri(context.HttpContext.Request.GetDisplayUrl()),
                relationshipPaths);
            responseResult.Value = jsonApiTransformer.Transform(responseResult.Value, jsonApiContext);
        }
コード例 #9
0
        public void OnActionExecuted_HandlesExceptionAndReturnsObjectResult()
        {
            // Arrange
            var filter = new HttpResponseExceptionActionFilter();
            var httpContext = new DefaultHttpContext();
            httpContext.Request.Method = "GET";

            var actionContext = new ActionContext(
                                httpContext,
                                new RouteData(),
                                Mock.Of<ActionDescriptor>());

            var context = new ActionExecutedContext(
                actionContext,
                filters: new List<IFilter>(),
                controller: new object());

            context.Exception = new HttpResponseException(HttpStatusCode.BadRequest);

            // Act
            filter.OnActionExecuted(context);

            // Assert
            Assert.True(context.ExceptionHandled);
            var result = Assert.IsType<ObjectResult>(context.Result);
            Assert.Equal(typeof(HttpResponseMessage), result.DeclaredType);
            var response = Assert.IsType<HttpResponseMessage>(result.Value);
            Assert.NotNull(response.RequestMessage);
            Assert.Equal(context.HttpContext.GetHttpRequestMessage(), response.RequestMessage);
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
コード例 #10
0
        /// <summary>
        /// アクションが実行されたとに呼び出されます。
        /// </summary>
        /// <param name="context">実行コンテキスト</param>
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            base.OnActionExecuted(context);

            //--- 例外が飛んだ場合は握り潰してエラーを通知
            if (context.Exception != null)
            {
                var color = "#C00000";
                context.Result = this.Json(new Message
                {
                    Text = "Unhandled exception occured...",
                    IsEphemeral = true,
                    Attachments = new []
                    {
                        new Attachment
                        {
                            Color      = color,
                            AuthorName = "Type",
                            AuthorLink = Uri.EscapeUriString($"https://www.google.com/search?q={context.Exception.GetType()}"),
                            Text       = context.Exception.GetType().ToString(),
                        },
                        new Attachment
                        {
                            Color      = color,
                            AuthorName = nameof(context.Exception.Message),
                            Text       = context.Exception.Message,
                        },
                        new Attachment
                        {
                            Color      = color,
                            AuthorName = nameof(context.Exception.StackTrace),
                            Text       = context.Exception.StackTrace,
                        },
                        new Attachment
                        {
                            Color      = color,
                            AuthorName = nameof(context.Exception.InnerException),
                            Text       = context.Exception.InnerException?.Message,
                        },
                    }
                });
                context.ExceptionHandled = true;
            }

            //--- JSON を返していれば正常終了とみなす
            if (context.Result is JsonResult)
                return;

            //--- ステータスコードを持つ場合はそれを通知
            var message = "Error occured...";
            var result = context.Result as HttpStatusCodeResult;
            if (result != null)
                message += Environment.NewLine + $"[HTTP Status Code : {result.StatusCode}]";

            context.Result = this.Json(new Message
            {
                Text = message,
                IsEphemeral = true,
            });
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            base.OnActionExecuted(context);

            if (context.Exception == null)
            {
                return;
            }

            var dbException = context.Exception as DbException;
            if (dbException != null)
            {
                context.Result = new BadRequestObjectResult(dbException);
            }
            else
            {
                context.Result = new InternalServerErrorResult();
            }

            var apiKey = this.config["RaygunSettings:ApiKey"];
            if (string.IsNullOrEmpty(apiKey))
            {
                return;
            }

            //TODO: update this once Raygun supports ASPNET CORE RTM
            //var settings = new RaygunSettings { ApiKey = apiKey };

            //var client = new RaygunClient(settings);
            //client.Send(context.Exception);
        }
コード例 #12
0
ファイル: AutoMap.cs プロジェクト: Supermakaka/mvc6
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var model = ((Controller)filterContext.Controller).ViewData.Model;

            object viewModel = Mapper.Map(model, SourceType, DestType);

            ((Controller)filterContext.Controller).ViewData.Model = viewModel;
        }
コード例 #13
0
ファイル: RandomNumberFilter.cs プロジェクト: ymd1223/Mvc
 public void OnActionExecuted(ActionExecutedContext context)
 {
     context.Result = new ContentResult()
     {
         Content = "4",
         ContentType = "text/plain"
     };
 }
コード例 #14
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     if (context.ActionDescriptor.DisplayName == "FiltersSample.Controllers.HomeController.Hello")
     {
         // Manipulating action result...
         context.Result = Helpers.GetContentResult(context.Result, "FIRST: ");
     }
 }
コード例 #15
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     context.Result = new ContentResult()
     {
         Content = "4",
         ContentType = new MediaTypeHeaderValue("text/plain")
     };
 }
コード例 #16
0
        private bool IsValidResult(ActionExecutedContext context)
        {
            var contextResult = context.Result;

            return contextResult is RedirectResult ||
                contextResult is RedirectToRouteResult ||
                contextResult is RedirectToActionResult;
        }
コード例 #17
0
        public ActionExecutedContext BuildActionExecuted()
        {
            var actionExecutedContext = new ActionExecutedContext(
                actionContext, new List<IFilterMetadata>(), new { });
            actionExecutedContext.Result = result;
            actionExecutedContext.Exception = exception;

            return actionExecutedContext;
        }
コード例 #18
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            if (context.Exception != null)
            {
                context.Result = Helpers.GetContentResult(null, "Hi from Action Filter");

                context.Exception = null;
            }
        }
コード例 #19
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;

            if (result != null)
            {
                result.Formatters.Add(new VCardFormatter_V3());
                result.Formatters.Add(new VCardFormatter_V4());
            }
        }
コード例 #20
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            AlertsContainer current = JsonConvert.DeserializeObject<AlertsContainer>(TempData["Alerts"] as String ?? "");
            if (current == null)
                current = Alerts;
            else
                current.Merge(Alerts);

            TempData["Alerts"] = JsonConvert.SerializeObject(current);
        }
コード例 #21
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;
            if (result != null)
            {
                result.Formatters.Add(new XmlSerializerOutputFormatter());
            }

            base.OnActionExecuted(context);
        }
コード例 #22
0
ファイル: FormatFilterController.cs プロジェクト: ymd1223/Mvc
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;
            if (result != null)
            {
                result.Formatters.Add(new CustomFormatter("application/FormatFilterController"));
            }

            base.OnActionExecuted(context);
        }
コード例 #23
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;
            if (result != null)
            {
                result.Formatters.Add(new CustomFormatter("application/custom_NoProducesContentOnClassController_Action"));
            }

            base.OnActionExecuted(context);
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;
            if (result != null)
            {
                var noContentFormatter = new HttpNoContentOutputFormatter() { TreatNullValueAsNoContent = false };
                result.Formatters.Add(noContentFormatter);
            }

            base.OnActionExecuted(context);
        }
コード例 #25
0
ファイル: HomeController.cs プロジェクト: john-pham/hapgo
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     if (User.IsSignedIn())
     {
         context.Result = RedirectToAction("Index", "Delivery", new { area = "Events" });
     }
     else
     {
         base.OnActionExecuted(context);
     }
 }
コード例 #26
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var responseContent = context.Result as ObjectResult;

            if (responseContent != null && responseContent.Value == null)
            {
                responseContent.StatusCode = (int) HttpStatusCode.NotFound;
            }

            base.OnActionExecuted(context);
        }
コード例 #27
0
        public virtual object Invoke(Type controllerType, MethodInfo action, IHttpContext context)
        {

            ControllerContext controllerContext = new ControllerContext(context);

            var controller = (IController) ServiceResolver.Current.Resolve(controllerType);
            var newController = controller as IController;

            try
            {
                controllerContext.Controller = controller;
                controllerContext.ControllerName = controllerType.Name;
                controllerContext.ControllerUri = "/" + controllerType.Name;
                controllerContext.ActionName = action.Name;

                controller.SetContext(controllerContext);

                
                if (newController != null)
                {
                    var actionContext =  new ActionExecutingContext (controllerContext);
                    newController.OnActionExecuting(actionContext);
                    if (actionContext.Result != null)
                        return actionContext.Result;
                }
                object[] args = { controllerContext };
                ActionResult result = (ActionResult)action.Invoke(controller, args);
                result.ExecuteResult(controllerContext);

                if (newController != null)
                {
                    var actionContext = new ActionExecutedContext(controllerContext, false, null);
                    newController.OnActionExecuted(actionContext);
                    if (actionContext.Result != null)
                        return actionContext.Result;
                }
                
                return result;
            }
            catch (Exception ex)
            {
                if (newController != null)
                {
                    var exceptionContext = new ExceptionContext(ex);
                    newController.OnException(exceptionContext);
                    if (exceptionContext.Result != null)
                        return exceptionContext.Result;
                }

                ActionResult result = (ActionResult) controller.TriggerOnException(ex);
                
                return result;
            }
        }
コード例 #28
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     if (context.ActionDescriptor.DisplayName == "FiltersWebSite.ProductsController.GetPrice")
     {
         context.HttpContext.Response.Headers.Append("filters",
             "On Controller Action Filter - OnActionExecuted");
     }
     else
     {
         context.Result = Helpers.GetContentResult(context.Result, "Controller Action filter - OnActionExecuted");
     }
 }
コード例 #29
0
ファイル: NormalController.cs プロジェクト: xuchrist/Mvc
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var result = context.Result as ObjectResult;
            if (result != null)
            {
                result.Formatters.Add(new PlainTextFormatter());
                result.Formatters.Add(new CustomFormatter("application/custom"));
                result.Formatters.Add(_indentingFormatter);
            }

            base.OnActionExecuted(context);
        }
コード例 #30
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            if (context.Exception != null && !context.ExceptionHandled)
            {
                context.ExceptionHandled = true;

                context.Result = new ContentResult
                {
                    ContentType = new MediaTypeHeaderValue("text/plain"),
                    Content = "Boom " + context.Exception.Message
                };
            }
        }
コード例 #31
0
    public override void OnActionExecuted(ActionExecutedContext filterContext)
    {
        var model = (IBreadcrumbs)filterContext.Controller.ViewData.Model;

        model.Breadcrumbs = BreadcrumbHelper.GetBreadCrumbs(string.Format("{0}", filterContext.RouteData.DataTokens["area"]), Page);
    }
コード例 #32
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     // Do something after the action executes.
     Console.WriteLine("MySampleActionFilter - after the action executes");
 }
コード例 #33
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     filterContext.Controller.ViewData.Add("CompanyName", CompanyNameActionAttribute.CompanyName);
 }
コード例 #34
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     //Do something after action executes
 }
コード例 #35
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     var service = context.HttpContext.RequestServices.GetService(ServiceType) as IFooService;
 }
コード例 #36
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
 }
コード例 #37
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     // Method intentionally left empty.
 }
コード例 #38
0
 void IActionFilter.OnActionExecuted(ActionExecutedContext context)
 {
 }
コード例 #39
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //Page
            var page = GetPage(filterContext);

            if (page != null)
            {
                var          requestServices           = filterContext.HttpContext.RequestServices;
                var          onPageExecuteds           = requestServices.GetServices <IOnPageExecuted>();
                var          layoutService             = requestServices.GetService <ILayoutService>();
                var          widgetService             = requestServices.GetService <IWidgetBasePartService>();
                var          applicationSettingService = requestServices.GetService <IApplicationSettingService>();
                var          themeService    = requestServices.GetService <IThemeService>();
                var          widgetActivator = requestServices.GetService <IWidgetActivator>();
                LayoutEntity layout          = layoutService.Get(page.LayoutId);
                layout.Page  = page;
                page.Favicon = applicationSettingService.Get(SettingKeys.Favicon, "~/favicon.ico");
                if (filterContext.HttpContext.User.Identity.IsAuthenticated && page.IsPublishedPage)
                {
                    layout.PreViewPage = requestServices.GetService <IPageService>().Get(page.ReferencePageID);
                }
                layout.CurrentTheme = themeService.GetCurrentTheme();
                layout.ZoneWidgets  = new ZoneWidgetCollection();
                filterContext.HttpContext.TrySetLayout(layout);
                widgetService.GetAllByPage(page, GetPageViewMode() == PageViewMode.Publish && !IsPreView(filterContext)).Each(widget =>
                {
                    if (widget != null)
                    {
                        IWidgetPartDriver partDriver = widgetActivator.Create(widget);
                        WidgetViewModelPart part     = partDriver.Display(widget, filterContext);
                        if (part != null)
                        {
                            lock (layout.ZoneWidgets)
                            {
                                if (layout.ZoneWidgets.ContainsKey(part.Widget.ZoneID))
                                {
                                    layout.ZoneWidgets[part.Widget.ZoneID].TryAdd(part);
                                }
                                else
                                {
                                    layout.ZoneWidgets.Add(part.Widget.ZoneID, new WidgetCollection {
                                        part
                                    });
                                }
                            }
                        }
                        partDriver.Dispose();
                    }
                });
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    layout.Layout = GetLayout();
                    if (GetPageViewMode() == PageViewMode.Design)
                    {
                        layout.Templates = widgetService.Get(m => m.IsTemplate == true);
                    }
                    (filterContext.Controller as Controller).ViewData.Model = layout;
                }
                if (page.IsPublishedPage && onPageExecuteds != null)
                {
                    onPageExecuteds.Each(m => m.OnExecuted(page, filterContext.HttpContext));
                }

                layoutService.Dispose();
                applicationSettingService.Dispose();
                widgetService.Dispose();
                themeService.Dispose();
            }
            else
            {
                if (!(filterContext.Result is RedirectResult))
                {
                    var viewResult = filterContext.Result as ViewResult;
                    if (viewResult != null)
                    {
                        viewResult.StatusCode = 404;
                        viewResult.ViewName   = "NotFound";
                    }
                    else
                    {
                        filterContext.Result = new RedirectResult("~/error/notfond?f=" + filterContext.HttpContext.Request.Path);
                    }
                }
            }
        }
 public void OnActionExecuted(ActionExecutedContext context)
 {
     //DateTime end = DateTime.Now;
     //double processTime = end.Subtract(start).TotalMilliseconds;
     //context.HttpContext.Response.Headers.Add("TimeExecution", processTime.ToString());
 }
コード例 #41
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     //throw new NotImplementedException();
 }
コード例 #42
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     LogMessage($"Completing: {context.RouteData.Values["controller"]} " +
                $"-> {context.RouteData.Values["action"]} -> {DateTime.Now} \n");
     LogMessage("------------------------------------------------------------------------------\n\n");
 }
コード例 #43
0
 /// <summary>
 /// Called after the action executes, before the action result
 /// </summary>
 /// <param name="context">A context for action filters</param>
 public void OnActionExecuted(ActionExecutedContext context)
 {
     //do nothing
 }
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     filterContext.HttpContext.Response.Write("OnActionExecuted</br>");
 }
コード例 #45
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     this.stopwatch.Stop();
 }
コード例 #46
0
 public override void OnActionExecuted(ActionExecutedContext context)
 {
     base.OnActionExecuted(context);
 }
コード例 #47
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var data = filterContext.RouteData;

            Debugger.Break(); // 4.
        }
コード例 #48
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
 }
コード例 #49
0
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
     this.profiler.StepStop(StepKeys.ActionFilter);
 }
コード例 #50
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            HandleAuditingAfterAction(filterContext);
        }
コード例 #51
0
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     base.OnActionExecuted(filterContext);
 }
コード例 #52
0
 /// <summary>
 /// Called after the action executes, before the action result.
 /// </summary>
 /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext" />.</param>
 public void OnActionExecuted(ActionExecutedContext context)
 {
     // Nothing to do.
 }
コード例 #53
0
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     filterContext.Controller.ViewBag.CustomActionMessage2 = "Custom Action Filter: Message from OnActionExecuted method.";
 }
コード例 #54
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     throw new NotImplementedException();
 }
コード例 #55
0
 /// <summary>
 /// Action执行完毕之后执行
 /// </summary>
 /// <param name="filterContext"></param>
 public void OnActionExecuted(ActionExecutedContext filterContext)
 {
 }
コード例 #56
0
ファイル: RolesFilter.cs プロジェクト: software-kd/Staging
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     //Log("OnActionExecuted", filterContext.RouteData);
 }
コード例 #57
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     _tracker?.Stop();
 }
コード例 #58
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     logger.LogError("OnActionExecuted");
 }
コード例 #59
0
        /// <summary>
        /// Execute filter
        /// </summary>
        /// <param name="filterContext">Filter context</param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var _store     = new StoreService(Data);
            var controller = filterContext.RouteData.Values["controller"].ToString();

            string controllerAction = string.Format("(controller, action) = ({0}, {1})", filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, filterContext.ActionDescriptor.ActionName);

            // Access denied to all page, but not to 'Home" and "User"
            if ((!_store.IsStoreInfoExist()) && !controller.Equals("Home") && !controller.Equals("User") && !controller.Equals("Diagnostic") && !controller.Equals("Functions"))
            {
                controller = filterContext.RouteData.Values["controller"].ToString();
                var action = string.Empty;

                // Allow access to proccess 'FirstTime"
                if (controller.Equals("Process"))
                {
                    var id = filterContext.RouteData.Values["id"];
                    action = filterContext.RouteData.Values["action"].ToString();

                    // If start process First time log in
                    if (action.Equals("Go"))
                    {
                        // First time log in process number
                        if (Convert.ToInt32(id) != (int)PredefinedProcess.FirstTimeNewUser)
                        {
                            if (Convert.ToInt32(id) != (int)PredefinedProcess.SignIn)
                            {
                                // Forgoten password process
                                if (!(Convert.ToInt32(id) == Convert.ToInt32(PredefinedProcess.ForgottenPassword) || Convert.ToInt32(id) == Convert.ToInt32(PredefinedProcess.ProductSearch)))
                                {
                                    CheckStoreFilter.Print(controllerAction + " - new RedirectResult(\"/User/SignIn\");");
                                    filterContext.Result = new RedirectResult("/User/SignIn");
                                }
                                else
                                {
                                    CheckStoreFilter.Print(controllerAction + " - Direct exit");
                                }
                            }
                            else
                            {
                                CheckStoreFilter.Print(controllerAction + " - Direct exit");
                            }
                        }
                        else
                        {
                            CheckStoreFilter.Print(controllerAction + " - Direct exit");
                        }
                    }
                    else if (!action.Equals("NextStep") && !action.Equals("PreviousStep"))
                    {
                        CheckStoreFilter.Print(controllerAction + " - new RedirectResult(\"/User/SignIn\");");
                        filterContext.Result = new RedirectResult("/User/SignIn");
                    }
                    else
                    {
                        CheckStoreFilter.Print(controllerAction + " - Direct exit");
                    }
                }
                else if ((!action.Equals("SignIn")) && (!string.IsNullOrEmpty(action)))
                {
                    CheckStoreFilter.Print(controllerAction + " - new RedirectResult(Url.Process(PredefinedProcess.SignIn))");
                    filterContext.Result = new RedirectResult(Url.Process(PredefinedProcess.SignIn));
                }
                else
                {
                    CheckStoreFilter.Print(controllerAction + " - Direct exit");
                }
            }
            else
            {
                CheckStoreFilter.Print(controllerAction + " - Direct exit");
            }
            //else if ((!_store.IsStoreInfoExist()) && !controller.Equals("Product"))
            //{}
        }
コード例 #60
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     //nothing for you there
 }