Umbraco update

Error email updates
Piscal communication error handling
Empty page for terms of service
This commit is contained in:
2017-01-04 08:49:36 -05:00
parent 8f5399e746
commit 9e710effc1
15 changed files with 228 additions and 25 deletions
+1
View File
@@ -4,6 +4,7 @@ namespace LeafWeb.Core.Remote
{
public interface IPiscalClient
{
string Host { get; }
void RunLeafInput(PiscalLeafInput leafInput);
PiscalStatus GetLeafInputStatus(PiscalLeafInput leafInput);
IEnumerable<PiscalLeafOutputFile> RetrieveLeafOutput(PiscalLeafInput leafInput);
+44 -12
View File
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IO;
@@ -12,6 +13,7 @@ namespace LeafWeb.Core.Remote
{
private const string BaseDirectory = "./LeafWeb";
private const string RemoteScriptPath = BaseDirectory + "/piscal_manager.sh";
private readonly string _host;
private readonly PasswordConnectionInfo _connectionInfo;
private const string StatusComplete = "complete";
@@ -24,10 +26,10 @@ namespace LeafWeb.Core.Remote
{
var conn = new DbConnectionStringBuilder {ConnectionString = connectionString};
var host = conn["host"] as string;
_host = conn["host"] as string;
var username = conn["username"] as string;
var password = conn["password"] as string;
_connectionInfo = new PasswordConnectionInfo(host, username, password);
_connectionInfo = new PasswordConnectionInfo(_host, username, password);
}
private SshClient GetSshClient()
@@ -40,6 +42,34 @@ namespace LeafWeb.Core.Remote
return new ScpClient(_connectionInfo);
}
private void Connect(PiscalLeafInput leafInput, BaseClient scp)
{
try
{
scp.Connect();
}
catch (Exception ex)
{
var message = $"Exception while connecting to client. Message: {ex.Message}";
_logger.Error(message);
throw new PiscalClientException(leafInput.LeafInputId, message);
}
}
private void Disconnect(PiscalLeafInput leafInput, BaseClient client)
{
try
{
client.Disconnect();
}
catch (Exception ex)
{
var message = $"Exception while disconnecting from client. Message: {ex.Message}";
_logger.Error(message);
throw new PiscalClientException(leafInput.LeafInputId, message);
}
}
private void CopyLeafInput(PiscalLeafInput leafInput, string directory)
{
// copy files
@@ -50,13 +80,15 @@ namespace LeafWeb.Core.Remote
using (var stream = new MemoryStream(file.Contents))
{
_logger.Debug("Copying " + inputPath);
scp.Connect();
Connect(leafInput, scp);
scp.Upload(stream, inputPath);
scp.Disconnect();
Disconnect(leafInput, scp);
}
}
}
public string Host => _host;
public void RunLeafInput(PiscalLeafInput leafInput)
{
if (string.IsNullOrEmpty(leafInput.PhotosyntheticType))
@@ -69,7 +101,7 @@ namespace LeafWeb.Core.Remote
// begin processing
using (var ssh = GetSshClient())
{
ssh.Connect();
Connect(leafInput, ssh);
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName} -p {leafInput.PhotosyntheticType} -s";
if (leafInput.SuppressStorageCopy)
@@ -80,7 +112,7 @@ namespace LeafWeb.Core.Remote
var command = ssh.CreateCommand(commandText);
command.Execute();
ssh.Disconnect();
Disconnect(leafInput, ssh);
if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
@@ -115,11 +147,11 @@ namespace LeafWeb.Core.Remote
{
using (var ssh = GetSshClient())
{
ssh.Connect();
Connect(leafInput, ssh);
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName}";
var command = ssh.CreateCommand(commandText);
command.Execute();
ssh.Disconnect();
Disconnect(leafInput, ssh);
if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
@@ -145,7 +177,7 @@ namespace LeafWeb.Core.Remote
using (var scp = GetScpClient())
{
scp.Connect();
Connect(leafInput, scp);
string outputFileType = string.Empty;
foreach (var filePath in filePaths)
{
@@ -168,7 +200,7 @@ namespace LeafWeb.Core.Remote
}
}
scp.Disconnect();
Disconnect(leafInput, scp);
}
}
@@ -176,11 +208,11 @@ namespace LeafWeb.Core.Remote
{
using (var ssh = GetSshClient())
{
ssh.Connect();
Connect(leafInput, ssh);
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName} -c";
var command = ssh.CreateCommand(commandText);
command.Execute();
ssh.Disconnect();
Disconnect(leafInput, ssh);
if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
+1 -1
View File
@@ -1 +1 @@
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.q2jvbaow.dll
C:\Users\poprhythm\AppData\Local\Temp\Temporary ASP.NET Files\vs\f80e29bb\faae20bf\App_Web_all.generated.cs.8f9494c4.2yhofn7h.dll
+46 -2
View File
@@ -8,7 +8,7 @@ using Umbraco.Web;
using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "c915aa356c033a90")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "c5118162be4a0dc0")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.1")]
@@ -18,7 +18,7 @@ using Umbraco.ModelsBuilder.Umbraco;
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder v3.0.4.0
// Umbraco.ModelsBuilder v3.0.5.96
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
@@ -278,6 +278,50 @@ namespace Umbraco.Web.PublishedContentModels
}
}
/// <summary>Empty Page</summary>
[PublishedContentModel("TextPage1")]
public partial class TextPage1 : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "TextPage1";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109
public TextPage1(IPublishedContent content)
: base(content)
{ }
#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109
public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<TextPage1, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
///<summary>
/// Content
///</summary>
[ImplementPropertyType("content")]
public Newtonsoft.Json.Linq.JToken Content
{
get { return this.GetPropertyValue<Newtonsoft.Json.Linq.JToken>("content"); }
}
///<summary>
/// Hide in Navigation?
///</summary>
[ImplementPropertyType("umbracoNaviHide")]
public bool UmbracoNaviHide
{
get { return this.GetPropertyValue<bool>("umbracoNaviHide"); }
}
}
/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
+47 -3
View File
@@ -2,7 +2,7 @@
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder v3.0.4.0
// Umbraco.ModelsBuilder v3.0.5.96
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
@@ -19,8 +19,8 @@ using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "c915aa356c033a90")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.2")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "c5118162be4a0dc0")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.5")]
namespace Umbraco.Web.PublishedContentModels
{
@@ -262,6 +262,50 @@ namespace Umbraco.Web.PublishedContentModels
}
}
/// <summary>Empty Page</summary>
[PublishedContentModel("TextPage1")]
public partial class TextPage1 : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "TextPage1";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109
public TextPage1(IPublishedContent content)
: base(content)
{ }
#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109
public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<TextPage1, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
///<summary>
/// Content
///</summary>
[ImplementPropertyType("content")]
public Newtonsoft.Json.Linq.JToken Content
{
get { return this.GetPropertyValue<Newtonsoft.Json.Linq.JToken>("content"); }
}
///<summary>
/// Hide in Navigation?
///</summary>
[ImplementPropertyType("umbracoNaviHide")]
public bool UmbracoNaviHide
{
get { return this.GetPropertyValue<bool>("umbracoNaviHide"); }
}
}
/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
+1 -1
View File
@@ -1 +1 @@
c915aa356c033a90
c5118162be4a0dc0
+3
View File
@@ -134,3 +134,6 @@ form .validation-summary-errors ul {
display: block;
border-bottom: 1px solid #000; }
.toggle {
width: 15px; }
+1 -1
View File
@@ -1 +1 @@
h1{padding:24px 0 12px 0;}p{padding:12px 0;}footer{margin-top:24px !important;}.row-no-padding [class*="col-"]{padding-left:0 !important;padding-right:0 !important;}.home .dark .row:first-child .column:first-child h1{padding-top:0;}.home .blogarchive{padding-top:20px;}.banner-link{white-space:normal;padding:20px;background:#000;background:rgba(0,0,0,.5);-moz-border-radius:10px;border-radius:10px;}.banner-link .glyphicon{color:#8cc641;}a.banner-link:hover{text-decoration:none;background:rgba(0,0,0,.6);}a.banner-link:hover .glyphicon{color:#a8ed4e;}.headline-icon h1:after{color:#8cc641;font-family:"Glyphicons Halflings";font-size:.8em;padding-left:10px;}.headline-icon.headline-icon-file h1:after{content:"";}.headline-icon.headline-icon-leaf h1:after{content:"";}.headline-icon.headline-icon-question h1:after{content:"";}.headline-icon.headline-icon-stats h1:after{content:"";}.headline-icon.headline-icon-user h1:after{content:"";}.headline-icon.headline-icon-list h1:after{content:"";}.status:after{font-family:"Glyphicons Halflings";font-size:.8em;padding-left:5px;}.status.status-complete{color:#337ab7;}.status.status-complete:after{content:"";}.status.status-exception{color:#a94442;}.status.status-exception:after{content:"";}.status.status-running,.status.status-pending,.status.status-starting,.status.status-finishing{color:#3c763d;}.status.status-running:after{content:"";}.status.status-pending:after{content:"";}.status.status-starting:after{content:"";}.status.status-finishing:after{content:"";}#chart{padding-top:20px;}.btn-file{position:relative;overflow:hidden;}.btn-file input[type=file]{position:absolute;top:0;right:0;min-width:100%;min-height:100%;font-size:100px;text-align:right;filter:alpha(opacity=0);opacity:0;outline:none;background:#fff;cursor:inherit;display:block;}form .validation-summary-errors ul{list-style-type:none;}.autocomplete-suggestions{border:1px solid #999;background:#fff;overflow:auto;}.autocomplete-suggestion{padding:2px 5px;white-space:nowrap;overflow:hidden;}.autocomplete-selected{background:#f0f0f0;}.autocomplete-suggestions strong{font-weight:normal;color:#39f;}.autocomplete-group{padding:2px 5px;}.autocomplete-group strong{display:block;border-bottom:1px solid #000;}
h1{padding:24px 0 12px 0;}p{padding:12px 0;}footer{margin-top:24px !important;}.row-no-padding [class*="col-"]{padding-left:0 !important;padding-right:0 !important;}.home .dark .row:first-child .column:first-child h1{padding-top:0;}.home .blogarchive{padding-top:20px;}.banner-link{white-space:normal;padding:20px;background:#000;background:rgba(0,0,0,.5);-moz-border-radius:10px;border-radius:10px;}.banner-link .glyphicon{color:#8cc641;}a.banner-link:hover{text-decoration:none;background:rgba(0,0,0,.6);}a.banner-link:hover .glyphicon{color:#a8ed4e;}.headline-icon h1:after{color:#8cc641;font-family:"Glyphicons Halflings";font-size:.8em;padding-left:10px;}.headline-icon.headline-icon-file h1:after{content:"";}.headline-icon.headline-icon-leaf h1:after{content:"";}.headline-icon.headline-icon-question h1:after{content:"";}.headline-icon.headline-icon-stats h1:after{content:"";}.headline-icon.headline-icon-user h1:after{content:"";}.headline-icon.headline-icon-list h1:after{content:"";}.status:after{font-family:"Glyphicons Halflings";font-size:.8em;padding-left:5px;}.status.status-complete{color:#337ab7;}.status.status-complete:after{content:"";}.status.status-exception{color:#a94442;}.status.status-exception:after{content:"";}.status.status-running,.status.status-pending,.status.status-starting,.status.status-finishing{color:#3c763d;}.status.status-running:after{content:"";}.status.status-pending:after{content:"";}.status.status-starting:after{content:"";}.status.status-finishing:after{content:"";}#chart{padding-top:20px;}.btn-file{position:relative;overflow:hidden;}.btn-file input[type=file]{position:absolute;top:0;right:0;min-width:100%;min-height:100%;font-size:100px;text-align:right;filter:alpha(opacity=0);opacity:0;outline:none;background:#fff;cursor:inherit;display:block;}form .validation-summary-errors ul{list-style-type:none;}.autocomplete-suggestions{border:1px solid #999;background:#fff;overflow:auto;}.autocomplete-suggestion{padding:2px 5px;white-space:nowrap;overflow:hidden;}.autocomplete-selected{background:#f0f0f0;}.autocomplete-suggestions strong{font-weight:normal;color:#39f;}.autocomplete-group{padding:2px 5px;}.autocomplete-group strong{display:block;border-bottom:1px solid #000;}.toggle{width:15px;}
+3
View File
@@ -160,3 +160,6 @@ form .validation-summary-errors ul {
&-group strong { display: block; border-bottom: 1px solid #000; }
}
.toggle {
width:15px;
}
+25 -3
View File
@@ -34,13 +34,23 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
protected string FormatException(Exception ex)
{
return
(ex is PiscalClientException ? $"LeafInput: {((PiscalClientException) ex).LeafInputId}{Environment.NewLine}" : "") +
(ex is PiscalClientException ? $"LeafInputId: {((PiscalClientException) ex).LeafInputId}{Environment.NewLine}" : "") +
$"Class: {GetType().Name}{Environment.NewLine}" +
$"Exception message: {ex.Message}{Environment.NewLine}" +
(ex.InnerException != null ? $"InnerException: {ex.InnerException}{Environment.NewLine}" : string.Empty)
+ $"StackTrace: {ex.StackTrace}";
}
protected string FormatLeafInputInfo(LeafInput leafInput)
{
return
$"User name: {leafInput.Name}{Environment.NewLine}" +
$"User email: {leafInput.Email}{Environment.NewLine}" +
$"Identifier: {leafInput.Identifier}{Environment.NewLine}" +
$"Site Id: {leafInput.SiteId}{Environment.NewLine}" +
$"Photosynthesis Type: {leafInput.PhotosynthesisType}{Environment.NewLine}";
}
protected void PiscalExceptionHandler(PiscalClientException ex, LeafInput leafInput)
{
var errorMessage = FormatException(ex);
@@ -48,7 +58,13 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
// send admin an email
BackgroundJobEnqueueRetry<EmailNotificationService>(
email => email.SendAdministratorMessage($"LeafWeb: PiscalQueue {GetType().Name} Exception", errorMessage));
email => email.SendAdministratorMessage(
$"LeafWeb: PiscalQueue {GetType().Name} Exception",
"Piscal exception reported. LeafInput info:" + Environment.NewLine
+ FormatLeafInputInfo(leafInput)
+ Environment.NewLine
+ "ErrorMessage:" + Environment.NewLine
+ errorMessage));
// send user email too
BackgroundJobEnqueueRetry<EmailNotificationService>(
@@ -67,7 +83,13 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
// send admin an email
BackgroundJobEnqueueRetry<EmailNotificationService>(
email => email.SendAdministratorMessage($"LeafWeb: PiscalQueue {GetType().Name} Warning", warningMessage));
email => email.SendAdministratorMessage(
$"LeafWeb: PiscalQueue {GetType().Name} Warning",
"Piscal warning reported. LeafInput info:" + Environment.NewLine
+ FormatLeafInputInfo(leafInput)
+ Environment.NewLine
+ "Warning message:" + Environment.NewLine
+ warningMessage));
}
public void Dispose()
@@ -83,7 +83,8 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
Logger.InfoFormat("LeafInput: {0}, Starting", pendingInputId);
try
{
DataService.SetLeafInputStatus(pendingInput, LeafInputStatusType.Starting);
DataService.SetLeafInputStatus(pendingInput, LeafInputStatusType.Starting,
details: $"File count: {pendingInput.InputFiles.Count}");
BackgroundJobEnqueueRetry<StartPending>(c => c.DoWork(pendingInputId));
}
catch (Exception ex)
@@ -26,6 +26,8 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
{
}
public string ServiceDescription => "Host: " + _piscalClient.Host;
public void Run(LeafInput leafInput)
{
var inputFile = new PiscalLeafInput(leafInput);
+1 -1
View File
@@ -10,7 +10,7 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
PiscalService.Run(leafInput);
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Running);
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Running, details: $"ServiceInfo: {PiscalService.ServiceDescription}");
}
}
}
+50
View File
@@ -0,0 +1,50 @@
@using ClientDependency.Core.Mvc
@inherits UmbracoTemplatePage
@{
Layout = null;
Html.RequiresCss("~/Content/bootstrap_leafweb.css");
Html.RequiresCss("~/Content/site.css");
Html.RequiresCss("~/Content/style.css");
Html.RequiresCss("~/css/rte.css");
Html.RequiresJs("~/scripts/jquery-1.12.4.js", 0);
Html.RequiresJs("~/scripts/bootstrap.js", 0);
Html.RequiresJs("~/scripts/site.js");
}
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="@CurrentPage.siteDescription">
<title>@CurrentPage.Name | @CurrentPage._siteTitle</title>
<!-- Fonts -->
<link href="//fonts.googleapis.com/css?family=Merriweather:400,700,300,900" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet" type="text/css">
<!-- CSS -->
@Html.RenderCssHere()
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div role="content">
@CurrentPage.GetGridHtml("content", "fanoe")
</div>
<!-- Javascripts -->
@Html.RenderJsHere()
</body>
</html>
+1
View File
@@ -61,6 +61,7 @@
@Html.EditorFor(m => m.Name)
@Html.EditorFor(m => m.Email)
@Html.EditorFor(m => m.EmailConfirm)
<a href="@UmbracoContext.Current.UrlProvider.GetUrl(1115)" target="_blank">Terms of Service</a>
<input type="submit" id="submit-form" class="hidden"/>
}
<label for="submit-form" class="btn btn-primary pull-right">Submit...</label>