Пример #1
0
        public ActionResult Index(ErrorCriteriaPostModel postModel)
        {
            var viewModel = new ErrorPageViewModel
            {
                ErrorsViewModel = new ErrorCriteriaViewModel
                {
                    Action     = "index",
                    Controller = "errors"
                }
            };

            var applications  = Core.GetApplications();
            var pagingRequest = GetSinglePagingRequest();

            if (applications.PagingStatus.TotalItems > 0)
            {
                var request = new GetApplicationErrorsRequest
                {
                    ApplicationId  = CurrentApplication.IfPoss(a => a.Id),
                    Paging         = pagingRequest,
                    Query          = postModel.Query,
                    OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                };

                if (postModel.DateRange.IsNotNullOrEmpty())
                {
                    string[] dates = postModel.DateRange.Split('|');

                    DateTime startDate;
                    DateTime endDate;

                    if (DateTime.TryParse(dates[0], out startDate) && DateTime.TryParse(dates[1], out endDate))
                    {
                        request.StartDate = startDate;
                        request.EndDate   = endDate;
                        viewModel.ErrorsViewModel.DateRange = "{0} - {1}".FormatWith(startDate.ToString("MMMM d, yyyy"), endDate.ToString("MMMM d, yyyy"));
                    }
                }

                var errors = _getApplicationErrorsQuery.Invoke(request);

                viewModel.ErrorsViewModel.Paging = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, errors.Errors.PagingStatus, pagingRequest);
                viewModel.ErrorsViewModel.Errors = errors.Errors.Items.Select(e => new ErrorInstanceViewModel
                {
                    Error = e,
                    //IsGetMethod = e.ContextData.ContainsKey("Request.HttpMethod") && e.ContextData["Request.HttpMethod"].ToLowerInvariant() == "get"
                }).ToList();
            }
            else
            {
                ErrorNotification(Resources.Application.No_Applications);
                return(Redirect(Url.AddApplication()));
            }

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult Index(string q)
        {
            var viewModel = new SearchViewModel
            {
                Query = q
            };

            var applications = Core.GetApplications();

            if (applications.PagingStatus.TotalItems > 0)
            {
                int searchedIssueId;
                if (int.TryParse(q, out searchedIssueId))
                {
                    var issue = _session.Raven.Load <Issue>(searchedIssueId);
                    if (issue != null)
                    {
                        return(Redirect(Url.Issue(searchedIssueId.ToString())));
                    }
                }

                var issues = _getApplicationIssuesQuery.Invoke(new GetApplicationIssuesRequest
                {
                    Paging = new PageRequestWithSort(1, 10)
                    {
                        Sort = nameof(Errordite.Core.Domain.Error.Error.TimestampUtc), SortDescending = true
                    },
                    OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                    Query          = q,
                    ApplicationId  = CurrentApplication.IfPoss(a => a.Id),
                }).Issues;

                var errors = _getApplicationErrorsQuery.Invoke(new GetApplicationErrorsRequest
                {
                    Paging = new PageRequestWithSort(1, 10)
                    {
                        Sort = nameof(Errordite.Core.Domain.Error.Error.TimestampUtc), SortDescending = true
                    },
                    OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                    Query          = q,
                    ApplicationId  = CurrentApplication.IfPoss(a => a.Id),
                }).Errors;

                viewModel.IssueTotal = issues.PagingStatus.TotalItems;
                viewModel.ErrorTotal = errors.PagingStatus.TotalItems;
                viewModel.Issues     = IssueItemViewModel.ConvertSimple(issues.Items, Core.GetUsers().Items, Core.AppContext.CurrentUser.ActiveOrganisation.TimezoneId, true);
                viewModel.Errors     = errors.Items.Select(e => new ErrorInstanceViewModel
                {
                    Error           = e,
                    ApplicationName = GetApplicationName(applications.Items, e.ApplicationId)
                }).ToList();
            }

            return(View(viewModel));
        }
