コード例 #1
0
 public void OnResultExecuting(ResultExecutingContext filterContext) {
     // should only run on a full view rendering result
     if (!(filterContext.Result is ViewResult) || !Orchard.UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
         return;
     _resourceManager.Require("script", "jQuery");
     _resourceManager.Include("script", "~/Modules/Orchard.MediaPicker/Scripts/MediaPicker.js", null);
 }
コード例 #2
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null)
                return;

            var workContext = _workContextAccessor.GetContext(filterContext);

            if (workContext == null ||
                workContext.Layout == null ||
                workContext.CurrentSite == null ||
                AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            var group = _deviceGroupService.GetCurrentGroup();
            if (group == null)
                return;

            if (group.Record.SwitcherEnabled && !string.IsNullOrWhiteSpace(group.Record.SwitcherText))
            {
                if (!string.IsNullOrWhiteSpace(group.Record.SwitcherZone))
                {
                    dynamic switcherShape = Shape.ThemeSwitcher_Links(SwitcherText: group.Record.SwitcherText);
                    var zone = workContext.Layout.Zones[group.Record.SwitcherZone];
                    zone.Add(switcherShape, group.Record.SwitcherPosition);
                }
            }
        }
コード例 #3
0
        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var trace = new MallBrowseTrace();
            trace.SourceOfPurchase();

            base.OnResultExecuting(filterContext);
        }
コード例 #4
0
        protected override void OnResultExecuting(ResultExecutingContext ctx)
        {
            base.OnResultExecuting(ctx);

            string _ipAddress;
            string _sessionId;
            _ipAddress = ctx.HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(_ipAddress))
            { _ipAddress = ctx.HttpContext.Request.ServerVariables["REMOTE_ADDR"]; }
            if (Request.Cookies["sessionKey"] != null)
            {
                _sessionId = Request.Cookies["sessionKey"].Value;
            }
            else
            {
                Response.Cookies.Add(new System.Web.HttpCookie("sessionKey", ctx.HttpContext.Session.SessionID));
                Response.Cookies["sessionKey"].Expires = DateTime.Now.AddHours(12);
                _sessionId = ctx.HttpContext.Session.SessionID;
            }

            Tracking track = new Tracking();
            track.IP = _ipAddress;
            track.Session = _sessionId;
            track.URL = ctx.HttpContext.Request.Url.PathAndQuery;
            track.CreatedDate = DateTime.Now;

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                db.Trackings.Add(track);
                db.SaveChanges();
            }

            ViewBag.PageModel = PageModel;
        }
コード例 #5
0
ファイル: ModalAdminFilter.cs プロジェクト: wezmag/Coevery
 public void OnResultExecuting(ResultExecutingContext filterContext) {
     // should only run on a full view rendering result
     if (!(filterContext.Result is ViewResult) || !UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
         return;
     _resourceManager.Include("stylesheet", "~/Modules/Orchard.MediaLibrary/Styles/dialog-mode.css", null);
     _resourceManager.Include("script", "~/Modules/Orchard.MediaLibrary/Scripts/modal-window.js", null);
 }
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var url = new UrlHelper(filterContext.RequestContext);
            var id = filterContext.RouteData.Values["id"];

            if (filterContext.Controller.GetType() == typeof(DataCollectionController))
            {
                var projectId = filterContext.RouteData.Values["projectId"];

                filterContext.Controller.ViewBag.Steps = new List<Step>
                                                             {
                                                                 new Step {Url = url.Action("Step1", "DataCollection", new {id, projectId}), Name = "Section 1"},
                                                                 new Step {Url = url.Action("Step2", "DataCollection", new {id, projectId}), Name = "Section 2"}
                                                             };
                filterContext.Controller.ViewBag.MaxStep = 2;
            }
            else if (filterContext.Controller.GetType() == typeof(ApprovalController))
            {
                filterContext.Controller.ViewBag.Steps = new List<Step>
                                                             {
                                                                 new Step {Url = url.Action("Step1", "Approval", new {id }), Name = "Section 1"},
                                                                 new Step {Url = url.Action("Step2", "Approval", new {id }), Name = "Section 2"},
                                                                 new Step {Url = url.Action("Confirm", "Approval", new {id}), Name = "Confirm"}
                                                             };
                filterContext.Controller.ViewBag.MaxStep = 2;
            }
        }
コード例 #7
0
ファイル: BrandingFilter.cs プロジェクト: bkupev/detached
        public void OnResultExecuting(ResultExecutingContext filterContext) 
        {

            // ignore filter on admin pages
            if (AdminFilter.IsApplied(filterContext.RequestContext)) 
                return;

            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
                return;

            var settings = _settingsService.GetSettings();

            if(String.IsNullOrEmpty(settings.AccentCss)) 
                return;

            var themeName = _siteThemeService.GetSiteTheme();
            if (themeName.Name == Constants.THEME_NAME)
            {
                var viewResult = filterContext.Result as ViewResult;
                if (viewResult == null)
                    return;

                if (settings.UseBranding) 
                {
                    /* TODO: Replace note use Items collection */
                    System.Web.HttpContext.Current.Items[Constants.ITEM_USE_BRANDING] = settings.UseBranding.ToString();
                    System.Web.HttpContext.Current.Items[Constants.ITEM_TAGLINE] = settings.Tagline;
                }
            }
        }
コード例 #8
0
        public override void OnResultExecuting(ResultExecutingContext context)
        {
            // if (!context.HttpContext.User.Identity.IsAuthenticated) return;
            // var uId = new CurrentUser(context.HttpContext).person.Id;
            var uname = context.HttpContext.User.Identity.Name;
            var request = context.HttpContext.Request;

            var refUrl = "";
            if (request.UrlReferrer != null) refUrl = request.UrlReferrer.ToString();

            PageRequest pv = new PageRequest
            {
                Name = request.RawUrl,
                Url = request.RawUrl,
                UrlReferrer = refUrl,
                UserIP = request.UserHostAddress,
                UserName = uname,
                // UserId = uId, CookieVal = reqInfo.Cookies["yourcookie"].Value,
                Created = ExtensionMethods.JsonDate(DateTime.Now),
                Action = (string)context.RequestContext.RouteData.Values["action"],
                Controller = (string)context.RouteData.Values["controller"],
                Param1 = (string)context.RouteData.Values["uref"],
                PageId = Convert.ToInt32(context.RouteData.Values["Id"]),
            };

            LogPageView(pv);
        }
コード例 #9
0
		public void OnResultExecuting(ResultExecutingContext filterContext)
		{
			if (!_profilerSettings.EnableMiniProfilerInPublicStore)
				return;
			
			// should only run on a full view rendering result
			var result = filterContext.Result as ViewResultBase;
			if (result == null)
			{
				return;
			}

			if (!this.ShouldProfile(filterContext.HttpContext))
			{
				return;
			}

			if (!filterContext.IsChildAction)
			{
				_widgetProvider.Value.RegisterAction(
					"head_html_tag",
					"MiniProfiler",
					"DevTools",
					new { area = "SmartStore.DevTools" });
			}

			var viewName = result.ViewName;
			if (viewName.IsEmpty())
			{
				string action = (filterContext.RouteData.Values["action"] as string).EmptyNull();
				viewName = action;
			}

			this._profiler.Value.StepStart("ResultFilter", string.Format("{0}: {1}", result is PartialViewResult ? "Partial" : "View", viewName));
		}
コード例 #10
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var context = filterContext.HttpContext;

            var ae = context.Request.Headers["Accept-Encoding"];
            if (ae != null)
            {
                ae = ae.ToLower();
                var response = context.Response;
                if (ae.Contains("gzip"))
                {
                    response.AddHeader("Content-Encoding", "gzip");
                    response.Filter =
                        new System.IO.Compression.GZipStream(response.Filter, System.IO.Compression.CompressionMode.Compress);
                }
                else if (ae.Contains("deflate"))
                {
                    response.AddHeader("Content-Encoding", "deflate");
                    response.Filter =
                        new System.IO.Compression.DeflateStream(response.Filter, System.IO.Compression.CompressionMode.Compress);
                }
            }

            base.OnResultExecuting(filterContext);
        }
コード例 #11
0
        //protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        //{
        //    base.Initialize(requestContext);
        //    //ViewData["OpenTasks"] = DataContext.Tasks.Where(t => t.UserId == this.UserId).Count();
        //}
        protected override void OnResultExecuting(ResultExecutingContext ctx)
        {
            base.OnResultExecuting(ctx);

            //string sDbg = ctx.Controller.TempData["DebugTrc"] as string;
            //System.Diagnostics.Debug.WriteLine("OnResultExecuted " +
            //sDbg);

            string _ipAddress;
            string _sessionId;
            _ipAddress = ctx.HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(_ipAddress))
            { _ipAddress = ctx.HttpContext.Request.ServerVariables["REMOTE_ADDR"]; }
            if (Request.Cookies["sessionKey"] != null)
            {
                _sessionId = Request.Cookies["sessionKey"].Value;
            }
            else
            {
                Response.Cookies.Add(new System.Web.HttpCookie("sessionKey", ctx.HttpContext.Session.SessionID));
                Response.Cookies["sessionKey"].Expires = DateTime.Now.AddHours(12);
                _sessionId = ctx.HttpContext.Session.SessionID;
            }

            DIYFELib.Tracking.InsertTracking(_sessionId,
                                            _ipAddress,
                                            ctx.HttpContext.Request.Url.PathAndQuery);

            ViewBag.PageModel = PageModel;
        }
