コード例 #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CurrentStore     = ExceptionsModule.GetStore(Request.Params["store"]);
            CurrentGroup     = Request.Params["group"];
            CurrentLog       = Request.Params["log"] ?? Request.Params["app"]; // old link compat
            CurrentId        = Request.Params["id"].HasValue() && Guid.TryParse(Request.Params["id"], out var guid) ? guid : (Guid?)null;
            CurrentSimilarId = Request.Params["similar"].HasValue() && Guid.TryParse(Request.Params["similar"], out var similarGuid) ? similarGuid : (Guid?)null;
            Enum.TryParse(Request.Params["sort"], out CurrentSort);

            if (CurrentLog.HasValue())
            {
                var storeApps = CurrentStore.Applications.Data;
                var a         = storeApps?.Find(app => app.Name == CurrentLog) ?? storeApps?.Find(app => app.ShortName == CurrentLog);
                if (a != null)
                {
                    // Correct the log name to a found one, this enables short names to work.
                    CurrentLog = a.Name;
                    // Make pre-group links work correctly
                    if (CurrentGroup.IsNullOrEmpty())
                    {
                        // Old links, that didn't know about groups
                        var g = ApplicationGroups.Find(gr => gr[a.Name] != null);
                        if (g != null)
                        {
                            CurrentGroup = g.Name;
                        }
                    }
                }
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            base.OnActionExecuting(filterContext);
        }
コード例 #2
0
        public ExceptionsController(ExceptionsModule module, IOptions <OpserverSettings> settings) : base(module, settings)
        {
            CurrentStore     = Module.GetStore(GetParam("store"));
            CurrentGroup     = GetParam("group");
            CurrentLog       = GetParam("log") ?? GetParam("app"); // old link compat
            CurrentId        = GetParam("id").HasValue() && Guid.TryParse(GetParam("id"), out var guid) ? guid : (Guid?)null;
            CurrentSimilarId = GetParam("similar").HasValue() && Guid.TryParse(GetParam("similar"), out var similarGuid) ? similarGuid : (Guid?)null;
            Enum.TryParse(GetParam("sort"), out CurrentSort);

            if (CurrentLog.HasValue())
            {
                var storeApps = CurrentStore.Applications.Data;
                var a         = storeApps?.Find(app => app.Name == CurrentLog) ?? storeApps?.Find(app => app.ShortName == CurrentLog);
                if (a != null)
                {
                    // Correct the log name to a found one, this enables short names to work.
                    CurrentLog = a.Name;
                    // Make pre-group links work correctly
                    if (CurrentGroup.IsNullOrEmpty())
                    {
                        // Old links, that didn't know about groups
                        var g = ApplicationGroups.Find(gr => gr[a.Name] != null);
                        if (g != null)
                        {
                            CurrentGroup = g.Name;
                        }
                    }
                }
            }
        }
コード例 #3
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            CurrentStore     = Module.GetStore(GetParam("store"));
            CurrentGroup     = GetParam("group");
            CurrentLog       = GetParam("log") ?? GetParam("app"); // old link compat
            CurrentId        = GetParam("id").HasValue() && Guid.TryParse(GetParam("id"), out var guid) ? guid : (Guid?)null;
            CurrentSimilarId = GetParam("similar").HasValue() && Guid.TryParse(GetParam("similar"), out var similarGuid) ? similarGuid : (Guid?)null;
            Enum.TryParse(GetParam("sort"), out CurrentSort);
            CurrentUrl  = GetParam("url")?.Trim();
            CurrentHost = GetParam("host")?.Trim();
            if (GetDate("startDate") is DateTime startDate)
            {
                CurrentStartDate = startDate;
            }
            if (GetDate("endDate") is DateTime endDate)
            {
                CurrentEndDate = endDate;
            }

            if (CurrentLog.HasValue())
            {
                var storeApps = CurrentStore.Applications.Data;
                var a         = storeApps?.Find(app => app.Name == CurrentLog) ?? storeApps?.Find(app => app.ShortName == CurrentLog);
                if (a != null)
                {
                    // Correct the log name to a found one, this enables short names to work.
                    CurrentLog = a.Name;
                    // Make pre-group links work correctly
                    if (CurrentGroup.IsNullOrEmpty())
                    {
                        // Old links, that didn't know about groups
                        var g = ApplicationGroups.Find(gr => gr[a.Name] != null);
                        if (g != null)
                        {
                            CurrentGroup = g.Name;
                        }
                    }
                }
            }
            base.OnActionExecuting(context);
        }