Exemplo n.º 1
0
        public ActionResult Exceptions(string log, ExceptionSorts? sort = null, int? count = null)
        {
            // Defaults
            count = count ?? 250;
            sort = sort ?? ExceptionSorts.TimeDesc;

            var vd = GetExceptionsModel(log, sort.Value, count.Value, loadAsync: 500);
            return View(vd);
        }
Exemplo n.º 2
0
        public ExceptionsModel GetExceptionsModel(string log, ExceptionSorts sort, int? count = null, Guid? prevLast = null, int? loadAsync = null)
        {
            var errors = ExceptionStores.GetAllErrors(log, sort: sort);

            var startIndex = 0;
            if (prevLast.HasValue)
            {
                startIndex = errors.FindIndex(e => e.GUID == prevLast.Value);
                if (startIndex > 0 && startIndex < errors.Count) startIndex++;
            }
            errors = errors.Skip(startIndex).Take(count ?? 500).ToList();
            var vd = new ExceptionsModel
            {
                Sort = sort,
                SelectedLog = log,
                LoadAsyncSize = loadAsync.GetValueOrDefault(),
                Applications = ExceptionStores.Applications,
                Errors = errors.ToList()
            };
            return vd;
        }
Exemplo n.º 3
0
        public ActionResult ExceptionsSimilar(string log, Guid id, ExceptionSorts? sort = null, bool truncate = true, bool byTime = false)
        {
            // Defaults
            sort = sort ?? ExceptionSorts.TimeDesc;
            log = GetLogName(log);
            var e = ExceptionStores.GetError(log, id);
            if (e == null)
                return View("Exceptions.Detail", null);

            var errors = ExceptionStores.GetSimilarErrors(e, byTime, sort: sort.Value);
            var vd = new ExceptionsModel
            {
                Sort = sort.Value,
                Exception = e,
                SelectedLog = log,
                ShowingWindow = byTime,
                Applications = ExceptionStores.Applications,
                ClearLinkForVisibleOnly = true,
                Errors = errors
            };
            return View("Exceptions.Similar", vd);
        }
Exemplo n.º 4
0
        public async Task <ExceptionsModel> GetExceptionsModel(string group, string log, ExceptionSorts sort, int?count = null, Guid?prevLast = null, int?loadAsync = null)
        {
            FixNames(ref group, ref log);

            var errors = await GetAllErrors(group, log, sort : sort).ConfigureAwait(false);

            var startIndex = 0;

            if (prevLast.HasValue)
            {
                startIndex = errors.FindIndex(e => e.GUID == prevLast.Value);
                if (startIndex > 0 && startIndex < errors.Count)
                {
                    startIndex++;
                }
            }
            errors = errors.Skip(startIndex).Take(count ?? 500).ToList();
            var vd = new ExceptionsModel
            {
                Sort          = sort,
                SelectedGroup = group,
                SelectedLog   = log,
                LoadAsyncSize = loadAsync.GetValueOrDefault(),
                Groups        = ApplicationGroups,
                Errors        = errors.ToList()
            };

            return(vd);
        }
Exemplo n.º 5
0
        public async Task <ActionResult> LoadMore(string group, string log, ExceptionSorts sort, int?count = null, Guid?prevLast = null)
        {
            var vd = await GetExceptionsModel(group, log, sort, count, prevLast).ConfigureAwait(false);

            return(View("Exceptions.Table.Rows", vd));
        }
Exemplo n.º 6
0
        public static List <Error> FindErrors(string searchText, string appName = null, int max = 200, bool includeDeleted = false, ExceptionSorts sort = ExceptionSorts.TimeDesc)
        {
            if (searchText.IsNullOrEmpty())
            {
                return(new List <Error>());
            }
            var stores  = appName.HasValue() ? GetStores(appName) : Stores;
            var results = stores.SelectMany(s => s.FindErrors(searchText, appName, max, includeDeleted));

            return(GetSorted(results, sort).ToList());
        }
Exemplo n.º 7
0
        public static List <Error> GetSimilarErrors(Error error, bool byTime = false, int max = 200, ExceptionSorts sort = ExceptionSorts.TimeDesc)
        {
            if (error == null)
            {
                return(new List <Error>());
            }
            var similarErrors = GetStores(error.ApplicationName).SelectMany(s => byTime ? s.GetSimilarErrorsInTime(error, max) : s.GetSimilarErrors(error, max));

            return(GetSorted(similarErrors, sort).ToList());
        }