Пример #3
0
        private ErrorCriteriaViewModel GetErrorsViewModel(ErrorCriteriaPostModel postModel, PageRequestWithSort paging, List <string> extraDataKeys)
        {
            var request = new GetApplicationErrorsRequest
            {
                OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                IssueId        = postModel.Id,
                Paging         = paging,
            };

            if (postModel.DateRange.IsNotNullOrEmpty())
            {
                string[] dates = postModel.DateRange.Split('|');

                DateTime startDate;
                DateTime endDate;

                if (DateTime.TryParse(dates[0], out startDate) && DateTime.TryParse(dates[1], out endDate))
                {
                    request.StartDate = startDate;
                    request.EndDate   = endDate.AddDays(1).AddMinutes(-1);
                }
            }

            var errors = _getApplicationErrorsQuery.Invoke(request).Errors;

            var model = new ErrorCriteriaViewModel
            {
                Action     = "errors",
                Controller = "issue",
                DateRange  = postModel.DateRange,
                Paging     = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, errors.PagingStatus, paging),
                Errors     = errors.Items.Select(e => new ErrorInstanceViewModel
                {
                    Error      = e,
                    HideIssues = true,
                    PropertiesEligibleForRules = extraDataKeys,
                    //IsGetMethod = e.ContextData.ContainsKey("Request.HttpMethod") && e.ContextData["Request.HttpMethod"].ToLowerInvariant() == "get"
                }).ToList(),
                HideIssues     = true,
                Id             = postModel.Id,
                Sort           = paging.Sort,
                SortDescending = paging.SortDescending,
            };

            model.Paging.Tab = IssueTab.Details.ToString();
            return(model);
        }
        public GetErrorsThatDoNotMatchNewRulesResponse Invoke(GetErrorsThatDoNotMatchNewRulesRequest request)
        {
            Trace("Starting...");

            var matches    = new List <Error>();
            var nonMatches = new List <Error>();

            var errors = _getApplicationErrorsQuery.Invoke(new GetApplicationErrorsRequest
            {
                ApplicationId  = request.IssueWithModifiedRules.ApplicationId,
                OrganisationId = request.IssueWithModifiedRules.OrganisationId,
                Paging         = new PageRequestWithSort(1, int.MaxValue),
                IssueId        = request.IssueWithModifiedRules.Id
            }).Errors;

            //find any errors which do not match the new rules and move them to our new temporary issue
            foreach (var error in errors.Items)
            {
                if (request.IssueWithModifiedRules.Rules.All(rule => rule.IsMatch(error)))
                {
                    matches.Add(error);
                }
                else
                {
                    nonMatches.Add(error);
                }
            }

            Trace("...Complete");

            return(new GetErrorsThatDoNotMatchNewRulesResponse
            {
                Status = AdjustRulesStatus.Ok,
                NonMatches = nonMatches,
                Matches = matches,
            });
        }
Пример #5
0
        public ActionResult Index()
        {
            var curentApplication = CurrentApplication;
            var applicationId     = curentApplication == null ? null : curentApplication.Id;
            var viewModel         = new DashboardViewModel();
            var applications      = Core.GetApplications();
            var preferences       = CookieManager.Get(WebConstants.CookieSettings.DashboardCookieKey);
            var pref = preferences.IsNullOrEmpty() || !preferences.Contains("|") ? null : preferences.Split('|');

            viewModel.ShowMe   = pref == null ? "1" : pref[0];
            viewModel.PageSize = pref == null ? 10 : int.Parse(pref[1]);

            if (applications.PagingStatus.TotalItems > 0)
            {
                viewModel.HasApplications = true;

                if (applications.Items.Count == 1)
                {
                    viewModel.SingleApplicationId    = applications.Items[0].Id;
                    viewModel.SingleApplicationToken = applications.Items[0].Token;
                }

                var showMe = DashboardViewModel.Sorting.FirstOrDefault(s => s.Id == viewModel.ShowMe) ?? new DashboardSort("1", "", true, "LastErrorUtc");

                if (showMe.Id == "5")
                {
                    var errors = _getApplicationErrorsQuery.Invoke(new GetApplicationErrorsRequest
                    {
                        Paging         = new PageRequestWithSort(1, viewModel.PageSize, "TimestampUtc", true),
                        OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                        ApplicationId  = applicationId
                    }).Errors;

                    viewModel.Errors = errors.Items.Select(e => new ErrorInstanceViewModel
                    {
                        Error           = e,
                        ApplicationName = GetApplicationName(applications.Items, e.ApplicationId),
                    }).ToList();

                    viewModel.ShowIntro = errors.PagingStatus.TotalItems <= 5 && applications.Items.Count == 1;
                }
                else
                {
                    var issues = _getApplicationIssuesQuery.Invoke(new GetApplicationIssuesRequest
                    {
                        Paging         = new PageRequestWithSort(1, viewModel.PageSize, showMe.SortField, showMe.SortDescending),
                        OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                        ApplicationId  = applicationId
                    }).Issues;

                    viewModel.TestIssueId = issues.Items.FirstOrDefault(i => i.TestIssue).IfPoss(i => i.Id);
                    viewModel.Issues      = IssueItemViewModel.ConvertSimple(issues.Items, Core.GetUsers().Items, Core.AppContext.CurrentUser.ActiveOrganisation.TimezoneId, showMe.Id != "2");
                    viewModel.ShowIntro   = issues.PagingStatus.TotalItems <= 3 && applications.Items.Count == 1;
                }

                var selectedApplication = applicationId.IsNotNullOrEmpty()
                    ? applications.Items.FirstOrDefault(a => a.FriendlyId == applicationId.GetFriendlyId())
                    : null;

                viewModel.SelectedApplicationId   = selectedApplication == null ? null : selectedApplication.FriendlyId;
                viewModel.SelectedApplicationName = selectedApplication == null ? null : selectedApplication.Name;
                viewModel.Applications            = applications.Items;
                viewModel.UrlGetter     = GetDashboardUrl;
                viewModel.ShowMeOptions = DashboardViewModel.Sorting.ToSelectList(s => s.Id, s => s.DisplayName, s => s.Id == viewModel.ShowMe);
                viewModel.PageSizes     = new List <SelectListItem>
                {
                    new SelectListItem {
                        Text = "10", Value = "10", Selected = viewModel.PageSize == 10
                    },
                    new SelectListItem {
                        Text = "20", Value = "20", Selected = viewModel.PageSize == 20
                    },
                    new SelectListItem {
                        Text = "30", Value = "30", Selected = viewModel.PageSize == 30
                    }
                };
            }
            else
            {
                ConfirmationNotification("You do not currently have any applications, please create an application to begin using Errordite.");
                return(Redirect(Url.AddApplication(false)));
            }

            return(View(viewModel));
        }
