public static string PrintChildren( string AChildName, string ADonorName, bool AChildWithoutDonor, string APartnerStatus, string ASponsorshipStatus, string ASponsorAdmin, string ASortBy, string AReportLanguage) { SponsorshipFindTDSSearchResultTable table = FindChildren(AChildName, ADonorName, AChildWithoutDonor, APartnerStatus, ASponsorshipStatus, ASponsorAdmin, ASortBy); HtmlDocument HTMLDocument = HTMLTemplateProcessor.Table2Html(table, "Sponsorship/SponsoredChildrenList.html", AReportLanguage); string PDFFile = TFileHelper.GetTempFileName( "printchildrenlist", ".pdf"); if (Html2Pdf.HTMLToPDF(HTMLDocument.DocumentNode.WriteTo(), PDFFile)) { byte[] data = System.IO.File.ReadAllBytes(PDFFile); string result = Convert.ToBase64String(data); System.IO.File.Delete(PDFFile); return(result); } return(String.Empty); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist) { HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); bool NewTransaction; TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction( IsolationLevel.ReadCommitted, out NewTransaction, "PartnerBySpecialTypesRead"); // get all the partners string sql = templateProcessor.GetSQLQuery("SelectPartners"); DataTable partners = DBAccess.GDBAccessObj.SelectDT(sql, "transactions", ReadTransaction); // TODO: get best address if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, partners, templateProcessor); return(html); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist) { HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); TDBTransaction ReadTransaction = new TDBTransaction(); DataTable recipients = null; DBAccess.ReadTransaction( ref ReadTransaction, delegate { // get all the recipients string sql = templateProcessor.GetSQLQuery("SelectRecipients"); recipients = ReadTransaction.DataBaseObj.SelectDT(sql, "recipients", ReadTransaction); }); // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, recipients, templateProcessor); return(html); }
private static void CalculateData(ref HtmlDocument html, DataTable partners, HTMLTemplateProcessor templateProcessor) { var partnerTemplate = HTMLTemplateProcessor.SelectSingleNode(html.DocumentNode, "//div[@id='partner_template']"); var partnerParentNode = partnerTemplate.ParentNode; int countRow = 0; foreach (DataRow partner in partners.Rows) { if (partner["p_partner_class_c"].ToString() == "FAMILY") { partner["PartnerName"] = Calculations.FormatShortName(partner["PartnerName"].ToString(), eShortNameFormat.eReverseShortname); } templateProcessor.AddParametersFromRow(partner); var newPartnerRow = partnerTemplate.Clone(); string partnerId = "partner" + countRow.ToString(); newPartnerRow.SetAttributeValue("id", partnerId); partnerParentNode.AppendChild(newPartnerRow); newPartnerRow.InnerHtml = templateProcessor.InsertParameters("{", "}", newPartnerRow.InnerHtml, HTMLTemplateProcessor.ReplaceOptions.NoQuotes); countRow++; } partnerTemplate.Remove(); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist) { HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); bool NewTransaction; TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction( IsolationLevel.ReadCommitted, out NewTransaction, "AccountDetailRead"); // get all the transactions string sql = templateProcessor.GetSQLQuery("SelectTransactions"); DataTable transactions = DBAccess.GDBAccessObj.SelectDT(sql, "transactions", ReadTransaction); // get all the balances sql = templateProcessor.GetSQLQuery("SelectBalances"); DataTable balances = DBAccess.GDBAccessObj.SelectDT(sql, "balances", ReadTransaction); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, balances, transactions, templateProcessor); return(html); }
private static bool PrintToPDF(string AFilename, HtmlDocument AHTMLDocument) { // transform the HTML output to pdf file HTMLTemplateProcessor.HTMLToPDF(AHTMLDocument, AFilename); return(true); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist, TDBTransaction ATransaction ) { HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); DataTable recipients = null; // get all the recipients string sql = templateProcessor.GetSQLQuery("SelectRecipients"); recipients = ATransaction.DataBaseObj.SelectDT(sql, "recipients", ATransaction); // ensure consents string needed_consent = parameterlist.Get("param_consent").ToString().Replace("*", "").Replace("%", "").Trim(); recipients = Utils.PartnerRemoveUnconsentReportData(recipients, needed_consent); // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, recipients, templateProcessor); return(html); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist, TDBTransaction ATransaction) { if (parameterlist.Get("param_city").ToString().Replace("*", "").Replace("%", "").Trim() == String.Empty) { throw new Exception("invalid parameters"); } HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); // get all the partners string sql = templateProcessor.GetSQLQuery("SelectPartners"); DataTable partners = ATransaction.DataBaseObj.SelectDT(sql, "transactions", ATransaction); // TODO: get best address // ensure consents string needed_consent = parameterlist.Get("param_consent").ToString().Replace("*", "").Replace("%", "").Trim(); partners = Utils.PartnerRemoveUnconsentReportData(partners, needed_consent); // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, partners, templateProcessor); return(html); }
private bool PrintToPDF(string AFilename) { // transform the HTML output to pdf file HTMLTemplateProcessor.HTMLToPDF(FHTMLDocument, AFilename); return(true); }
private static bool ExportToExcelFile(string AFilename, HtmlDocument AHTMLDocument) { // transform the HTML output to xlsx file ExcelPackage ExcelDoc = HTMLTemplateProcessor.HTMLToCalc(AHTMLDocument); if (ExcelDoc != null) { using (FileStream fs = new FileStream(AFilename, FileMode.Create)) { ExcelDoc.SaveAs(fs); fs.Close(); } return(true); } return(false); }
private static bool ExportToExcelFile(string AFilename, HtmlDocument AHTMLDocument) { // transform the HTML output to xlsx file XSSFWorkbook workbook = HTMLTemplateProcessor.HTMLToCalc(AHTMLDocument); if (workbook != null) { using (FileStream fs = new FileStream(AFilename, FileMode.Create)) { workbook.Write(fs); fs.Close(); } return(true); } return(false); }
/// calculate the report public static HtmlDocument Calculate( string AHTMLReportDefinition, TParameterList parameterlist, TDBTransaction ATransaction) { HTMLTemplateProcessor templateProcessor = new HTMLTemplateProcessor(AHTMLReportDefinition, parameterlist); // get all the partners string sql = templateProcessor.GetSQLQuery("SelectPartners"); DataTable partners = ATransaction.DataBaseObj.SelectDT(sql, "transactions", ATransaction); // TODO: get best address // generate the report from the HTML template HtmlDocument html = templateProcessor.GetHTML(); CalculateData(ref html, partners, templateProcessor); return(html); }
private static void CalculateData(ref HtmlDocument html, DataTable balances, DataTable transactions, HTMLTemplateProcessor templateProcessor) { var balanceTemplate = HTMLTemplateProcessor.SelectSingleNode(html.DocumentNode, "//div[@id='costcentreaccount_template']"); var balanceParentNode = balanceTemplate.ParentNode; int countBalanceRow = 0; int countTransactionRow = 0; foreach (DataRow balance in balances.Rows) { // skip account/costcentre combination if there are no transations and the balance is 0 if ((Decimal)balance["end_balance"] == 0.0m) { bool transactionExists = false; foreach (DataRow transaction in transactions.Rows) { if ((transaction["a_account_code_c"].ToString() == balance["a_account_code_c"].ToString()) && (transaction["a_cost_centre_code_c"].ToString() == balance["a_cost_centre_code_c"].ToString())) { transactionExists = true; break; } } if (!transactionExists) { continue; } } templateProcessor.AddParametersFromRow(balance); var newBalanceRow = balanceTemplate.Clone(); string balanceId = "acccc" + countBalanceRow.ToString(); newBalanceRow.SetAttributeValue("id", balanceId); balanceParentNode.AppendChild(newBalanceRow); countBalanceRow++; var FooterDiv = HTMLTemplateProcessor.SelectSingleNode(newBalanceRow, ".//div[@class='row']"); Decimal TotalCredit = 0.0m; Decimal TotalDebit = 0.0m; foreach (DataRow transaction in transactions.Rows) { if (!((transaction["a_account_code_c"].ToString() == balance["a_account_code_c"].ToString()) && (transaction["a_cost_centre_code_c"].ToString() == balance["a_cost_centre_code_c"].ToString()))) { continue; } TVariant amount = new TVariant(transaction["a_transaction_amount_n"]); if ((bool)transaction["a_debit_credit_indicator_l"]) { TotalDebit += amount.ToDecimal(); } else { TotalCredit += amount.ToDecimal(); } countTransactionRow++; } templateProcessor.SetParameter("total_debit", new TVariant(TotalDebit)); templateProcessor.SetParameter("total_credit", new TVariant(TotalCredit)); FooterDiv.InnerHtml = templateProcessor.InsertParameters("{", "}", FooterDiv.InnerHtml, HTMLTemplateProcessor.ReplaceOptions.NoQuotes); } balanceTemplate.Remove(); }