Exemplo n.º 8
0
 public static List <Error> GetAllErrors(string appName = null, int maxPerApp = 5000, ExceptionSorts sort = ExceptionSorts.TimeDesc)
 {
     using (MiniProfiler.Current.Step("GetAllErrors() - All Stores" + (appName.HasValue() ? " (app:" + appName + ")" : "")))
     {
         var allErrors = Stores.SelectMany(s => s.GetErrorSummary(maxPerApp, appName));
         return(GetSorted(allErrors, sort).ToList());
     }
 }
Exemplo n.º 9
0
 public ActionResult ExceptionsLoadMore(string log, ExceptionSorts sort, int? count = null, Guid? prevLast = null)
 {
     var vd = GetExceptionsModel(log, sort, count, prevLast);
     return View("Exceptions.Table.Rows", vd);
 }
Exemplo n.º 10
0
        public ActionResult ExceptionsSearch(string q, string log, ExceptionSorts? sort = null, bool showDeleted = false)
        {
            // Defaults
            sort = sort ?? ExceptionSorts.TimeDesc;
            log = GetLogName(log);

            // empty searches go back to the main log
            if (q.IsNullOrEmpty())
                return RedirectToAction("Exceptions", new { log });

            var errors = ExceptionStores.FindErrors(q, log, includeDeleted: showDeleted, max: 2000, sort: sort.Value);
            if (!errors.Any() && !showDeleted)
            {
                // If we didn't find any current errors, go ahead and search deleted as well
                return RedirectToAction("ExceptionsSearch", new { q, log, showDeleted = true });
            }

            var vd = new ExceptionsModel
            {
                Sort = sort.Value,
                Search = q,
                SelectedLog = log,
                ShowDeleted = showDeleted,
                Applications = ExceptionStores.Applications,
                ClearLinkForVisibleOnly = true,
                Errors = errors
            };
            return View("Exceptions.Search", vd);
        }
Exemplo n.º 11
0
        public ActionResult ExceptionsLoadMore(string log, ExceptionSorts sort, int?count = null, Guid?prevLast = null)
        {
            var vd = GetExceptionsModel(log, sort, count, prevLast);

            return(View("Exceptions.Table.Rows", vd));
        }
Exemplo n.º 12
0
        public static async Task <List <Error> > FindErrorsAsync(string searchText, string group = null, string app = null, int max = 200, bool includeDeleted = false, ExceptionSorts sort = ExceptionSorts.TimeDesc)
        {
            if (searchText.IsNullOrEmpty())
            {
                return(new List <Error>());
            }
            var stores       = app.HasValue() ? GetStores(app) : Stores; // Apps are across stores, group doesn't matter here
            var errorFetches = stores.Select(s => s.FindErrorsAsync(searchText, max, includeDeleted, GetAppNames(group, app)));
            var results      = (await Task.WhenAll(errorFetches).ConfigureAwait(false)).SelectMany(e => e);

            return(GetSorted(results, sort).ToList());
        }
Exemplo n.º 13
0
        public static async Task <List <Error> > GetSimilarErrorsAsync(Error error, bool byTime = false, int max = 200, ExceptionSorts sort = ExceptionSorts.TimeDesc)
        {
            if (error == null)
            {
                return(new List <Error>());
            }
            var errorFetches  = GetStores(error.ApplicationName).Select(s => byTime ? s.GetSimilarErrorsInTimeAsync(error, max) : s.GetSimilarErrorsAsync(error, max));
            var similarErrors = (await Task.WhenAll(errorFetches).ConfigureAwait(false)).SelectMany(e => e);

            return(GetSorted(similarErrors, sort).ToList());
        }
Exemplo n.º 14
0
        public static async Task <List <Error> > GetAllErrors(string group = null, string app = null, int?maxPerApp = null, ExceptionSorts sort = ExceptionSorts.TimeDesc)
        {
            using (MiniProfiler.Current.Step("GetAllErrors() - All Stores" + (group.HasValue() ? " (group:" + group + ")" : "") + (app.HasValue() ? " (app:" + app + ")" : "")))
            {
                maxPerApp = maxPerApp ?? Current.Settings.Exceptions.PerAppCacheCount;
                var stores = ExceptionsModule.Stores;
                IEnumerable <Error> allErrors;
                if (stores.Count == 1)
                {
                    allErrors = await stores[0].GetErrorSummary(maxPerApp.Value, group, app).ConfigureAwait(false);
                }
                else
                {
                    var tasks       = stores.Select(s => s.GetErrorSummary(maxPerApp.Value, group, app));
                    var taskResults = await Task.WhenAll(tasks).ConfigureAwait(false);

                    var combined = new List <Error>();
                    foreach (var r in taskResults)
                    {
                        combined.AddRange(r);
                    }
                    allErrors = combined;
                }
                return(GetSorted(allErrors, sort).ToList());
            }
        }