コード例 #12
0
 public void OnResultExecuting(ResultExecutingContext filterContext)
 {
     if (filterContext.Result is JsonResult)
     {
         (filterContext.Result as JsonResult).JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     }
 }
コード例 #13
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (!filterContext.HttpContext.Request.IsHomePage()) return;

            var globalSettings = _seoSettingsManagerWork.Value.GetGlobalSettings();

            if (!String.IsNullOrEmpty(globalSettings.HomeTitle)) {
                _pageTitleBuilderWork.Value.OverrideTitle(Tokenize(globalSettings.HomeTitle));
            }

            var resourceManager = _resourceManagerWork.Value;

            if (!String.IsNullOrEmpty(globalSettings.HomeDescription)) {
                resourceManager.SetMeta(new MetaEntry {
                    Name = "description",
                    Content = Tokenize(globalSettings.HomeDescription)
                });
            }

            if (!String.IsNullOrEmpty(globalSettings.HomeKeywords)) {
                resourceManager.SetMeta(new MetaEntry {
                    Name = "keywords",
                    Content = Tokenize(globalSettings.HomeKeywords)
                });
            }
        }
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            HttpContextBase context = filterContext.HttpContext;

            User user = null;
            string fcAuthToken = null;

            if (filterContext.HttpContext.Session["currentUser"] != null)
            {
                user = (User)filterContext.HttpContext.Session["currentUser"];
            }

            if (context.Request.Cookies[ApplicationConfiguration.FriendConnectCookie] != null)
            {
                fcAuthToken = context.Request.Cookies[ApplicationConfiguration.FriendConnectCookie].Value;
            }

            if (user == null && fcAuthToken == null)
            {
                filterContext.HttpContext.Response.Redirect("/Login", true);
            }
            else if (user != null && fcAuthToken == null)
            {
                context.Session.Remove("currentUser");
                filterContext.HttpContext.Response.Redirect("/Logout", true);
            }
        }
コード例 #15
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // Kirigami should only run on a full view rendering result
            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null)
                return;

            var workContext = _workContextAccessor.GetContext(filterContext);

            // Some standard checks
            if (workContext == null ||
                workContext.Layout == null ||
                workContext.CurrentSite == null ||
                AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            // TODO: Build and add shape to zone.
            /*var zones = workContext.Layout.Zones;
            foreach (var widgetPart in widgetParts)
            {
                if (activeLayerIds.Contains(widgetPart.As<ICommonPart>().Container.ContentItem.Id))
                {
                    var widgetShape = _contentManager.BuildDisplay(widgetPart);
                    zones[widgetPart.Record.Zone].Add(widgetShape, widgetPart.Record.Position);
                }
            }*/

        }
        public void Ensure_All_Ancestor_ViewData_Is_Merged_Without_Data_Loss()
        {
            var http = new FakeHttpContextFactory("http://localhost");

            //setup an heirarchy
            var rootViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary() };
            var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
            parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
            var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) { RouteData = new RouteData() };
            controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);

            //set up the view data with overlapping keys
            controllerCtx.Controller.ViewData["Test1"] = "Test1";
            controllerCtx.Controller.ViewData["Test2"] = "Test2";
            controllerCtx.Controller.ViewData["Test3"] = "Test3";
            parentViewCtx.ViewData["Test2"] = "Test4";
            parentViewCtx.ViewData["Test3"] = "Test5";
            parentViewCtx.ViewData["Test4"] = "Test6";
            rootViewCtx.ViewData["Test3"] = "Test7";
            rootViewCtx.ViewData["Test4"] = "Test8";
            rootViewCtx.ViewData["Test5"] = "Test9";

            var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) { RouteData = controllerCtx.RouteData };
            var att = new MergeParentContextViewDataAttribute();

            Assert.IsTrue(filter.IsChildAction);
            att.OnResultExecuting(filter);

            Assert.AreEqual(5, controllerCtx.Controller.ViewData.Count);
            Assert.AreEqual("Test1", controllerCtx.Controller.ViewData["Test1"]);
            Assert.AreEqual("Test2", controllerCtx.Controller.ViewData["Test2"]);
            Assert.AreEqual("Test3", controllerCtx.Controller.ViewData["Test3"]);
            Assert.AreEqual("Test6", controllerCtx.Controller.ViewData["Test4"]);
            Assert.AreEqual("Test9", controllerCtx.Controller.ViewData["Test5"]);
        }