Пример #6
0
        public ResetIssueErrorCountsResponse Invoke(ResetIssueErrorCountsRequest request)
        {
            Trace("Starting...");
            Trace("Syncing issue with Id:={0}...", request.IssueId);

            TraceObject(request);

            var issue = Load <Issue>(Issue.GetId(request.IssueId));

            if (issue == null)
            {
                return(new ResetIssueErrorCountsResponse());
            }

            var currentIssueCount = issue.ErrorCount;

            //re-initialise the issue hourly counts
            var hourlyCount = Session.Raven.Load <IssueHourlyCount>("IssueHourlyCount/{0}".FormatWith(issue.FriendlyId));

            if (hourlyCount == null)
            {
                hourlyCount = new IssueHourlyCount
                {
                    IssueId       = issue.Id,
                    Id            = "IssueHourlyCount/{0}".FormatWith(issue.FriendlyId),
                    ApplicationId = issue.ApplicationId
                };

                Store(hourlyCount);
            }

            hourlyCount.Initialise();

            var errors = _getApplicationErrorsQuery.Invoke(new GetApplicationErrorsRequest
            {
                ApplicationId          = issue.ApplicationId,
                OrganisationId         = issue.OrganisationId,
                IssueId                = issue.Id,
                Paging                 = new PageRequestWithSort(1, int.MaxValue),
                WaitForIndexStaleAtUtc = request.TriggerEventUtc,
            }).Errors;

            var dailyCounts = new Dictionary <DateTime, IssueDailyCount>();

            foreach (var error in errors.Items)
            {
                hourlyCount.IncrementHourlyCount(error.TimestampUtc);

                if (dailyCounts.ContainsKey(error.TimestampUtc.Date))
                {
                    dailyCounts[error.TimestampUtc.Date].Count++;
                }
                else
                {
                    var dailyCount = new IssueDailyCount
                    {
                        Id            = "IssueDailyCount/{0}-{1}".FormatWith(issue.FriendlyId, error.TimestampUtc.ToString("yyyy-MM-dd")),
                        IssueId       = issue.Id,
                        Count         = 1,
                        Date          = error.TimestampUtc.Date,
                        ApplicationId = issue.ApplicationId
                    };

                    dailyCounts.Add(error.TimestampUtc.Date, dailyCount);

                    Trace("Creating IssueDailyCount, Id:={0}", dailyCount.Id);
                }

                if (issue.LastErrorUtc < error.TimestampUtc)
                {
                    issue.LastErrorUtc = error.TimestampUtc;
                }
            }

            //delete any daily issue count docs except the historical one
            new DeleteAllDailyCountsCommitAction(issue.Id, deleteHistorical: false).Execute(Session);

            //make sure the issue index is not stale
            new SynchroniseIndexCommitAction <IssueDailyCounts>().Execute(Session);

            foreach (var dailyCount in dailyCounts)
            {
                Store(dailyCount.Value);
            }

            issue.ErrorCount  = errors.PagingStatus.TotalItems;
            issue.LimitStatus = issue.ErrorCount >= _configuration.IssueErrorLimit ? ErrorLimitStatus.Exceeded : ErrorLimitStatus.Ok;

            //create or update the historical count of errors for this issue
            var historicalCount = Load <IssueDailyCount>("IssueDailyCount/{0}-Historical".FormatWith(issue.FriendlyId));

            if (historicalCount == null)
            {
                historicalCount = new IssueDailyCount
                {
                    IssueId       = issue.Id,
                    ApplicationId = issue.ApplicationId,
                    Count         = currentIssueCount - issue.ErrorCount,
                    Date          = DateTime.MinValue.Date,
                    Historical    = true,
                    Id            = "IssueDailyCount/{0}-Historical".FormatWith(issue.FriendlyId)
                };

                Store(historicalCount);
            }
            else
            {
                historicalCount.Count += (currentIssueCount - issue.ErrorCount);
            }

            return(new ResetIssueErrorCountsResponse());
        }