Email notification for LeafWeb jobs
This commit is contained in:
@@ -69,6 +69,11 @@ namespace LeafWeb.Core.DAL
|
||||
return _db.LeafInputFiles;
|
||||
}
|
||||
|
||||
public LeafInputFile GetLeafInputFile(int id)
|
||||
{
|
||||
return _db.LeafInputFiles.Find(id);
|
||||
}
|
||||
|
||||
public IQueryable<LeafInputFile> GetLeafInputFiles(LeafInputStatusType status)
|
||||
{
|
||||
return
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Remote
|
||||
{
|
||||
@@ -11,6 +12,7 @@ namespace LeafWeb.Core.Remote
|
||||
public string Filename { get; set; }
|
||||
public byte[] Contents { get; set; }
|
||||
public string DirectoryName { get; set; }
|
||||
public string PhotosyntheticType { get; set; }
|
||||
|
||||
static PiscalLeafInputFile()
|
||||
{
|
||||
@@ -18,9 +20,14 @@ namespace LeafWeb.Core.Remote
|
||||
new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<LeafInputFile, PiscalLeafInputFile>()
|
||||
.ForMember(dest => dest.DirectoryName, opt => opt.MapFrom(
|
||||
src => PiscalUtility.GetPiscalDirectoryName(src)))
|
||||
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id));
|
||||
.ForMember(dest => dest.DirectoryName,
|
||||
opt => opt.MapFrom(src => PiscalUtility.GetPiscalDirectoryName(src)))
|
||||
.ForMember(dest => dest.Filename, opt =>
|
||||
opt.MapFrom(src => src.Filename.WhitespaceToUnderscore().FilterValidFilename()))
|
||||
.ForMember(dest => dest.LeafInputId, opt => opt.MapFrom(src => src.Id))
|
||||
.ForMember(
|
||||
dest => dest.PhotosyntheticType,
|
||||
opt => opt.MapFrom(src => src.LeafInput.PhotosynthesisType.Id.WhitespaceToUnderscore()));
|
||||
});
|
||||
Mapper = config.CreateMapper();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace LeafWeb.Core.Remote
|
||||
using (var ssh = GetSshClient())
|
||||
{
|
||||
ssh.Connect();
|
||||
var commandText = $"{RemoteScriptPath} -d {file.DirectoryName} -f {file.Filename}";
|
||||
var commandText = $"{RemoteScriptPath} -d {file.DirectoryName} -f {file.Filename} -p {file.PhotosyntheticType}";
|
||||
var command = ssh.CreateCommand(commandText);
|
||||
command.Execute();
|
||||
ssh.Disconnect();
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace LeafWeb.Core.Utility
|
||||
return char.ToLowerInvariant(s[0]) + s.Substring(1);
|
||||
}
|
||||
|
||||
public static string WhitespaceToUnderscore(this string str)
|
||||
{
|
||||
return Regex.Replace(str, @"\s+", "_");
|
||||
}
|
||||
|
||||
public static byte[] GetBytes(this string str)
|
||||
{
|
||||
return System.Text.Encoding.Default.GetBytes(str);
|
||||
@@ -47,6 +52,11 @@ namespace LeafWeb.Core.Utility
|
||||
return Regex.Replace(input, @"[^\w_]", "");
|
||||
}
|
||||
|
||||
public static string FilterValidFilename(this string input)
|
||||
{
|
||||
return Regex.Replace(input, @"[^\w_\-\.]", "");
|
||||
}
|
||||
|
||||
public static string FilenameFromPath(this string path)
|
||||
{
|
||||
return Regex.Replace(path, @".*/([^/]*$)", "$1");
|
||||
|
||||
Reference in New Issue
Block a user