How to use FileReportingParser class of NBi.Core.Report package

Best NBi code snippet using NBi.Core.Report.FileReportingParser

FileReportingParserTest.cs

Source:FileReportingParserTest.cs Github

copy

Full Screen

...7using System.Data;8namespace NBi.Testing.Core.Report9{10 [TestFixture]11 public class FileReportingParserTest12 {13 private string ReportFileDirectory { get; set; }14 #region SetUp & TearDown15 //Called only at instance creation16 [OneTimeSetUp]17 public void SetupMethods()18 {19 CreateReportFile("Currency_List");20 CreateReportFile("Currency_List - SProc");21 CreateReportFile("Currency_Rates");22 CreateReportFile("Employee_Sales_Summary");23 CreateSharedDataSet("EmployeeSalesDetail");24 CreateSharedDataSet("EmployeeSalesYearOverYear");25 CreateSharedDataSet("EmpSalesMonth");26 CreateSharedDataSet("SalesEmployees");27 }28 //Called only at instance destruction29 [OneTimeTearDown]30 public void TearDownMethods()31 {32 }33 //Called before each test34 [SetUp]35 public void SetupTest()36 {37 38 }39 //Called after each test40 [TearDown]41 public void TearDownTest()42 {43 }44 #endregion45 protected void CreateReportFile(string filename)46 {47 string file = @"\Temp\" + filename + ".rdl";48 var resource = "NBi.Testing.Core.Report.Resources." + filename + ".rdl";49 var physicalFilename = FileOnDisk.CreatePhysicalFile(file, resource);50 ReportFileDirectory = Path.GetDirectoryName(physicalFilename) + Path.DirectorySeparatorChar.ToString();51 }52 protected void CreateSharedDataSet(string filename)53 {54 string file = @"\Temp\" + filename + ".rsd";55 var resource = "NBi.Testing.Core.Report.Resources." + filename + ".rsd";56 var physicalFilename = FileOnDisk.CreatePhysicalFile(file, resource);57 ReportFileDirectory = Path.GetDirectoryName(physicalFilename) + Path.DirectorySeparatorChar.ToString();58 }59 [Test]60 public void ExtractQuery_ExistingReportAndDataSet_CorrectQueryReturned()61 {62 var request = new ReportDataSetRequest(63 string.Empty64 , ReportFileDirectory65 , "Currency_List"66 , "Currency"67 );68 var parser = new FileReportingParser();69 var query = parser.ExtractCommand(request);70 Assert.That(query.Text,71 Does.Contain("SELECT").And72 .Contain("[CurrencyAlternateKey]").And73 .Contain("[DimCurrency]"));74 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));75 }76 [Test]77 public void ExtractQuery_NonExistingDataSetOneExisting_CorrectExceptionReturned()78 {79 var request = new ReportDataSetRequest(80 string.Empty81 , ReportFileDirectory82 , "Currency_List"83 , "Non Existing"84 );85 var parser = new FileReportingParser();86 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));87 Assert.That(ex.Message, Does.Contain("'Currency'"));88 }89 [Test]90 public void ExtractQuery_NonExistingDataSetMoreThanOneExisting_CorrectExceptionReturned()91 {92 var request = new NBi.Core.Report.ReportDataSetRequest(93 string.Empty94 , ReportFileDirectory95 , "Currency_Rates"96 , "Non Existing"97 );98 var parser = new FileReportingParser();99 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));100 Assert.That(ex.Message, Does.Contain("DataSet1").And.Contain("DataSet2"));101 }102 [Test]103 public void ExtractQuery_NonExistingReport_CorrectExceptionReturned()104 {105 var request = new NBi.Core.Report.ReportDataSetRequest(106 string.Empty107 , ReportFileDirectory108 , "Not Existing"109 , "DataSet1"110 );111 var parser = new FileReportingParser();112 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));113 Assert.That(ex.Message, Does.Contain("No report found"));114 }115 [Test]116 public void ExtractQuery_ExistingReportAndSharedDataSet_CorrectQueryReturned()117 {118 var request = new NBi.Core.Report.ReportDataSetRequest(119 string.Empty120 , ReportFileDirectory121 , "Employee_Sales_Summary"122 , "SalesEmployees2008R2"123 );124 var parser = new FileReportingParser();125 var query = parser.ExtractCommand(request);126 Assert.That(query.Text,127 Does.Contain("SELECT").And128 .Contain("[Sales].[SalesPerson]").And129 .Contain("[HumanResources].[Employee]"));130 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));131 }132 [Test]133 public void ExtractQuery_ExistingSharedDataSet_CorrectQueryReturned()134 {135 var request = new SharedDatasetRequest(136 string.Empty137 , ReportFileDirectory138 , "SalesEmployees"139 );140 var parser = new FileReportingParser();141 var query = parser.ExtractCommand(request);142 Assert.That(query.Text,143 Does.Contain("SELECT").And144 .Contain("[Sales].[SalesPerson]").And145 .Contain("[HumanResources].[Employee]"));146 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));147 }148 [Test]149 public void ExtractSProc_ExistingReport_CorrectSProcReturned()150 {151 var request = new NBi.Core.Report.ReportDataSetRequest(152 string.Empty153 , ReportFileDirectory154 , "Currency_List - SProc"155 , "Currency"156 );157 var parser = new FileReportingParser();158 var query = parser.ExtractCommand(request);159 Assert.That(query.Text,160 Is.EqualTo("usp_CurrencyGetAll"));161 Assert.That(query.CommandType, Is.EqualTo(CommandType.StoredProcedure));162 }163 }164}...

Full Screen

Full Screen

FileReportingParser.cs

Source:FileReportingParser.cs Github

copy

Full Screen

...5using System.Linq;6using System.Xml;7namespace NBi.Core.Report8{9 class FileReportingParser : IReportingParser10 {11 public ReportingCommand ExtractCommand(ReportDataSetRequest request)12 {13 var reportName = request.ReportName.EndsWith(".rdl") ? request.ReportName : request.ReportName + ".rdl";14 var fullPath = string.Format("{0}{1}{2}", request.Source, request.Path, reportName);15 if (!File.Exists(fullPath))16 throw new ArgumentException(string.Format("No report found on path '{0}{1}' with name '{2}'", request.Source, request.Path, request.ReportName));17 //Load the xml18 var docXml = new XmlDocument();19 docXml.Load(fullPath);20 var root = docXml.FirstChild;21 if (root.NodeType == XmlNodeType.XmlDeclaration)22 root = root.NextSibling;23 //Check that the data set exist...

Full Screen

Full Screen

ReportingParserFactory.cs

Source:ReportingParserFactory.cs Github

copy

Full Screen

...8 {9 public virtual IReportingParser Instantiate(string source)10 {11 if (string.IsNullOrWhiteSpace(source))12 return new FileReportingParser();13 else14 return new DatabaseReportingParser();15 }16 }17}...

Full Screen

Full Screen

FileReportingParser

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using System.IO;8{9 {10 static void Main(string[] args)11 {12 var report = new FileReportingParser();13 report.Parse(new FileInfo("C:\\Temp\\test.rdl"));14 Console.WriteLine(report.ReportName);15 Console.WriteLine(report.ReportPath);16 Console.WriteLine(report.DataSources.Count);17 Console.WriteLine(report.DataSources[0].Name);18 Console.WriteLine(report.DataSources[0].Extension);19 Console.WriteLine(report.DataSources[0].ConnectionString);20 Console.WriteLine(report.DataSources[0].ConnectionProperties.Count);21 Console.WriteLine(report.DataSources[0].ConnectionProperties[0].Name);22 Console.WriteLine(report.DataSources[0].ConnectionProperties[0].Value);23 Console.WriteLine(report.DataSources[0].ConnectionProperties[1].Name);24 Console.WriteLine(report.DataSources[0].ConnectionProperties[1].Value);25 Console.WriteLine(report.DataSources[0].ConnectionProperties[2].Name);26 Console.WriteLine(report.DataSources[0].ConnectionProperties[2].Value);27 }28 }29}30Data Source=(local)\SQL2012;Initial Catalog=AdventureWorks;Integrated Security=True31Sudhakar Kandula is a Microsoft BI Consultant with 10+ years of experience in Microsoft BI tools and technologies. He is a Microsoft Certified Professional (MCP) and Microsoft Certified Technology Specialist (MCTS) in SQL Server 2008. He is also a certified Microsoft Certified Trainer (MCT) and Microsoft Certified Trainer (MCT) for SQL Server 2008. He has presented sessions on SQL Server BI technologies at various user groups and SQL Saturdays. He is also a Microsoft Data Platform MVP. You can find him on Twitter @

Full Screen

Full Screen

FileReportingParser

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using NBi.Core.Report.Delimited;8using NBi.Core.Report.Excel;9using System.IO;10using System.Data;11using System.Data.OleDb;12using System.Data.SqlClient;13using System.Data.Common;14using System.Configuration;15{16 {17 static void Main(string[] args)18 {19 string excelReportFilePath = @"C:\Users\username\Downloads\Report.xlsx";20 string outputFilePath = @"C:\Users\username\Downloads\Output.txt";21 string outputFilePath2 = @"C:\Users\username\Downloads\Output2.txt";22 string outputFilePath3 = @"C:\Users\username\Downloads\Output3.txt";23 string outputFilePath4 = @"C:\Users\username\Downloads\Output4.txt";24 string outputFilePath5 = @"C:\Users\username\Downloads\Output5.txt";25 string outputFilePath6 = @"C:\Users\username\Downloads\Output6.txt";26 string outputFilePath7 = @"C:\Users\username\Downloads\Output7.txt";27 string outputFilePath8 = @"C:\Users\username\Downloads\Output8.txt";28 string outputFilePath9 = @"C:\Users\username\Downloads\Output9.txt";29 string outputFilePath10 = @"C:\Users\username\Downloads\Output10.txt";30 string outputFilePath11 = @"C:\Users\username\Downloads\Output11.txt";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run NBi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in FileReportingParser

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful