Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2012 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/514f2676c8c8af572b2c to your computer and use it in GitHub Desktop.
Save anonymous/514f2676c8c8af572b2c to your computer and use it in GitHub Desktop.
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