-
-
Save anonymous/514f2676c8c8af572b2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
using AzureLogViewer.Models.Storage; | |
using AzureLogViewer.Tools; | |
using AzureLogViewer.ViewModel; | |
using AzureLogViewer.ViewModel.Log; | |
using AzureLogViewer.Views.Log; | |
namespace AzureLogViewer.Controllers | |
{ | |
/// <summary> | |
/// Log display controller. | |
/// </summary> | |
public class LogController : AbstractController | |
{ | |
/// <summary> | |
/// Shows log entries. | |
/// </summary> | |
public ActionResult ShowLog(string logName, Period period) | |
{ | |
var logRepository = Config.Instance.LogEntryRepositoryFactory.CreateRepository(Config.Instance.AzureConnectionStrings[logName].ConnectionString); | |
var logEntries = logRepository.GetForTimeDiapasone(DateTime.Now.Subtract(period), DateTime.Now) | |
.Take(Config.Instance.MaxLogEntries) | |
.ToList(); | |
ShowLogViewModel model = new ShowLogViewModel | |
{ | |
AvailableLogNames = Config.Instance.AzureConnectionStrings.Keys, | |
CurrentLogName = logName, | |
CurrentPeriod = period, | |
LogEntries = logEntries, | |
HasRemainingLogEntries = logEntries.Count >= Config.Instance.MaxLogEntries, | |
}; | |
return View<ShowLogView, ShowLogViewModel>(model); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment