Esempio n. 1
0
        private void OnLoadTemplateClick(object sender, RoutedEventArgs e)
        {
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            string version = fvi.FileVersion;


            var template = m_Reporter.Templater.LoadTemplate(TemplateSelection.SelectedValue.ToString());

            var sampleTbl  = SampleDataGenerator.GenerateSampleTable();
            var reportData = new SimpleReportData
            {
                TemplateData = template,
                ContentData  = new SimpleContentData
                {
                    ListOfTexts = new Dictionary <string, string> {
                        { "appVersion", version }
                    },
                    ListOfTables = new List <SimpleTableData>
                    {
                        new SimpleTableData
                        {
                            Table = sampleTbl,
                        },
                    },
                },
            };

            var printData = m_Reporter.CreateReport(reportData);

            m_ReportViewer.LoadReport(printData);
        }
Esempio n. 2
0
        public SimplePrintData CreateReport(SimpleReportData reportData)
        {
            var data = new SimplePrintData();

            var builder = new ReportBuilder();

            data.HtmlContent = builder.BuildReport(reportData);

            Cleanup(reportData);
            return(data);
        }
Esempio n. 3
0
 public string FinishReport(SimpleReportData reportData, string content)
 {
     if (reportData.ContentData.ListOfVariables != null)
     {
         //Replace varText with variable content
         foreach (var variable in reportData.ContentData.ListOfVariables)
         {
             content = content.Replace(variable.Key, variable.Value);
         }
     }
     return(content);
 }
Esempio n. 4
0
 private void Cleanup(SimpleReportData reportData)
 {
     try
     {
         if (reportData.ContentData != null)
         {
             if (reportData.ContentData.ListOfAttributes != null)
             {
                 reportData.ContentData.ListOfAttributes.Clear();
             }
             if (reportData.ContentData.ListOfSelections != null)
             {
                 reportData.ContentData.ListOfSelections.Clear();
             }
             if (reportData.ContentData.ListOfTables != null)
             {
                 reportData.ContentData.ListOfTables.Clear();
             }
             if (reportData.ContentData.ListOfTexts != null)
             {
                 reportData.ContentData.ListOfTexts.Clear();
             }
             if (reportData.ContentData.ListOfVariables != null)
             {
                 reportData.ContentData.ListOfVariables.Clear();
             }
         }
         if (reportData.TemplateData != null)
         {
             if (reportData.TemplateData.HtmlNodeList != null)
             {
                 reportData.TemplateData.HtmlNodeList = new List <HtmlNode>();
             }
             if (reportData.TemplateData.StyleFiles != null)
             {
                 reportData.TemplateData.StyleFiles.Clear();
             }
         }
     }
     catch (Exception ex)
     {
         SLLog.WriteError(new LogData
         {
             Source       = ToString(),
             FunctionName = "Cleanup Error!",
             Ex           = ex,
         });
     }
     GC.Collect();
 }
Esempio n. 5
0
        public string BuildReport(SimpleReportData reportData)
        {
            if (reportData == null)
            {
                return("ReportData ist null!");
            }
            if (reportData.TemplateData == null)
            {
                return("Template wurde nicht definiert!");
            }
            if (reportData.ContentData == null)
            {
                return("ContentData ist null!");
            }

            var data = reportData.ContentData;

            foreach (HtmlNode node in reportData.TemplateData.HtmlNodeList)
            {
                TextBuilder.BuildTexts(node, data);
                TextBuilder.BuildAttributes(node, data);
                TextBuilder.BuildVariables(node, data);

                switch (node.OriginalName)
                {
                case "table":
                    TableBuilder.BuildTable(node, data, node.Id);
                    break;

                case "select":
                    SelectionBuilder.BuildSelections(node, data, node.Id);
                    break;
                }
            }

            var firstHtmlNode = reportData.TemplateData.HtmlNodeList.First();

            return(FinishReport(reportData, firstHtmlNode.OuterHtml));
        }