ChristopherusHausFamilienhilfe/Export/SimbaExporter - mit PDF-Export
This commit is contained in:
@@ -9,39 +9,32 @@ using BeWo.Report.ReportObjects;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BS.Shared.DataContracts;
|
||||
using DevExpress.XtraPrinting;
|
||||
using DevExpress.XtraReports.UI;
|
||||
|
||||
namespace ChristopherusHausFamilienhilfe.Export
|
||||
{
|
||||
public class FibuExport
|
||||
{
|
||||
List<FileAttachmentDC> liste = new List<FileAttachmentDC>();
|
||||
public static QueryDC CreateQuery(QueryDC query)
|
||||
{
|
||||
DateTime dt = DateTime.Now;
|
||||
DateTime.TryParse(query.Parameter[0].Value.ToString(), out dt);
|
||||
|
||||
var table = ExecuteQuery(GetMonatlicheRechnungenSql(dt), dt);
|
||||
|
||||
query.FileName = String.Format("BUCH_BO_{0:yyyyMM}.scs", dt);
|
||||
string folder = String.Format("BUCH_BO_{0:yyyyMM}", dt);
|
||||
query.QueryResult = GetAbrechnungenString(dt, folder);
|
||||
query.QueryResult = GetAbrechnungenString(dt, table);
|
||||
query.Attachments = CreateInvoiceFiles(table);
|
||||
return query;
|
||||
}
|
||||
|
||||
//public static string CreateExportString(string[] pHeaderCaption, string[][] pContent)
|
||||
//{
|
||||
// if (pHeaderCaption != null && pHeaderCaption.Length > 1 && pHeaderCaption[0].Contains("Fibu"))
|
||||
// {
|
||||
// DateTime dt = DateTime.Now;
|
||||
// DateTime.TryParse(pHeaderCaption[1], out dt);
|
||||
// return GetAbrechnungenString(dt);
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public static String GetAbrechnungenString(DateTime dt, String folder)
|
||||
public static String GetAbrechnungenString(DateTime dt, DataTable table)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("\"MND\";500");
|
||||
sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt));
|
||||
|
||||
var s = GetMonatlicheRechnungenString(dt, folder);
|
||||
sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt));
|
||||
var s = GetMonatlicheRechnungenString(dt, table);
|
||||
if (!String.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
sb.Append(s);
|
||||
@@ -50,9 +43,8 @@ namespace ChristopherusHausFamilienhilfe.Export
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static String GetMonatlicheRechnungenString(DateTime date, String folder)
|
||||
public static String GetMonatlicheRechnungenString(DateTime date, DataTable dt)
|
||||
{
|
||||
var dt = ExecuteQuery(GetMonatlicheRechnungenSql(date), date);
|
||||
/* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, org.DebitorNumber, '3170', org.Name, p.FirstName, p.LastName*/
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
@@ -81,16 +73,18 @@ namespace ChristopherusHausFamilienhilfe.Export
|
||||
sb.Append(";;;;");
|
||||
sb.Append(String.Format("\"Rechnung ISB{0}.pdf\"", row[3]));
|
||||
}
|
||||
SaveInvoicesToFolder(dt, folder);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void SaveInvoicesToFolder(DataTable dt, String folder)
|
||||
private static List<FileAttachmentDC> CreateInvoiceFiles(DataTable dt)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<FileAttachmentDC> liste = new List<FileAttachmentDC>();
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
var pdf = new FileAttachmentDC();
|
||||
|
||||
var invoiceOid = row[10].ToString();
|
||||
if (!String.IsNullOrEmpty(invoiceOid))
|
||||
{
|
||||
@@ -103,16 +97,26 @@ namespace ChristopherusHausFamilienhilfe.Export
|
||||
var ro = ServiceInvoiceRO.Create(idc);
|
||||
anhang.SetReportDataSource(ro);
|
||||
anhang.CreateDocument();
|
||||
string name = anhang.PrintingSystem.Document.Name;
|
||||
string path = @"C:\Temp\FiBuExport\";
|
||||
anhang.ExportToPdf(path + name + ".pdf");
|
||||
|
||||
pdf.FileName = anhang.PrintingSystem.Document.Name + ".pdf";
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
anhang.ExportToPdf(ms);
|
||||
pdf.BinaryData = ms.ToArray();
|
||||
}
|
||||
liste.Add(pdf);
|
||||
//string name = anhang.PrintingSystem.Document.Name;
|
||||
//string path = @"C:\Temp\FiBuExport\";
|
||||
//anhang.ExportToPdf(path + name + ".pdf");
|
||||
}
|
||||
}
|
||||
return liste;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// continue - auch wenn gar nichts stimmt
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String GetMonatlicheRechnungenSql(DateTime date)
|
||||
|
||||
Reference in New Issue
Block a user