Mit UI verdbunden, so ganz funktioniert es noch nicht..
This commit is contained in:
parent
5b588712de
commit
c1a4540c86
@ -26,10 +26,12 @@
|
|||||||
<value>1000</value>
|
<value>1000</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="LockingServerAddress" serializeAs="String">
|
<setting name="LockingServerAddress" serializeAs="String">
|
||||||
<value>http://192.168.2.24/LockingService/LockingService.svc</value>
|
<!--value>http://192.168.2.24/LockingService/LockingService.svc</value-->
|
||||||
|
<value>http://heupferd/bsmd.LockingService/LockingService.svc</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="ConnectionString" serializeAs="String">
|
<setting name="ConnectionString" serializeAs="String">
|
||||||
<value>Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value>
|
<value>Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=E:\DATA\DB\NSW.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False</value>
|
||||||
|
<!--value>Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value-->
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="ReportAuthor" serializeAs="String">
|
<setting name="ReportAuthor" serializeAs="String">
|
||||||
<value>BSMD ReportGenerator</value>
|
<value>BSMD ReportGenerator</value>
|
||||||
|
|||||||
@ -80,7 +80,12 @@
|
|||||||
<Label Grid.Column="0" Grid.Row="6" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" />
|
<Label Grid.Column="0" Grid.Row="6" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" />
|
||||||
<Button IsEnabled="True" Name="buttonStorno" Grid.Column="1" Grid.Row="6" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}" Background="Red"/>
|
<Button IsEnabled="True" Name="buttonStorno" Grid.Column="1" Grid.Row="6" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}" Background="Red"/>
|
||||||
<Button IsEnabled="True" Name="buttonCopy" Grid.Column="2" Grid.Row="6" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/>
|
<Button IsEnabled="True" Name="buttonCopy" Grid.Column="2" Grid.Row="6" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/>
|
||||||
<Button IsEnabled="False" Name="buttonSendPDF" Grid.Column="3" Grid.Row="6" Margin="2" Click="buttonSendPDF_Click" Content="{x:Static p:Resources.textCreatePDF}"/>
|
<Button IsEnabled="True" Name="buttonSendPDF" Grid.Column="3" Grid.Row="6" Margin="2" Click="buttonSendPDF_Click">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="{x:Static p:Resources.textCreatePDF}"></TextBlock>
|
||||||
|
<Image Source="../Resources/document_pdf.png" Margin="10,0,5,0" Height="16"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
<Button Name="buttonQueryHIS" Grid.Column="4" Grid.Row="6" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/>
|
<Button Name="buttonQueryHIS" Grid.Column="4" Grid.Row="6" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/>
|
||||||
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="6">
|
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="6">
|
||||||
<Button Name="buttonRefresh" Margin="2" Click="buttonRefresh_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipRefresh}">
|
<Button Name="buttonRefresh" Margin="2" Click="buttonRefresh_Click" BorderThickness="0" Background="Transparent" ToolTip="{x:Static p:Resources.textTooltipRefresh}">
|
||||||
|
|||||||
@ -12,6 +12,7 @@ using System.Timers;
|
|||||||
using bsmd.database;
|
using bsmd.database;
|
||||||
using ENI2.EditControls;
|
using ENI2.EditControls;
|
||||||
using ENI2.Import;
|
using ENI2.Import;
|
||||||
|
using ENI2.Report;
|
||||||
|
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -538,7 +539,31 @@ namespace ENI2.DetailViewControls
|
|||||||
|
|
||||||
private void buttonSendPDF_Click(object sender, RoutedEventArgs e)
|
private void buttonSendPDF_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
SelectImportClassesDialog sicd = new SelectImportClassesDialog();
|
||||||
|
sicd.IsTransit = this.Core.IsTransit;
|
||||||
|
if ((sicd.ShowDialog() ?? false) && (sicd.SelectedClasses.Count > 0))
|
||||||
|
{
|
||||||
|
// get here if user selected some classes
|
||||||
|
SaveFileDialog sfd = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "PDF Files|*.pdf"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() ?? false)
|
||||||
|
{
|
||||||
|
Util.UIHelper.SetBusyState();
|
||||||
|
ReportManager rm = new ReportManager();
|
||||||
|
|
||||||
|
// create PDF from message classes
|
||||||
|
if (rm.Create(sfd.FileName, this.Core, sicd.SelectedClasses, out string importResultText))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Report created", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(importResultText, "PDF create failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonQueryHIS_Click(object sender, RoutedEventArgs e)
|
private void buttonQueryHIS_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@ -86,9 +86,9 @@ namespace ENI2.Report
|
|||||||
document.Info.Subject = "Reporting class info";
|
document.Info.Subject = "Reporting class info";
|
||||||
document.Info.Author = Properties.Settings.Default.ReportAuthor;
|
document.Info.Author = Properties.Settings.Default.ReportAuthor;
|
||||||
|
|
||||||
ReportDocument.DefineSingleStyle(document);
|
DefineSingleStyle(document);
|
||||||
ReportDocument.DefineSingleHeader(document, coverInfos, rp);
|
DefineSingleHeader(document, coverInfos, rp);
|
||||||
ReportDocument.DefineContentSectionInitial(document);
|
DefineContentSectionInitial(document);
|
||||||
|
|
||||||
DatabaseEntity.ReportReplacer += DatabaseEntity_ReportReplacer; // ist das ein Leak?
|
DatabaseEntity.ReportReplacer += DatabaseEntity_ReportReplacer; // ist das ein Leak?
|
||||||
_lastOrientation = Orientation.Portrait; // Reset orientation (if last page was landscape..)
|
_lastOrientation = Orientation.Portrait; // Reset orientation (if last page was landscape..)
|
||||||
@ -103,18 +103,16 @@ namespace ENI2.Report
|
|||||||
/// <param name="filename">full path of bla.pdf output file</param>
|
/// <param name="filename">full path of bla.pdf output file</param>
|
||||||
public static void RenderDocument(Document document, string filename)
|
public static void RenderDocument(Document document, string filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
// wozu braucht man das hier?
|
|
||||||
string filenameCore = Path.GetFileNameWithoutExtension(filename);
|
string filenameCore = Path.GetFileNameWithoutExtension(filename);
|
||||||
string migraTempFile = string.Format("{1}\\{0}.mdddl", filenameCore, Path.GetDirectoryName(filename));
|
string migraTempFile = string.Format("{1}\\{0}.mdddl", filenameCore, Path.GetDirectoryName(filename));
|
||||||
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, migraTempFile);
|
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, migraTempFile);
|
||||||
|
|
||||||
// TODO Test font embedding (-> filesize!)
|
|
||||||
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
|
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
|
||||||
renderer.Document = document;
|
renderer.Document = document;
|
||||||
renderer.RenderDocument();
|
renderer.RenderDocument();
|
||||||
|
|
||||||
renderer.PdfDocument.Save(filename);
|
renderer.PdfDocument.Save(filename);
|
||||||
|
File.Delete(migraTempFile); // dont need that
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -4,26 +4,67 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using log4net;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
|
||||||
using bsmd.database;
|
using bsmd.database;
|
||||||
|
|
||||||
namespace ENI2.Report
|
namespace ENI2.Report
|
||||||
{
|
{
|
||||||
class ReportManager
|
class ReportManager
|
||||||
{
|
{
|
||||||
|
private readonly ILog _log = LogManager.GetLogger(typeof(ReportManager));
|
||||||
|
|
||||||
public bool Import(string filePath, MessageCore core, List<Message.NotificationClass> classes, out string readMessage)
|
public bool Create(string filePath, MessageCore core, List<Message.NotificationClass> notificationClasses, out string readMessage)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
readMessage = "";
|
readMessage = "";
|
||||||
|
if(notificationClasses.Count == 0)
|
||||||
|
{
|
||||||
|
readMessage = "no classes selected";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Message> messages = DBManager.Instance.GetMessagesForCore(core, DBManager.MessageLoad.ALL);
|
||||||
|
List<Message> reportMessages = new List<Message>();
|
||||||
|
messages.Sort(new ReportMessageComparer());
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (Message aMessage in messages)
|
||||||
|
{
|
||||||
|
if (notificationClasses.Contains(aMessage.MessageNotificationClass))
|
||||||
|
{
|
||||||
|
reportMessages.Add(aMessage);
|
||||||
|
|
||||||
|
sb.Append(aMessage.MessageNotificationClassDisplay);
|
||||||
|
sb.Append("_");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sb.Length > 0) sb.Remove(sb.Length - 1, 1);
|
||||||
|
string classes = sb.ToString();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Dictionary<string, string> coverInfos = new Dictionary<string, string>();
|
||||||
|
coverInfos.Add("Ship", DBManager.Instance.GetShipNameFromCore(core));
|
||||||
|
coverInfos.Add("ETA", core.ETA_NOA_NOD.HasValue ? core.ETA_NOA_NOD.Value.ToLocalTime().ToString() : "");
|
||||||
|
coverInfos.Add("Port of call", core.Portname);
|
||||||
|
coverInfos.Add("Visit-ID", core.DisplayId);
|
||||||
|
coverInfos.Add("Class", classes);
|
||||||
|
|
||||||
|
Document migraDocument = ReportDocument.CreateSingleClassDocument(core, reportMessages, coverInfos, classes, ReportingParty.CurrentReportingParty);
|
||||||
|
|
||||||
|
// print messages to document
|
||||||
|
foreach (Message message in reportMessages)
|
||||||
|
{
|
||||||
|
ReportDocument.AddNSWMessageParagraph(migraDocument, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportDocument.RenderDocument(migraDocument, filePath);
|
||||||
|
_log.InfoFormat("Created PDF document: {0}", filePath);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -31,5 +72,14 @@ namespace ENI2.Report
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class ReportMessageComparer : IComparer<bsmd.database.Message>
|
||||||
|
{
|
||||||
|
public int Compare(Message x, Message y)
|
||||||
|
{
|
||||||
|
return Message.ANSWSortList.IndexOf(x.MessageNotificationClass).CompareTo(Message.ANSWSortList.IndexOf(y.MessageNotificationClass));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user