public ReportGenerator(Client client)
        {
            // get values from web.config
            // template
            NameValueCollection appSettings = (NameValueCollection)ConfigurationManager.GetSection("appSettings");
            string templateFile = appSettings["TemplateFile"];
            TemplateFile = HttpContext.Current.Server.MapPath(sourceDir + "templates\\" + templateFile);
            //content file
            string contentFile = appSettings["ContentFile"];
            ContentXmlFile = HttpContext.Current.Server.MapPath(sourceDir + contentFile);
            //temp directory
            string tempDir = appSettings["TempDir"];

            if (tempDir != null && Directory.Exists(tempDir))
                TempDir = tempDir;
            else
                TempDir = Environment.GetEnvironmentVariable("temp");

            // source files
            TempContentXmlFile = tempDir + "\\content_temp.xml";
            ReportSpecFile = HttpContext.Current.Server.MapPath(sourceDir + "report-spec.xml");

            // directly fill Content Controls?
            FillContentControls = Boolean.Parse(appSettings["FillContentControls"] ?? "true");

            Client = client;
            Report = new Report(ReportSpecFile) { Client = Client };
        }
Example #2
0
        public void CreateReport(MainDocumentPart mainPart, Report report)
        {
            TextContent tc = new TextContent();
            tc.GenerateTextContent(mainPart, report.Client, contentSourceXml);

            ChartItem chartItem = null;
            string controlName = null;

            // Model Table
            Table table = report.ModelTable();
            controlName = "ModelTable";
            AddTableToDoc(mainPart, table, controlName);

            // Drawdown
            chartItem = report.Drawdown();
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Comparison Chart
            if (report.Client.ExistingAssets) {
                chartItem = report.AllocationComparison();
                controlName = chartItem.CustomControlName;
                AddChartToDoc(mainPart, chartItem, controlName);
            }

            // Stress Test Market Rise Bar Chart
            chartItem = report.StressTestMarketRise();
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Stress Test Market Crash Bar Chart
            chartItem = report.StressTestMarketCrash();
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Allocation Pie Chart
            chartItem = report.Allocation();
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Rolling Return 1 yr
            chartItem = report.RollingReturnChart(1);
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Rolling Return 3 yr
            chartItem = report.RollingReturnChart(3);
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Rolling Return 5 yr
            chartItem = report.RollingReturnChart(5);
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // Ten Year Return Chart
            chartItem = report.TenYearReturn();
            controlName = chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // save and close document
            mainPart.Document.Save();
        }
Example #3
0
        static void Main(string[] args)
        {
            Program This = new Program();

            File.Copy(sourceFile, generated, true);
            Report report = new Report();
            WordprocessingDocument myWordDoc = WordprocessingDocument.Open(generated, true);
            MainDocumentPart mainPart = myWordDoc.MainDocumentPart;

            This.CreateReportTest(mainPart, report);
            myWordDoc.Close();
            return;

            // create test Client and Report
            //Guid guid = new Guid("636c8103-e06d-4575-aafc-574474c2d7f8");
            //Client client = Client.GetClientByGUID(guid);
            //Report report = new Report() { Client = client };

            //// copy template to generated
            ////File.Copy(template, generated, true);
            //string tempDoc = createTempDocFile(sourceFile);

            //// open Word document
            //WordprocessingDocument myWordDoc = WordprocessingDocument.Open(tempDoc, true);
            //MainDocumentPart mainPart = myWordDoc.MainDocumentPart;

            ////This.InsertAllocationPie(mainPart);
            //This.CreateReport(mainPart, report);

            //myWordDoc.Close();
        }
Example #4
0
        public void CreateReportTest(MainDocumentPart mainPart, Report report)
        {
            ChartItem chartItem = null;
            string controlName = null;

            // data
            var model = new List<AssetWeighting>();
            model.Add(new AssetWeighting { AssetClass = "1st Qtr", Weighting = 8.2 });
            model.Add(new AssetWeighting { AssetClass = "2nd Qtr", Weighting = 3.2 });
            model.Add(new AssetWeighting { AssetClass = "3rd Qtr", Weighting = 1.4 });
            model.Add(new AssetWeighting { AssetClass = "4th Qtr", Weighting = 1.2 });

            //var m = new List<ReturnData>();
            //int startDate = 35944;
            //double val = 100;

            //for (int i = 0; i < 30; i++) {
            //    m.Add(new ReturnData { Date = startDate, Value = val++ });
            //    startDate += 30;
            //}

            string ssTest = path + "GraphDataCompare.xlsx";

            // Test Graph
            chartItem = report.ExcelChart(model);
            chartItem.GraphData.Close();
            chartItem.GraphData.WriteSpreadSheetToFile(ssTest);

            controlName = "ExcelChart"; // chartItem.CustomControlName;
            AddChartToDoc(mainPart, chartItem, controlName);

            // save and close document
            mainPart.Document.Save();
        }
        private void AddChartsToDoc(MainDocumentPart mainPart, Report report)
        {
            string controlName = null;
            ChartItem chartItem = null;

            // Allocation Pie Chart
            chartItem = report.Allocation();
            AddChartToDoc(mainPart, chartItem);

            // Comparison Chart
            if (report.Client.ExistingAssets) {
                chartItem = report.AllocationComparison();
                AddChartToDoc(mainPart, chartItem);
            } else {
                controlName = report.GetContentControlNameForChart("allocation-comparison");
                RemoveContentControlFromBlock(mainPart, controlName);
            }

            // Drawdown
            chartItem = report.Drawdown();
            AddChartToDoc(mainPart, chartItem);

            // Ten Year Return Chart
            chartItem = report.TenYearReturn();
            AddChartToDoc(mainPart, chartItem);

            // Stress Test Market Rise Bar Chart
            chartItem = report.StressTestMarketRise();
            AddChartToDoc(mainPart, chartItem);

            // Stress Test Market Crash Bar Chart
            chartItem = report.StressTestMarketCrash();
            AddChartToDoc(mainPart, chartItem);

            // Rolling Return 1 yr
            chartItem = report.RollingReturnChart(1);
            AddChartToDoc(mainPart, chartItem);

            // Rolling Return 3 yr
            chartItem = report.RollingReturnChart(3);
            AddChartToDoc(mainPart, chartItem);

            // Rolling Return 5 yr
            chartItem = report.RollingReturnChart(5);
            AddChartToDoc(mainPart, chartItem);
        }
Example #6
0
 public TextContent(Report report)
 {
     Report = report;
     Client = Report.Client;
 }