protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.IsChildAction || Request.IsAjaxRequest() || Session == null) { return; } IUserContext user = GetCurrentUser(); //Response.AppendHeader("Refresh",Convert.ToString((Session.Timeout * 30)) + ";URL=~/Home/Index"); // set language if (Request.QueryString["lang"] != null) { ILocale locale; locale = CoreData.LocaleManager.GetUsedLocales(GetCurrentUser()).Get(Request.QueryString["lang"]); if (locale.IsNotNull()) { SetLanguage(locale.ISOCode); if (user.IsAuthenticated()) { user.Locale = locale; } } } // Render image mode. // If we render the map as image, we use Google Mercator coordinate system and Google maps. if (Request.QueryString["renderImageMode"] != null) { ViewBag.RenderImageMode = true; } // Set LogOn information ViewBag.IsLoggedIn = user.IsAuthenticated(); ViewBag.UserName = user.User.UserName; ViewBag.UserRole = string.Empty; ViewBag.MultipleRoles = false; if (user.CurrentRoles.IsNotNull() && user.CurrentRoles.Count > 0) { ViewBag.UserRole = user.CurrentRole.IsNotNull() ? "(" + user.CurrentRole.Name + ")" : string.Empty; if (user.CurrentRoles.Count > 1 && user.CurrentRole.IsNotNull()) { ViewBag.MultipleRoles = true; } } // User message if (SessionHandler.UserMessages != null) { ViewBag.UserMessages = new List <UserMessage>(SessionHandler.UserMessages); SessionHandler.UserMessages.Clear(); } // MySettings message if (SessionHandler.MySettingsMessage != null) { ViewBag.MySettingsMessage = SessionHandler.MySettingsMessage; SessionHandler.MySettingsMessage = null; } #if DEBUG ViewBag.Debug = true; #else ViewBag.Debug = false; #endif ActionDescriptor actionDescriptor = filterContext.ActionDescriptor; string actionName = actionDescriptor.ActionName; string controllerName = actionDescriptor.ControllerDescriptor.ControllerName; ViewBag.CookieName = string.Format("{0}{1}", controllerName, actionName); PageInfo currentPage = PageInfoManager.GetPageInfo(controllerName, actionName); if (currentPage.IsNotNull()) { SessionHandler.CurrentPage = currentPage; } // Log history event var logEventHistoryItem = new LogEventHistoryItem(); logEventHistoryItem.Action = actionName; logEventHistoryItem.Controller = controllerName; logEventHistoryItem.Form = Request.Form != null?Request.Form.PrettyPrint() : "-"; logEventHistoryItem.HttpAction = Request.HttpMethod; logEventHistoryItem.Url = Request.RawUrl; logEventHistoryItem.Date = DateTime.Now; logEventHistoryItem.UserName = user.User != null ? user.User.UserName : "******"; logEventHistoryItem.UserRole = user.CurrentRole != null ? user.CurrentRole.Identifier : "-"; logEventHistoryItem.Referrer = Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : "-"; var logEventHistory = SessionHandler.LogEventHistory; if (logEventHistory == null) { logEventHistory = new LogEventHistory(); SessionHandler.LogEventHistory = logEventHistory; } logEventHistory.HistoryItems.Add(logEventHistoryItem); if (logEventHistory.HistoryItems.Count > 10) { logEventHistory.HistoryItems.RemoveAt(0); } base.OnActionExecuting(filterContext); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.IsChildAction || Request.IsAjaxRequest() || Session == null) { return; } IUserContext user = GetCurrentUser(); string masterName; if (Request.QueryString["mode"] != null) { if (Request.QueryString["mode"].ToLower() == "full") { masterName = "Site"; Session["masterpage"] = masterName; } else if (Request.QueryString["mode"].ToLower() == "mini") { masterName = "Rest"; Session["masterpage"] = masterName; } } if (Session["masterpage"] != null && (string)Session["masterpage"] == "Rest") { ViewBag.MiniMode = true; } else { ViewBag.MiniMode = false; } // set language if (Request.QueryString["lang"] != null) { ILocale locale; locale = CoreData.LocaleManager.GetUsedLocales(GetCurrentUser()).Get(Request.QueryString["lang"]); if (locale.IsNotNull()) { SetLanguage(locale.ISOCode); if (user.IsAuthenticated()) { user.Locale = locale; } } } // Removed from code 2012-02-28 (agoh) only set revision from Revision Controller - start editing // set revisionId //string strRevisionId = (filterContext.RouteData.Values["revisionId"] ?? // filterContext.RequestContext.HttpContext.Request.QueryString["revisionId"] ?? // filterContext.RequestContext.HttpContext.Request.Form["revisionId"]) as string; //int revisionId; //if (int.TryParse(strRevisionId, out revisionId)) //{ // Session["RevisionId"] = revisionId; //} // Set LogOn information ViewBag.IsLoggedIn = user.IsAuthenticated(); ViewBag.UserName = user.User.UserName; // Set Taxon and Revision information ViewBag.TaxonId = this.TaxonIdentifier.Id; ViewBag.RevisionId = this.RevisionId; ViewBag.RootTaxonId = this.RootTaxonId; if (this.RevisionId.HasValue && user.CurrentRole == null) { user.SetCurrentUserRoleToTaxonRevisionEditor(this.RevisionId.Value); } #if DEBUG ViewBag.Debug = true; #else ViewBag.Debug = false; #endif ActionDescriptor actionDescriptor = filterContext.ActionDescriptor; string actionName = actionDescriptor.ActionName; string controllerName = actionDescriptor.ControllerDescriptor.ControllerName; ViewBag.CookieName = string.Format("{0}{1}", controllerName, actionName); // Log history event if (actionName != "TaxonQualitySummaryChart") { var logEventHistoryItem = new LogEventHistoryItem(); logEventHistoryItem.Action = actionName; logEventHistoryItem.Controller = controllerName; logEventHistoryItem.TaxonId = this.TaxonIdentifier.Id; logEventHistoryItem.RevisionId = this.RevisionId; logEventHistoryItem.Form = Request.Form != null?Request.Form.PrettyPrint() : "-"; logEventHistoryItem.HttpAction = Request.HttpMethod; logEventHistoryItem.Url = DyntaxaLogger.GetUrl(); logEventHistoryItem.Date = DateTime.Now; logEventHistoryItem.UserName = user.User != null ? user.User.UserName : "******"; logEventHistoryItem.UserRole = user.CurrentRole != null ? user.CurrentRole.Identifier : "-"; logEventHistoryItem.Referrer = Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : "-"; var logEventHistory = Session["LogEventHistory"] as LogEventHistory; if (logEventHistory == null) { logEventHistory = new LogEventHistory(); Session["LogEventHistory"] = logEventHistory; } logEventHistory.HistoryItems.Add(logEventHistoryItem); if (logEventHistory.HistoryItems.Count > 10) { logEventHistory.HistoryItems.RemoveAt(0); } } base.OnActionExecuting(filterContext); }