Fix exception reporting.

- Repariert: Fehlerberichte konnten nicht gesendet werden.
This commit is contained in:
daniel 2017-09-18 21:19:49 +02:00
parent 08bd137e94
commit 443a6b48e7
10 changed files with 67 additions and 64 deletions

View File

@ -49,11 +49,11 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.1\lib\net40\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />

View File

@ -2,7 +2,7 @@
<packages>
<package id="Bovender" version="0.17.0.0" targetFramework="net40" />
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.1" targetFramework="net40" />
<package id="YamlDotNet.Signed" version="4.1.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NUnit" version="3.8.1" targetFramework="net40" />
<package id="YamlDotNet.Signed" version="4.2.1" targetFramework="net40" />
</packages>

View File

@ -1,53 +1,52 @@
<?php
require(__DIR__ . '/PHPMailer/PHPMailerAutoload.php');
$reportId = $_POST['report_id'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'nephrowiki.de';
$mail->Username = 'zaareloaded@nephrowiki.de';
$mail->Password = 'ooZ1eiJa';
// $mail->SMTPSecure = 'tls';
$mail->Port = 25;
function sendMail() {
$to = 'dk@doktorkraus.de';
$headers = "From: \"zaaReloaded\" <dk@doktorkraus.de>";
$reportId = $_POST['report_id'];
$info = print_r( $_POST, true ); // this will be a string, not an array!
$body = <<<EOF
zaaReloaded hat einen Fehler ausgelöst.
$mail->From = 'zaareloaded@nephrowiki.de';
$mail->FromName = 'zaaReloaded';
$mail->addAddress('dk@doktorkraus.de');
$mail->Subject = "[zaaReloaded] Exception $reportId";
-----
if ( $_POST['ccUser'] ) {
$validMail = filter_var( $_POST['usersMail'], FILTER_VALIDATE_EMAIL );
$validUser = filter_var( $_POST['usersName'], FILTER_SANITIZE_STRING );
if ( $validUser ) {
$validUser = "\"$validUser\" "; // space character deliberately placed
};
if ( $validMail ) {
$mail->addCC($validMail, $validUser);
};
};
Benutzerkommentar:
$info = print_r( $_POST, true );
$mail->Body = <<<EOF
zaaReloaded exception
User's comment on submission:
{$_POST['comment']}
***
-----
Technical details: $info
Technische Info: $info
--
http://zaa.nephrowiki.de
--
www.doktorkraus.de/zaareloaded
EOF;
if ($mail->send())
{
// Must return the report ID to indicate success
echo($reportId);
if ( $_POST['ccUser'] ) {
$validMail = filter_var( $_POST['usersMail'], FILTER_VALIDATE_EMAIL );
$validUser = filter_var( $_POST['usersName'], FILTER_SANITIZE_STRING );
if ( $validUser ) {
$validUser = "\"$validUser\" "; // space character deliberately placed
};
if ( $validMail ) {
$headers .= "\r\nCc: $validUser<$validMail>";
};
};
mail($to, "Exception report [$reportId]", $body, $headers);
}
else
{
echo($mail->ErrorInfo);
// =============================================================
// Begin main script
// =============================================================
if (!isset($_POST['report_id'])) {
http_response_code(400);
exit;
}
sendMail();
// Return the report ID and the issue URL to signal all is well.
$reportId = $_POST['report_id'];
$load = "{\"ReportId\": \"$reportId\", \"IssueUrl\": \"https://www.doktorkraus.de/zaareloaded\"}";
error_log( __FILE__ . ": Load = $load" );
header('Content-Type: application/json');
echo $load;

View File

@ -83,7 +83,7 @@ namespace zaaReloaded2.ExceptionHandler
protected override string DevPath()
{
return @"x:\Code\zaaReloaded2\zaaReloaded2\";
return @"x:\\Code\\zaaReloaded2\\zaaReloaded2\\";
}
protected override Bovender.UserSettings.UserSettingsBase UserSettings

View File

@ -34,12 +34,12 @@ namespace zaaReloaded2.ExceptionHandler
{
protected override Window CreateSuccessWindow()
{
return Content.InjectInto<SubmissionSuccessView>();
return new SubmissionSuccessView();
}
protected override Window CreateFailureWindow()
{
return Content.InjectInto<SubmissionFailureView>();
return new SubmissionFailureView();
}
protected override Window CreateCancelledWindow()

View File

@ -21,14 +21,14 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:zaaReloaded2"
SizeToContent="WidthAndHeight"
SizeToContent="Height" Width="540"
Title="Fehlerbericht versenden"
>
<Window.Resources>
<ResourceDictionary Source="/Bovender;component/Style.xaml" />
</Window.Resources>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock FontSize="72" FontWeight="Bold" Foreground="Red" Margin="0,0,10,0"
<DockPanel Margin="10">
<TextBlock DockPanel.Dock="Left" FontSize="72" FontWeight="Bold" Foreground="Red" Margin="0,0,10,0"
LineHeight="48" LineStackingStrategy="BlockLineHeight">
&#x00d7;
<TextBlock.Effect>
@ -36,11 +36,13 @@
</TextBlock.Effect>
</TextBlock>
<StackPanel>
<TextBlock Text="Beim Senden des Fehlerberichtes ist wiederum leider ein Fehler aufgetreten... (Funktioniert das Netzwerk?)" />
<TextBlock Text="{Binding Exception}" Margin="0,10,0,0" Foreground="LightSlateGray" />
<TextBlock TextWrapping="Wrap"
Text="Beim Senden des Fehlerberichtes ist wiederum leider ein Fehler aufgetreten... (Funktioniert das Netzwerk?)" />
<TextBlock TextWrapping="Wrap"
Text="{Binding Exception}" Margin="0,10,0,0" Foreground="LightSlateGray" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button Command="{Binding CloseViewCommand}" Content="Schließen" />
</StackPanel>
</StackPanel>
</StackPanel>
</DockPanel>
</Window>

View File

@ -28,7 +28,7 @@ namespace zaaReloaded2.ExceptionHandler
{
protected override System.Windows.Window CreateView()
{
return Content.InjectInto<SubmissionProcessView>();
return new SubmissionProcessView();
}
}
}

View File

@ -21,14 +21,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:zaaReloaded2"
SizeToContent="WidthAndHeight"
SizeToContent="Height" Width="400"
Title="Fehlerbericht versenden"
>
<Window.Resources>
<ResourceDictionary Source="/Bovender;component/Style.xaml" />
</Window.Resources>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock FontSize="48" FontWeight="Bold" Foreground="GreenYellow" Margin="0,0,10,0"
<DockPanel Margin="10">
<TextBlock DockPanel.Dock="Left"
FontSize="48" FontWeight="Bold" Foreground="GreenYellow" Margin="0,0,10,0"
LineHeight="48" LineStackingStrategy="BlockLineHeight">
&#x2714;
<TextBlock.Effect>
@ -36,10 +37,10 @@
</TextBlock.Effect>
</TextBlock>
<StackPanel>
<TextBlock Text="Der Fehlerbericht wurde erfolgreich versandt." />
<TextBlock TextWrapping="Wrap" Text="Der Fehlerbericht wurde erfolgreich versandt." />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 10 0 0">
<Button Command="{Binding CloseViewCommand}" Content="Schließen" />
</StackPanel>
</StackPanel>
</StackPanel>
</DockPanel>
</Window>

View File

@ -21,6 +21,6 @@
<packages>
<package id="Bovender" version="0.17.0.0" targetFramework="net40" />
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="YamlDotNet.Signed" version="4.1.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
</packages>

View File

@ -140,7 +140,7 @@
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
@ -235,6 +235,7 @@
<Compile Include="Formatter\DanielsStyle.cs" />
<Compile Include="Formatter\DocumentWriter.cs" />
<Compile Include="Formatter\NoLaboratoryDataException.cs" />
<Compile Include="Importer\ImportMode.cs" />
<Compile Include="LogFile.cs" />
<Compile Include="Medication\Formatter.cs" />
<Compile Include="Medication\Importer.cs" />