コード例 #17
0
ファイル: MenuFilter.cs プロジェクト: seifipour/exams4doctors
        public void OnResultExecuting(ResultExecutingContext filterContext) {
            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult)) {
                return;
            }

            WorkContext workContext = _workContextAccessor.GetContext(filterContext);

            const string menuName = "admin";
            if (!AdminFilter.IsApplied(filterContext.RequestContext)) {
                return;
            }

            IEnumerable<MenuItem> menuItems = _navigationManager.BuildMenu(menuName);

            // Set the currently selected path
            Stack<MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, filterContext.RouteData);

            // Populate main nav
            dynamic menuShape = _shapeFactory.Menu().MenuName(menuName);
            NavigationHelper.PopulateMenu(_shapeFactory, menuShape, menuShape, menuItems);

            // Add any know image sets to the main nav
            IEnumerable<string> menuImageSets = _navigationManager.BuildImageSets(menuName);
            if (menuImageSets != null && menuImageSets.Any())
                menuShape.ImageSets(menuImageSets);

            workContext.Layout.Navigation.Add(menuShape);

            // Populate local nav
            dynamic localMenuShape = _shapeFactory.LocalMenu().MenuName(string.Format("local_{0}", menuName));
            NavigationHelper.PopulateLocalMenu(_shapeFactory, localMenuShape, localMenuShape, selectedPath);
            workContext.Layout.LocalNavigation.Add(localMenuShape);
        }
コード例 #18
0
ファイル: TransactionFilter.cs プロジェクト: elbandit/PPPDDD
 // executes before controller
 public override void OnResultExecuting(ResultExecutingContext filterContext)
 {
     // start a transaction
     var t = new TransactionScope();
     HttpContext.Current.Items["transaction"] = t;
     base.OnResultExecuting(filterContext);
 }
コード例 #19
0
		public void Should_delegate_to_result_filter_executing()
		{
			var attribute = new FilterUsingAttribute(typeof(TestResultFilter));
			var context = new ResultExecutingContext();
			attribute.OnResultExecuting(context);
			context.Result.ShouldBe<EmptyResult>();
		}
コード例 #20
0
 public void OnResultExecuting(ResultExecutingContext filterContext)
 {
     timer = Stopwatch.StartNew();
     filterContext.HttpContext.Response.Write(
     string.Format("<div>Result starte time: {0}</div>",
     System.DateTime.Now.ToShortTimeString()));
 }
コード例 #21
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var actionName = filterContext.RouteData.Values["action"] as string;

            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null) return;

            // Ask the runtime to see if anything is registered and we need to use it
            var provider = ViewInfoProviders.GetPathProvider(filterContext);
            if (provider == null) return;

            // Get the name of the view, if nothing is specified, we take the name of the action
            // since this is the same as the value of return View();
            var viewName = (string.IsNullOrEmpty(viewResult.ViewName)) ? actionName : viewResult.ViewName;

            // Ask the collection to get the correct view path from the specified IViewProvider
            var viewInfo = provider.GetViewInfo(filterContext, viewResult);
            if (viewInfo == null) return;

            string newView = viewInfo.ViewPath + viewName;
            var foundView = ViewEngines.Engines.FindView(filterContext, newView, viewResult.MasterName);
            if (foundView == null || foundView.SearchedLocations != null) return;

            viewResult.ViewName = newView;
        }
コード例 #22
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var response = filterContext.HttpContext.Response;

            if (filterContext.Result is ViewResult)
                response.Filter = new HtmlMinifierFilter(response.Filter);
        }
コード例 #23
0
        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // Before View Rendering logic
            base.OnResultExecuting(filterContext);

            filterContext.HttpContext.Response.Write(this.Msg);
        }
コード例 #24
0
ファイル: LogginAction.cs プロジェクト: MCorzo/MyTunes
 public override void OnResultExecuting(ResultExecutingContext filterContext)
 {
     Logger.DebugFormat(
         "El resultado fue {0}",
         filterContext.Result.ToString());
     base.OnResultExecuting(filterContext);
 }
