Scanning for LeafWeb data submission errors

This commit is contained in:
2020-08-11 21:07:46 -04:00
parent 5dfc65a83a
commit 9f654822f8
10 changed files with 98 additions and 60 deletions
+29 -1
View File
@@ -211,5 +211,33 @@ namespace LeafWeb.Core.Tests.Parsers
} }
LeafInputCsvParser.ExportCsv(@"C:\Temp\test.csv", leafInputs); LeafInputCsvParser.ExportCsv(@"C:\Temp\test.csv", leafInputs);
} }
}
[Explicit]
[Test]
public void FailedParseData_FindIssues()
{
const string dir = @"C:\temp\LeafWeb_FailedParseData\";
var files = Directory.GetFiles(dir, "*.csv", SearchOption.AllDirectories).Select(f => new FileInfo(f)).ToList();
var leafInputs = new List<LeafInputData>();
var num = 1;
foreach (var file in files)
{
try
{
var parser = new LeafInputCsvParser(file);
var leafInput = parser.Parse();
leafInputs.Add(leafInput);
Console.WriteLine("{3}/{4}, {0}, {1}, {2}", file.Name, leafInput.InvestigatorName, leafInput.ContactInformation, num++, files.Count);
}
catch (Exception ex)
{
File.AppendAllLines(@"C:\Temp\errors.txt", new[] { string.Format("{2}\\{1} : {0}", ex.Message, file.Name, file.Directory?.Name) });
Console.WriteLine("{2}\\{1} : {0}", ex.Message, file.Name, file.Directory?.Name);
}
}
LeafInputCsvParser.ExportCsv(@"C:\Temp\test.csv", leafInputs);
}
}
} }
+7
View File
@@ -63,6 +63,12 @@ namespace LeafWeb.WebCms.Models
public bool ShowOnlySuccessfullyCompleted => !string.IsNullOrEmpty(compl); public bool ShowOnlySuccessfullyCompleted => !string.IsNullOrEmpty(compl);
[Display(Name = "Show Only Erred")]
[UIHint("Checkbox")]
public string erred { get; set; }
public bool ShowOnlyErred => !string.IsNullOrEmpty(erred);
[Display(Name = "Only my data")] [Display(Name = "Only my data")]
[UIHint("Checkbox")] [UIHint("Checkbox")]
public string usr { get; set; } public string usr { get; set; }
@@ -83,6 +89,7 @@ namespace LeafWeb.WebCms.Models
&& string.IsNullOrEmpty(tleaf) && string.IsNullOrEmpty(tleaf)
&& string.IsNullOrEmpty(phips2) && string.IsNullOrEmpty(phips2)
&& string.IsNullOrEmpty(compl) && string.IsNullOrEmpty(compl)
&& string.IsNullOrEmpty(erred)
); );
public bool HasParameters => public bool HasParameters =>
+10
View File
@@ -154,6 +154,16 @@ namespace LeafWeb.WebCms.Utility
select li; select li;
} }
if (query.ShowOnlyErred)
{
resultItems =
from li in resultItems
where
// has an error message
li.OutputFiles.Any(f => f.Filename.Contains(LeafOutputFile.Filename_ErrorMessage))
select li;
}
if (query.OnlyUserData && !string.IsNullOrEmpty(currentUserEmail)) if (query.OnlyUserData && !string.IsNullOrEmpty(currentUserEmail))
{ {
resultItems = resultItems =
@@ -41,20 +41,6 @@ else
new {id="register-member"})) new {id="register-member"}))
{ {
@Html.ValidationSummary(false) @Html.ValidationSummary(false)
<ul class="d-none">
@foreach (var ms in ViewData.ModelState)
{
<li>@ms.Key
<ul>
<li>@ms.Value.Value.AttemptedValue</li>
@foreach (var valueError in ms.Value.Errors)
{
<li>@valueError.ErrorMessage</li>
}
</ul>
</li>
}
</ul>
@Html.EditorFor(m => registerModel.Name) @Html.EditorFor(m => registerModel.Name)
@Html.EditorFor(m => registerModel.Email, new { type = "email"}) @Html.EditorFor(m => registerModel.Email, new { type = "email"})
@@ -66,7 +52,7 @@ else
</div> </div>
@Html.HiddenFor(m => registerModel.MemberTypeAlias) @Html.HiddenFor(m => registerModel.MemberTypeAlias)
@Html.HiddenFor(m => registerModel.RedirectUrl) @Html.HiddenFor(m => registerModel.RedirectUrl)
@Html.HiddenFor(m => registerModel.UsernameIsEmail) @*@Html.HiddenFor(m => registerModel.UsernameIsEmail)*@
<button type="submit" class="btn btn-primary pull-right">Register</button> <button type="submit" class="btn btn-primary pull-right">Register</button>
} }
+3 -1
View File
@@ -26,7 +26,9 @@
new ViewDataDictionary{ new ViewDataDictionary{
{"actionName", "Search"}, {"actionName", "Search"},
{"controllerName", "Queue"}, {"controllerName", "Queue"},
{"htmlFormAction", "/admin/manage-queue/"}}) {"htmlFormAction", "/admin/manage-queue/"},
{"admin", true}
})
</div> </div>
</div> </div>
+18 -19
View File
@@ -8,26 +8,25 @@
@ChartLink(Model) @ChartLink(Model)
<div class="dropdown pl-3"> @if (string.Equals(Model.Email, username, StringComparison.OrdinalIgnoreCase))
<button class="btn btn-outline-secondary dropdown-toggle" id="downloadButton" {
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <div class="dropdown pl-3">
<span class="fa fa-download"></span> Download <button class="btn btn-outline-secondary dropdown-toggle" id="downloadButton"
</button> data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@if (string.Equals(Model.Email, username, StringComparison.OrdinalIgnoreCase)) <span class="fa fa-download"></span> Download
{ </button>
<div class="dropdown-menu" aria-labelledby="downloadButton"> <div class="dropdown-menu" aria-labelledby="downloadButton">
<a href="@Url.Action("Input", "Download", new {id = Model.LeafInputId})" <a href="@Url.Action("Input", "Download", new {id = Model.LeafInputId})"
class="dropdown-item"> class="dropdown-item">
Input Input
</a> </a>
<a href="@Url.Action("OutputToUser", "Download", new {id = Model.LeafInputId})" <a href="@Url.Action("OutputToUser", "Download", new {id = Model.LeafInputId})"
class="dropdown-item @if (!Model.HasOutputFiles) {<text> disabled</text>}"> class="dropdown-item @if (!Model.HasOutputFiles) {<text> disabled</text>}">
Output Output
</a> </a>
</div>
</div> </div>
} }
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="container"> <div class="container">
-22
View File
@@ -1,22 +0,0 @@
@model Boolean?
@{
Layout = "_FieldLayout.cshtml";
var htmlAttributes = new RouteValueDictionary();
if (ViewBag.@class != null)
{
htmlAttributes.Add("class", ViewBag.@class);
}
}
@if (Model.HasValue && Model.Value)
{
<input id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" name="@ViewData.TemplateInfo.GetFullHtmlFieldId("")"
type="checkbox" checked="checked" />
}
else
{
<input id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" name="@ViewData.TemplateInfo.GetFullHtmlFieldId("")"
type="checkbox" />
}
@@ -0,0 +1,15 @@
<ul class="d-none">
@foreach (var ms in ViewData.ModelState)
{
<li>@ms.Key
<ul>
<li>@ms.Value.Value.AttemptedValue</li>
@foreach (var valueError in ms.Value.Errors)
{
<li class="text-danger">Error: @valueError.ErrorMessage</li>
<li class="text-danger">Ex: @valueError.Exception.Message</li>
}
</ul>
</li>
}
</ul>
+13
View File
@@ -11,6 +11,7 @@
var actionName = string.Empty; var actionName = string.Empty;
var controllerName = string.Empty; var controllerName = string.Empty;
var htmlFormAction = string.Empty; var htmlFormAction = string.Empty;
var admin = false;
if (ViewData.ContainsKey("actionName")) if (ViewData.ContainsKey("actionName"))
{ {
@@ -24,6 +25,10 @@
{ {
htmlFormAction = (string)ViewData["htmlFormAction"]; htmlFormAction = (string)ViewData["htmlFormAction"];
} }
if (ViewData.ContainsKey("admin"))
{
admin = true;
}
} }
@using (Html.BeginUmbracoForm(actionName, controllerName, null, new { action = htmlFormAction, id = "leafdataquery" })) @using (Html.BeginUmbracoForm(actionName, controllerName, null, new { action = htmlFormAction, id = "leafdataquery" }))
{ {
@@ -101,6 +106,14 @@
@Html.EditorFor(m => m.compl) @Html.EditorFor(m => m.compl)
</div> </div>
</div> </div>
@if (admin)
{
<div class="row">
<div class="col">
@Html.EditorFor(m => m.erred)
</div>
</div>
}
</div> </div>
</div> </div>
</div> </div>
+1 -1
View File
@@ -1075,9 +1075,9 @@
<Content Include="Views\Shared\DisplayTemplates\_Details_ResultsLink.cshtml" /> <Content Include="Views\Shared\DisplayTemplates\_Details_ResultsLink.cshtml" />
<Content Include="Views\Results\Details.cshtml" /> <Content Include="Views\Results\Details.cshtml" />
<Content Include="Views\MacroPartials\ResultsDetails.cshtml" /> <Content Include="Views\MacroPartials\ResultsDetails.cshtml" />
<Content Include="Views\Shared\Boolean.cshtml" />
<Content Include="Views\Shared\EditorTemplates\Checkbox.cshtml" /> <Content Include="Views\Shared\EditorTemplates\Checkbox.cshtml" />
<Content Include="Views\Shared\PermissionDenied.cshtml" /> <Content Include="Views\Shared\PermissionDenied.cshtml" />
<Content Include="Views\Shared\ModelStateErrors.cshtml" />
<None Include="Web.Debug.config"> <None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon> <DependentUpon>Web.config</DependentUpon>
</None> </None>