Code rearrange for services and charting
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Remote;
|
||||
|
||||
namespace LeafWeb.Web.Services.PiscalQueue
|
||||
{
|
||||
/// <summary>
|
||||
/// Thin layer over PiscalClient to translate Core entities to Piscal objects
|
||||
/// </summary>
|
||||
public class PiscalService
|
||||
{
|
||||
private readonly IPiscalClient _piscalClient;
|
||||
|
||||
public PiscalService(IPiscalClient piscalClient)
|
||||
{
|
||||
_piscalClient = piscalClient;
|
||||
}
|
||||
|
||||
public PiscalService() : this(new PiscalSshClient(ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString))
|
||||
{
|
||||
}
|
||||
|
||||
public void Run(LeafInput leafInput)
|
||||
{
|
||||
var inputFile = new PiscalLeafInput(leafInput);
|
||||
_piscalClient.RunLeafInput(inputFile);
|
||||
}
|
||||
|
||||
public PiscalStatus GetStatus(LeafInput leafInput)
|
||||
{
|
||||
var inputFile = new PiscalLeafInput(leafInput);
|
||||
return _piscalClient.GetLeafInputStatus(inputFile);
|
||||
}
|
||||
|
||||
public IEnumerable<LeafOutputFile> RetrieveOutputFiles(LeafInput leafInput)
|
||||
{
|
||||
var input = new PiscalLeafInput(leafInput);
|
||||
var piscalLeafOutputFiles = _piscalClient.RetrieveLeafOutput(input);
|
||||
foreach (var file in piscalLeafOutputFiles)
|
||||
{
|
||||
var leafOutputFile = file.GetLeafOutputFile();
|
||||
leafOutputFile.LeafInput = leafInput;
|
||||
yield return leafOutputFile;
|
||||
}
|
||||
}
|
||||
|
||||
public void Cleanup(LeafInput leafInput)
|
||||
{
|
||||
var input = new PiscalLeafInput(leafInput);
|
||||
_piscalClient.CleanupLeafProcess(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user