コード例 #25
0
 public void OnResultExecuting(ResultExecutingContext filterContext) {
     var workContext = _wca.GetContext();
     var routeValues = filterContext.RouteData.Values;
     workContext.Layout.Metadata.Alternates.Add(BuildShapeName(routeValues, "area"));
     workContext.Layout.Metadata.Alternates.Add(BuildShapeName(routeValues, "area", "controller"));
     workContext.Layout.Metadata.Alternates.Add(BuildShapeName(routeValues, "area", "controller", "action"));
 }
コード例 #26
0
ファイル: TrackerFilter.cs プロジェクト: dminik/voda_code
        public void OnResultExecuting(ResultExecutingContext filterContext) {
            // ignore tracker on admin pages
            if (AdminFilter.IsApplied(filterContext.RequestContext)) {
                return;
            }

            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
                return;

            var script = _cacheManager.Get("GoogleAnalytics.Settings",
                              ctx => {
                                  ctx.Monitor(_signals.When("GoogleAnalytics.SettingsChanged"));
                                  var settings = _settingsService.Get();
                                  return !settings.Enable ? null : settings.Script;
                              });

            if(String.IsNullOrEmpty(script)) {
                return;
            }

            var context = _workContextAccessor.GetContext();
            var tail = context.Layout.Tail;
            tail.Add(new MvcHtmlString(script));
        }
コード例 #27
0
        public void OnResultExecuting(ResultExecutingContext filterContext) {
            
            // Only need to include scripts on normal view results and not in admin
            // TODO: We could set an option in the context if we want the possibility of admin-side delta
            if (!(filterContext.Result is ViewResult) 
                || Orchard.UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
                return;

            var context = new DeltaInstanceConfiguration();

            foreach (var p in _deltaInstanceProviders) {
                p.Configure(context);
            }

            dynamic stuff = new Stuff();

            var defs = context.Instances.Select(i => {

                foreach (var req in i.Requires) {
                    var settings = _resourceManager.Require(req.ResourceType, req.ResourceName);
                    if (req.Delegate != null) req.Delegate(settings);
                }

                return new {
                    Namespace = i.Namespace,
                    Type = i.TypeName,
                    Properties = i.Properties
                };

            });
            stuff.Instances = defs;
            string json = stuff.Json();
            string jscript = "Delta.Ready(function(){Delta.Configure("+json+");});";
            _resourceManager.RegisterFootScript("<script type=\"text/javascript\" >"+jscript+"</script>");
        }
コード例 #28
0
		/// <summary>Called by the ASP.NET MVC framework before the action result executes.</summary>
		/// <param name="filterContext">The filter context.</param>
		public override void OnResultExecuting(ResultExecutingContext filterContext)
		{
			//var viewResult = filterContext.Result as ViewResult;
			//if (viewResult != null)
			//	viewResult.MasterName = "_Layout";
			base.OnResultExecuting(filterContext);
		}
コード例 #29
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var viewModel = filterContext.Controller.ViewData.Model;

            var model = viewModel as IPageViewModel<SitePageData>;
            if (model != null)
            {
                var currentContentLink = filterContext.RequestContext.GetContentLink();

                var layoutModel = model.Layout ?? _contextFactory.CreateLayoutModel(currentContentLink, filterContext.RequestContext);

                var layoutController = filterContext.Controller as IModifyLayout;
                if(layoutController != null)
                {
                    layoutController.ModifyLayout(layoutModel);
                }

                model.Layout = layoutModel;

                if (model.Section == null)
                {
                    model.Section = _contextFactory.GetSection(currentContentLink);
                }
            }
        }
コード例 #30
0
        protected override void OnResultExecuting(
            ResultExecutingContext filterContext)
        {
            // Add "Dog of the Week" info to the view bag
            var dog = new DataEntities()
                .Dogs
                .OrderByDescending(d => d.DateFeatured)
                .Select(d => new
                {
                    Id = d.DogId,
                    Name = d.Name,
                    Birthday = d.Birthday, Breed = d.Breed,
                })
                .FirstOrDefault();

            ViewBag.DogOfTheWeek = new DogOfTheWeekSummaryViewModel {
                Id = dog.Id,
                Name = dog.Name,
                ThumbnailUrl = Url.Action(
                    "Image", "Dog", new { id = dog.Id }),
                Age = GetDogAge(dog.Birthday ?? DateTime.Now),
                Breed = dog.Breed
            };

            ViewBag.SupportsTelUrls = Request.Browser.CanInitiateVoiceCall;

            base.OnResultExecuting(filterContext);
        }