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)); }
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)); }
public ActionResult Index() { var pagingRequest = GetSinglePagingRequest(); var applications = Core.GetApplications(pagingRequest); if (applications.Items == null || applications.Items.Count == 0) { ErrorNotification(Resources.Application.No_Applications); return(Redirect(Url.AddApplication())); } var applicationsViewModel = new ApplicationsViewModel { Applications = applications.Items.Select(Mapper.Map <Application, ApplicationViewModel>).ToList(), Paging = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, applications.PagingStatus, pagingRequest) }; var users = Core.GetUsers(); foreach (var application in applicationsViewModel.Applications) { var user = users.Items.FirstOrDefault(u => u.Id == application.DefaultUserId); //if the default user has been deleted, update it here to the current user if (user == null) { var app = Core.Session.Raven.Load <Application>(Application.GetId(application.Id)); app.DefaultUserId = Core.AppContext.CurrentUser.Id; user = Core.AppContext.CurrentUser; } application.RuleMatchFactory = _matchRuleFactoryFactory.Create(application.RuleMatchFactory).Name; application.DefaultUser = "******".FormatWith(user.FirstName, user.LastName); } return(View(applicationsViewModel)); }
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)); }