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
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using LeafWeb.Core.DAL;
|
||||
using NLog;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
@@ -18,6 +17,20 @@ namespace LeafWeb.Web.Controllers
|
||||
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()
|
||||
@@ -42,6 +55,10 @@ namespace LeafWeb.Web.Controllers
|
||||
case StatusType.Error:
|
||||
TempData["StatusMessage-Type"] = "alert-error";
|
||||
break;
|
||||
case StatusType.Info:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(statusType), statusType, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Hangfire;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Remote;
|
||||
using LeafWeb.Web.Attributes;
|
||||
using LeafWeb.Web.ViewModels;
|
||||
using LeafWeb.Web.ViewModels.LeafInput;
|
||||
using NLog;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
@@ -57,6 +55,7 @@ namespace LeafWeb.Web.Controllers
|
||||
|
||||
[HttpParamAction]
|
||||
[HttpPost]
|
||||
[ActionLog]
|
||||
public ActionResult Confirm(CreateViewModel viewModel)
|
||||
{
|
||||
// directory name is the sessionID
|
||||
@@ -82,17 +81,15 @@ namespace LeafWeb.Web.Controllers
|
||||
|
||||
DeleteBackloadDirectory(Session.SessionID);
|
||||
|
||||
foreach (var file in leafInput.Files.Select(f => new PiscalLeafInputFile(f)))
|
||||
{
|
||||
BackgroundJob.Enqueue(() => ProcessLeafInput(file));
|
||||
}
|
||||
|
||||
var msg = $"A data set has submitted for '{viewModel.Identifier}' from '{viewModel.SiteId}'. " + Environment.NewLine
|
||||
+ $"When complete, an email will be delivered to {viewModel.Name} <{viewModel.Email}> with results.";
|
||||
|
||||
SetStatusMessage(HttpUtility.HtmlEncode(msg),StatusType.Success);
|
||||
|
||||
LogManager.GetCurrentClassLogger().Info(msg);
|
||||
|
||||
HangfireStartup.TriggerPiscalProcessQueue();
|
||||
|
||||
SetStatusMessage(
|
||||
HttpUtility.HtmlEncode(
|
||||
$"A data set has submitted for '{viewModel.Identifier}' from '{viewModel.SiteId}'. " + Environment.NewLine
|
||||
+ $"When complete, an email will be delivered to {viewModel.Name} <{viewModel.Email}> with results."),
|
||||
StatusType.Success);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
@@ -100,12 +97,6 @@ namespace LeafWeb.Web.Controllers
|
||||
return View("Index", viewModel);
|
||||
}
|
||||
|
||||
public void ProcessLeafInput(PiscalLeafInputFile leafInputFile)
|
||||
{
|
||||
var piscalSshClient = new PiscalSshClient(ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString);
|
||||
piscalSshClient.SubmitLeafInputFile(leafInputFile);
|
||||
}
|
||||
|
||||
private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
|
||||
{
|
||||
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
public class LeafOutputController : ControllerBase
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
var viewModel = DataService.GetLeafOutputFiles();
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user