Exemple #1
0
 public void PrependLogs(FilingSummary tmpFS)
 {
     for (int i = 0; i < tmpFS.Logs.Count; i++)
     {
         LogItem log = tmpFS.Logs[i];
         this.Logs.Insert(i, log);
     }
 }
Exemple #2
0
        private List <ReportHeader> returnHeaders(DirectoryInfo path)
        {
            FilingSummary       sum        = FilingSummary.Load(path.FullName);
            List <ReportHeader> HeaderList = new List <ReportHeader>();

            if (sum != null)
            {
                ReportHeader[] header = (ReportHeader[])sum.MyReports.ToArray();
                HeaderList = new List <ReportHeader>(header);
            }

            return(HeaderList);
        }
Exemple #3
0
        public static FilingSummary Load(string directory)
        {
            string fn = directory + Path.DirectorySeparatorChar + FilingSummaryXmlName;

            if (!File.Exists(fn))
            {
                return(null);
            }

            XmlTextReader xmlReader = new XmlTextReader(fn);

            XmlSerializer xmlReport = new XmlSerializer(typeof(FilingSummary));

            FilingSummary fs = (FilingSummary)xmlReport.Deserialize(xmlReader);

            xmlReader.Close();

            return(fs);
        }
Exemple #4
0
        /// <summary>
        /// The method name refers to RR, but it is for all Instance Documents
        /// </summary>
        /// <param name="reportDirectory">The folder containing all reports (R1.xml, etc).
        /// This is also the destination folder.</param>
        /// <param name="excelReportName">The destination file name, without path or extention</param>
        /// <param name="xsltPath">The path to InstanceReport_XmlWorkbook.xslt</param>
        /// <param name="cssPath">The path to report.css</param>
        /// <returns></returns>
        public static bool GenerateExcelWorkbook(FilingSummary fs, string reportDirectory, string excelReportName)
        {
            if (!Directory.Exists(reportDirectory))
            {
                return(false);
            }


            try
            {
                SingleFileWorkbook sfwb = GenerateExcelWorkbook(fs, reportDirectory);

                string saveAt = Path.Combine(reportDirectory, excelReportName + ".xls");
                sfwb.SaveAs(saveAt);
                return(true);
            }
            catch { }

            return(false);
        }
Exemple #5
0
 /// <summary>
 /// Creates a new instance of the trace wrapper with <paramref
 /// name="fs"/> as the base.
 /// </summary>
 /// <param name="fs">The <see cref="FilingSummary"/> to use for
 /// creating the trace wrapper.</param>
 public FilingSummaryTraceWrapper(FilingSummary fs)
 {
     this.fs = fs;
     this.Attributes["switchValue"] = "All";
 }
Exemple #6
0
 public void PrependLogs(FilingSummary tmpFS)
 {
 }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportDirectory">The folder containing all reports (R1.xml, etc)</param>
        /// <param name="xsltPath">The path to InstanceReport_XmlWorkbook.xslt</param>
        /// <param name="cssPath">The path to report.css</param>
        /// <returns></returns>
        public static SingleFileWorkbook GenerateExcelWorkbook(FilingSummary myFilingSummary, string reportDirectory)
        {
            string cssPath  = RulesEngineUtils.GetResourcePath(RulesEngineUtils.ReportBuilderFolder.Resources, RulesEngineUtils.StylesheetFile);
            string xsltPath = RulesEngineUtils.GetResourcePath(RulesEngineUtils.ReportBuilderFolder.Resources, RulesEngineUtils.TransformWorkbookFile);

            XslCompiledTransform xslt = new XslCompiledTransform();

            xslt.Load(xsltPath);

            SingleFileWorkbook       sfwb       = new SingleFileWorkbook();
            Dictionary <string, int> sheetNames = new Dictionary <string, int>();

            //Process the R files. Each R File will be transformed into a worksheet in the workbook
            int idx = 0;

            foreach (ReportHeader reportHeader in myFilingSummary.MyReports)
            {
                if (reportHeader.ReportType == ReportHeaderType.Book)
                {
                    continue;
                }

                string reportPath = Path.Combine(reportDirectory, reportHeader.XmlFileName);
                if (!File.Exists(reportPath))
                {
                    Trace.TraceError(
                        "Error: An error occurred while creating the Excel Workbook.\n" +
                        "Sheet '" + reportHeader.ShortName + "' could not be loaded.\n" +
                        "Reason:\n\tFile not found."
                        );
                    continue;
                }

                try
                {
                    idx++;
                    string tmpPath = Path.GetTempFileName();

                    if (File.Exists(tmpPath + ".html"))
                    {
                        FileInfo fi = new FileInfo(tmpPath + ".html");
                        FileUtilities.DeleteFile(fi, true);
                    }

                    File.Move(tmpPath, tmpPath + ".html");
                    tmpPath += ".html";

                    xslt.Transform(reportPath, tmpPath);

                    SingleFileAttachment sfa = sfwb.AddAttachment(tmpPath);
                    sfa.UseName          = "Sheet" + idx.ToString("00") + ".html";
                    sfa.Name             = NameSheet(reportHeader.ShortName, sheetNames);
                    sheetNames[sfa.Name] = 1;
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning(
                        "Warning: An error occurred while creating the Excel Workbook.\n" +
                        "Sheet '" + reportHeader.ShortName + "' may be missing.\n" +
                        "Reason:\n\t" + ex.Message
                        );
                }
            }

            string[] charts = Directory.GetFiles(reportDirectory, "*.jpg");
            foreach (string chart in charts)
            {
                try
                {
                    SingleFileAttachment sfa = sfwb.AddAttachment(chart);
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning(
                        "Warning: An error occurred while creating the Excel Workbook.\n" +
                        "This attachment could not be embedded:\n\t" + Path.GetFileName(chart) +
                        "\nReason:\n\t" + ex.Message
                        );
                }
            }

            return(sfwb);
        }