Best NBi code snippet using NBi.Core.Report.DatabaseReportingParser
DatabaseReportingParser.cs
Source:DatabaseReportingParser.cs
...6using System.Linq;7using System.Reflection;8namespace NBi.Core.Report9{10 public class DatabaseReportingParser : IReportingParser11 {12 public ReportingCommand ExtractCommand(ReportDataSetRequest request)13 {14 var otherDataSets = new List<string>();15 var query = SearchDataSet(16 request.Source17 , request.Path18 , request.ReportName19 , request.DataSetName20 , ref otherDataSets);21 if (query == null)22 {23 var reference = SearchSharedDataSet(24 request.Source...
DatabaseReportingParserTest.cs
Source:DatabaseReportingParserTest.cs
...7namespace NBi.Testing.Integration.Core.Report8{9 [TestFixture]10 [Category("ReportServerDB")]11 public class DatabaseReportingParserTest12 {13 private static bool isSqlServerStarted = false; 14 #region SetUp & TearDown15 //Called only at instance creation16 [OneTimeSetUp]17 public void SetupMethods()18 {19 isSqlServerStarted = CheckIfSqlServerStarted();20 }21 //Called only at instance destruction22 [OneTimeTearDown]23 public void TearDownMethods()24 {25 }26 //Called before each test27 [SetUp]28 public void SetupTest()29 {30 if (!isSqlServerStarted)31 Assert.Ignore("SQL Server not started.");32 }33 //Called after each test34 [TearDown]35 public void TearDownTest()36 {37 }38 private bool CheckIfSqlServerStarted()39 {40 var pname = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName.Contains("sqlservr"));41 return pname.Count() > 0;42 }43 #endregion44 [Test]45 public void ExtractQuery_ExistingReportAndDataSet_CorrectQueryReturned()46 {47 var request = new ReportDataSetRequest( 48 ConnectionStringReader.GetReportServerDatabase()49 , "/AdventureWorks Sample Reports/"50 , "Currency_List"51 ,"Currency" 52 );53 var parser = new DatabaseReportingParser();54 var query = parser.ExtractCommand(request);55 Assert.That(query.Text, 56 Does.Contain("SELECT").And57 .StringContaining("[CurrencyAlternateKey]").And58 .StringContaining("[DimCurrency]"));59 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));60 }61 [Test]62 public void ExtractQuery_NonExistingDataSetOneExisting_CorrectExceptionReturned()63 {64 var request = new ReportDataSetRequest(65 ConnectionStringReader.GetReportServerDatabase()66 , "/AdventureWorks Sample Reports/"67 , "Currency_List"68 , "Non Existing"69 );70 var parser = new DatabaseReportingParser();71 var ex = Assert.Throws<ArgumentException>(()=> parser.ExtractCommand(request));72 Assert.That(ex.Message, Does.Contain("'Currency_List'"));73 }74 [Test]75 public void ExtractQuery_NonExistingDataSetMoreThanOneExisting_CorrectExceptionReturned()76 {77 var request = new ReportDataSetRequest(78 ConnectionStringReader.GetReportServerDatabase()79 , "/AdventureWorks Sample Reports/"80 , "Currency Rates"81 , "Non Existing"82 );83 var parser = new DatabaseReportingParser();84 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));85 Assert.That(ex.Message, Does.Contain("DataSet1").And.StringContaining("DataSet2"));86 }87 [Test]88 public void ExtractQuery_NonExistingReport_CorrectExceptionReturned()89 {90 var request = new ReportDataSetRequest(91 ConnectionStringReader.GetReportServerDatabase()92 , "/AdventureWorks Sample Reports/"93 , "Not Existing"94 , "DataSet1"95 );96 var parser = new DatabaseReportingParser();97 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));98 Assert.That(ex.Message, Does.Contain("No report found"));99 }100 [Test]101 public void ExtractQuery_SharedDataSetViaReport_CorrectQuery()102 {103 var request = new ReportDataSetRequest(104 ConnectionStringReader.GetReportServerDatabase()105 , "/AdventureWorks Sample Reports/"106 , "Employee_Sales_Summary"107 , "EmpSalesMonth"108 );109 var parser = new DatabaseReportingParser();110 var query = parser.ExtractCommand(request);111 Assert.That(query.Text,112 Does.Contain("SELECT"));113 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));114 }115 [Test]116 public void ExtractQuery_NonExistingSharedDataSet_CorrectQuery()117 {118 var request = new ReportDataSetRequest(119 ConnectionStringReader.GetReportServerDatabase()120 , "/AdventureWorks Sample Reports/"121 , "Employee_Sales_Summary"122 , "NonExisting"123 );124 var parser = new DatabaseReportingParser();125 var ex = Assert.Throws<ArgumentException>(() => parser.ExtractCommand(request));126 Assert.That(ex.Message, Does.Contain("Quota").And.StringContaining("EmpSalesMonth"));127 }128 [Test]129 public void ExtractQuery_SharedDataSet_CorrectQuery()130 {131 var request = new SharedDatasetRequest(132 ConnectionStringReader.GetReportServerDatabase()133 , "/AdventureWorks Sample Reports/"134 , "EmpSalesMonth"135 );136 var parser = new DatabaseReportingParser();137 var query = parser.ExtractCommand(request);138 Assert.That(query.Text,139 Does.Contain("SELECT"));140 Assert.That(query.CommandType, Is.EqualTo(CommandType.Text));141 }142 }143}...
ReportingParserFactory.cs
Source:ReportingParserFactory.cs
...10 {11 if (string.IsNullOrWhiteSpace(source))12 return new FileReportingParser();13 else14 return new DatabaseReportingParser();15 }16 }17}...
DatabaseReportingParser
Using AI Code Generation
1using NBi.Core.Report;2using NBi.Core.Report.Dbf;3using System;4using System.Collections.Generic;5using System.IO;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 public DbfParser(string connectionString, string commandText)12 : base(connectionString, commandText)13 { }14 protected override IReportEngine GetEngine()15 {16 return new DbfEngine();17 }18 }19}20using NBi.Core.Report;21using NBi.Core.Report.Dbf;22using System;23using System.Collections.Generic;24using System.IO;25using System.Linq;26using System.Text;27using System.Threading.Tasks;28{29 {30 public override void Execute()31 {32 }33 }34}35using NBi.Core.Report;36using NBi.Core.Report.Dbf;37using System;38using System.Collections.Generic;39using System.IO;40using System.Linq;41using System.Text;42using System.Threading.Tasks;43{44 {45 public string ConnectionString { get; set; }46 public string CommandText { get; set; }47 public string ReportFile { get; set; }48 public string ReportName { get; set; }49 public DbfCommand(string connectionString, string commandText, string reportFile, string reportName)50 {51 ConnectionString = connectionString;52 CommandText = commandText;53 ReportFile = reportFile;54 ReportName = reportName;55 }56 }57}58using NBi.Core.Report;59using NBi.Core.Report.Dbf;60using System;61using System.Collections.Generic;62using System.IO;63using System.Linq;64using System.Text;65using System.Threading.Tasks;66{67 {68 public IDatabaseReportingCommand Instantiate(string connectionString, string commandText, string reportFile,
DatabaseReportingParser
Using AI Code Generation
1using NBi.Core.Report;2using NBi.Core.Report.Delimited;3using NBi.Core.Report.Excel;4using NBi.Core.Report.Html;5using NBi.Core.Report.PowerPoint;6using NBi.Core.Report.Word;7using System;8using System.Collections.Generic;9using System.IO;10using System.Linq;11using System.Text;12using System.Threading.Tasks;13{14 {15 static void Main(string[] args)16 {17 var path = @"C:\Users\kumar\Downloads\test.xlsx";18 var parser = new DatabaseReportingParser(new ExcelReportingParser(path));19 var result = parser.Execute();20 Console.WriteLine(result.Rows.Count);21 Console.ReadLine();22 }23 }24}25using NBi.Core.Report;26using NBi.Core.Report.Delimited;27using NBi.Core.Report.Excel;28using NBi.Core.Report.Html;29using NBi.Core.Report.PowerPoint;30using NBi.Core.Report.Word;31using System;32using System.Collections.Generic;33using System.IO;34using System.Linq;35using System.Text;36using System.Threading.Tasks;37{38 {39 static void Main(string[] args)40 {41 var path = @"C:\Users\kumar\Downloads\test.xlsx";42 var parser = new DatabaseReportingParser(new ExcelReportingParser(path));43 var result = parser.Execute();44 Console.WriteLine(result.Rows.Count);45 Console.ReadLine();46 }47 }48}49using NBi.Core.Report;50using NBi.Core.Report.Delimited;51using NBi.Core.Report.Excel;52using NBi.Core.Report.Html;53using NBi.Core.Report.PowerPoint;54using NBi.Core.Report.Word;55using System;56using System.Collections.Generic;57using System.IO;58using System.Linq;59using System.Text;60using System.Threading.Tasks;61{62 {63 static void Main(string[] args)64 {65 var path = @"C:\Users\kumar\Downloads\test.xlsx";66 var parser = new DatabaseReportingParser(new ExcelReportingParser(path));67 var result = parser.Execute();68 Console.WriteLine(result.Rows.Count);69 Console.ReadLine();70 }71 }72}
DatabaseReportingParser
Using AI Code Generation
1using NBi.Core.Report;2using NBi.Core.Report.Delimited;3using NBi.Core.Report.Excel;4using NBi.Core.Report.Html;5using NBi.Core.Report.Xml;6using NBi.Core.Report.Rdl;7using NBi.Core.Report.Tsv;8using NBi.Core.Report;9using NBi.Core.Report.Delimited;10using NBi.Core.Report.Excel;11using NBi.Core.Report.Html;12using NBi.Core.Report.Xml;13using NBi.Core.Report.Rdl;14using NBi.Core.Report.Tsv;15using NBi.Core.Report;16using NBi.Core.Report.Delimited;17using NBi.Core.Report.Excel;18using NBi.Core.Report.Html;19using NBi.Core.Report.Xml;20using NBi.Core.Report.Rdl;21using NBi.Core.Report.Tsv;22using NBi.Core.Report;23using NBi.Core.Report.Delimited;24using NBi.Core.Report.Excel;25using NBi.Core.Report.Html;26using NBi.Core.Report.Xml;27using NBi.Core.Report.Rdl;28using NBi.Core.Report.Tsv;29using NBi.Core.Report;30using NBi.Core.Report.Delimited;31using NBi.Core.Report.Excel;32using NBi.Core.Report.Html;33using NBi.Core.Report.Xml;34using NBi.Core.Report.Rdl;35using NBi.Core.Report.Tsv;36using NBi.Core.Report;37using NBi.Core.Report.Delimited;38using NBi.Core.Report.Excel;39using NBi.Core.Report.Html;40using NBi.Core.Report.Xml;41using NBi.Core.Report.Rdl;42using NBi.Core.Report.Tsv;43using NBi.Core.Report;44using NBi.Core.Report.Delimited;45using NBi.Core.Report.Excel;46using NBi.Core.Report.Html;47using NBi.Core.Report.Xml;48using NBi.Core.Report.Rdl;49using NBi.Core.Report.Tsv;50using NBi.Core.Report;51using NBi.Core.Report.Delimited;52using NBi.Core.Report.Excel;53using NBi.Core.Report.Html;
DatabaseReportingParser
Using AI Code Generation
1var parser = new DatabaseReportingParser();2var report = parser.Parse("SELECT * FROM [dbo].[Table1]");3var parser = new DatabaseReportingParser();4var report = parser.Parse("SELECT * FROM [dbo].[Table1]");5var parser = new DatabaseReportingParser();6var report = parser.Parse("SELECT * FROM [dbo].[Table1]");7var parser = new DatabaseReportingParser();8var report = parser.Parse("SELECT * FROM [dbo].[Table1]");9var parser = new DatabaseReportingParser();10var report = parser.Parse("SELECT * FROM [dbo].[Table1]");11var parser = new DatabaseReportingParser();12var report = parser.Parse("SELECT * FROM [dbo].[Table1]");13var parser = new DatabaseReportingParser();14var report = parser.Parse("SELECT * FROM [dbo].[Table1]");15var parser = new DatabaseReportingParser();16var report = parser.Parse("SELECT * FROM [dbo].[Table1]");17var parser = new DatabaseReportingParser();18var report = parser.Parse("SELECT * FROM [dbo].[Table1]");19var parser = new DatabaseReportingParser();20var report = parser.Parse("SELECT * FROM [dbo].[Table1]");21var parser = new DatabaseReportingParser();22var report = parser.Parse("SELECT * FROM [dbo].[Table1]");23var parser = new DatabaseReportingParser();24var report = parser.Parse("SELECT * FROM [dbo].[Table1]");
DatabaseReportingParser
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using NBi.Core.Report;7using NBi.Core.Report.Xml;8using NBi.Core.Report.Drillthrough;9using NBi.Core.Report.Drillthrough.Xml;10using NBi.Core.Report.Drillthrough.Execution;11using NBi.Core.Report.Drillthrough.Execution.Olap;12using NBi.Core.Report.Drillthrough.Execution.Csv;13using NBi.Core.Report.Drillthrough.Execution.Excel;14using NBi.Core.Report.Drillthrough.Execution.Html;15using NBi.Core.Report.Drillthrough.Execution.Json;16using NBi.Core.Report.Drillthrough.Execution.Pdf;17using NBi.Core.Report.Drillthrough.Execution.Powerpoint;18using NBi.Core.Report.Drillthrough.Execution.Rtf;
DatabaseReportingParser
Using AI Code Generation
1var parser = new DatabaseReportingParser();2var report = parser.Parse("C:\\temp\\report.rdl");3var connection = new SqlConnection("Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True");4var command = new SqlCommand("SELECT * FROM HumanResources.Employee", connection);5var adapter = new SqlDataAdapter(command);6var ds = new DataSet();7adapter.Fill(ds);8var result = report.Execute(ds.Tables[0]);9var sb = new StringBuilder();10var writer = new StringWriter(sb);11result.WriteXml(writer);12var xml = sb.ToString();13var parser = new DatabaseReportingParser();14var report = parser.Parse("C:\\temp\\report.rdl");15var connection = new SqlConnection("Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True");16var command = new SqlCommand("SELECT * FROM HumanResources.Employee", connection);17var adapter = new SqlDataAdapter(command);18var ds = new DataSet();19adapter.Fill(ds);20var result = report.Execute(ds.Tables[0]);21var sb = new StringBuilder();22var writer = new StringWriter(sb);23result.WriteXml(writer);24var xml = sb.ToString();25var parser = new DatabaseReportingParser();26var report = parser.Parse("C:\\temp\\report.rdl");27var connection = new SqlConnection("Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True");28var command = new SqlCommand("SELECT * FROM HumanResources.Employee", connection);29var adapter = new SqlDataAdapter(command);30var ds = new DataSet();31adapter.Fill(ds);32var result = report.Execute(ds.Tables[0]);33var sb = new StringBuilder();34var writer = new StringWriter(sb);35result.WriteXml(writer);36var xml = sb.ToString();37var parser = new DatabaseReportingParser();38var report = parser.Parse("C:\\temp\\report.rdl");39var connection = new SqlConnection("Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=True");40var command = new SqlCommand("SELECT * FROM HumanResources.Employee", connection);41var adapter = new SqlDataAdapter(command);42var ds = new DataSet();43adapter.Fill(ds);44var result = report.Execute(ds.Tables[0]);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!