Example #1
0
        public async Task AnalyzeAsync(DirectoryModel analyzeModel)
        {
            var content = await FileProvider.GetContentAsync();

            var parserResponse = new ParserFactory().Analyze(new ParserRequestModel(content));
            await ReportingService.ExportAsync(analyzeModel.OutputPath, parserResponse.ParserFileModels);
        }
        /// <summary>
        /// Represents the asynchronous entry point to the application, which allows us to use asynchorous methods.
        /// </summary>
        public static async Task MainAsync()
        {
            // Asks the user to specify a file name
            System.Console.Write("Specify file name (default is My Documents): ");
            string fileName = System.Console.ReadLine();
            if (string.IsNullOrWhiteSpace(fileName))
                fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Export.pdf");

            // Asks the user for his name
            System.Console.Write("What is your name: ");
            string documentAuthor = System.Console.ReadLine();

            // Creates the report, renders, and exports it
            System.Console.WriteLine("Generating document...");
            IIocContainer iocContainer = new SimpleIocContainer();
            ReportingService reportingService = new ReportingService(iocContainer);
            DocumentFormat documentFormat = Path.GetExtension(fileName).ToUpperInvariant() == ".XPS" ? DocumentFormat.Xps : DocumentFormat.Pdf;
            await reportingService.ExportAsync<Document>(documentFormat, fileName, string.IsNullOrWhiteSpace(documentAuthor) ? null : new { Author = documentAuthor });
            System.Console.WriteLine("Finished generating document");
            
            // Waits for a key stroke, before the application is quit
            System.Console.WriteLine("Press any key to quit...");
            System.Console.ReadKey();
        }