Пример #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
        public ActionResult Index(IssueCriteriaPostModel postModel)
        {
            var viewModel    = new IssueCriteriaViewModel();
            var applications = Core.GetApplications();

            if (applications.PagingStatus.TotalItems > 0)
            {
                var pagingRequest = GetSinglePagingRequest();

                if (postModel.Status == null || postModel.Status.Length == 0)
                {
                    postModel.Status = Enum.GetNames(typeof(IssueStatus)).ToArray();
                }
                else if (postModel.Status.Length == 1 && postModel.Status[0].Contains(","))
                {
                    //this is a fix up for when the url gets changed to contain the statuses in a single query parameter
                    postModel.Status = postModel.Status[0].Split(',');
                }

                var request = new GetApplicationIssuesRequest
                {
                    ApplicationId  = CurrentApplication.IfPoss(a => a.Id),
                    Paging         = pagingRequest,
                    AssignedTo     = postModel.AssignedTo,
                    Status         = postModel.Status,
                    Query          = postModel.Name,
                    OrganisationId = Core.AppContext.CurrentUser.OrganisationId,
                };

                var issues = _getApplicationIssuesQuery.Invoke(request).Issues;
                var users  = Core.GetUsers();

                viewModel.AssignedTo     = postModel.AssignedTo;
                viewModel.Status         = postModel.Status;
                viewModel.Name           = postModel.Name;
                viewModel.Paging         = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, issues.PagingStatus, pagingRequest);
                viewModel.Users          = users.Items.ToSelectList(u => u.FriendlyId, u => u.FullName, u => u.FriendlyId == postModel.AssignedTo);
                viewModel.Statuses       = Enum.GetNames(typeof(IssueStatus)).ToSelectList(s => s, s => s, s => s.IsIn(postModel.Status));
                viewModel.Issues         = IssueItemViewModel.Convert(issues.Items, applications.Items, users.Items);
                viewModel.NoApplications = applications.PagingStatus.TotalItems == 0;
            }
            else
            {
                ErrorNotification(Resources.Application.No_Applications);
                return(Redirect(Url.AddApplication()));
            }

            return(View(viewModel));
        }