Files
LeafWeb/Web/Controllers/ControllerBase.cs
T
poprhythm 10cd2986cf Organize Piscal Service items
Add nlog, PiscalQueueManager

	modified:   Core.Tests/Remote/PiscalSshClientTests.cs
	modified:   Core/DAL/DataService.cs
	modified:   Core/Remote/IPiscalClient.cs
	modified:   Core/Remote/PiscalSshClient.cs
	new file:   Web/Attributes/ActionLogAttribute.cs
	modified:   Web/Controllers/ControllerBase.cs
	modified:   Web/Controllers/LeafInputController.cs
	modified:   Web/Controllers/LeafOutputController.cs
	new file:   Web/NLog.config
	new file:   Web/NLog.xsd
	new file:   Web/Services/PiscalQueueManager.cs
	modified:   Web/Services/PiscalService.cs
	modified:   Web/Startup.cs
	modified:   Web/Web.csproj
	modified:   Web/packages.config

Ignore logs

Organize piscal queue manager

	modified:   Core/Entities/LeafInputFile.cs
	modified:   Web/Controllers/LeafInputController.cs
	renamed:    Web/Startup.cs -> Web/HangfireStartup.cs
	modified:   Web/Services/PiscalQueueManager.cs
	modified:   Web/Web.csproj

cleanup usings in leafinputcontroller
2016-03-01 07:35:58 -05:00

70 lines
1.7 KiB
C#

using System;
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Core.DAL;
using NLog;
namespace LeafWeb.Web.Controllers
{
//[UserActivity]
public class ControllerBase : Controller
{
protected readonly DataService DataService = new DataService();
protected override void Dispose(bool disposing)
{
DataService.Dispose();
base.Dispose(disposing);
}
protected override void OnException(ExceptionContext filterContext)
{
if (filterContext?.Exception != null)
{
var controller = filterContext.RouteData.Values["controller"].ToString();
var action = filterContext.RouteData.Values["action"].ToString();
var loggerName = $"{controller}Controller.{action}";
LogManager.GetLogger(loggerName).Error(filterContext.Exception);
}
base.OnException(filterContext);
}
protected bool IsHttpParamActionMatch()
{
return ControllerContext.RouteData.Values["action"].ToString()
.Equals("Action", StringComparison.InvariantCultureIgnoreCase);
}
protected enum StatusType
{
Info,
Success,
Error
}
protected void SetStatusMessage(string msg, StatusType statusType = StatusType.Info)
{
TempData["StatusMessage"] = msg;
switch (statusType)
{
case StatusType.Success:
TempData["StatusMessage-Type"] = "alert-success";
break;
case StatusType.Error:
TempData["StatusMessage-Type"] = "alert-error";
break;
case StatusType.Info:
break;
default:
throw new ArgumentOutOfRangeException(nameof(statusType), statusType, null);
}
}
protected SelectList GetPhotosynthesisTypeSelectList()
{
return new SelectList(DataService.GetPhotosynthesisTypes().ToList(), "Id", "Name");
}
}
}