How to use ExtractCommand method of NBi.Core.Report.DatabaseReportingParser class

Best NBi code snippet using NBi.Core.Report.DatabaseReportingParser.ExtractCommand

DatabaseReportingParser.cs

Source:DatabaseReportingParser.cs Github

copy

Full Screen

...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.Source25 , request.Path26 , request.ReportName27 , request.DataSetName28 , ref otherDataSets);29 if (!string.IsNullOrEmpty(reference))30 query = ReadQueryFromSharedDataSet(request.Source, request.Path, reference);31 }32 if (query != null)33 return query;34 if (otherDataSets.Count() == 0)35 throw new ArgumentException(string.Format("No report found on path '{0}' with name '{1}'", request.Path, request.ReportName));36 else if (otherDataSets.Count() == 1)37 throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The dataset for this report is {3}", request.Path, request.ReportName, request.DataSetName, otherDataSets[0]));38 else39 throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The datasets for this report are {3}", request.Path, request.ReportName, request.DataSetName, String.Join(", ", otherDataSets.ToArray())));40 }41 public ReportingCommand ExtractCommand(SharedDatasetRequest request)42 {43 var query = ReadQueryFromSharedDataSet(request.Source, request.Path, request.SharedDatasetName);44 if (query != null)45 return query;46 throw new ArgumentException(string.Format("The requested shared dataset ('{1}') wasn't found on path '{0}'.", request.Path, request.SharedDatasetName));47 }48 private ReportingCommand SearchDataSet(string source, string reportPath, string reportName, string dataSetName, ref List<string> otherDataSets)49 {50 using (var conn = new SqlConnection())51 {52 //create connection and define sql query53 conn.ConnectionString = source;54 var cmd = new SqlCommand();55 cmd.Connection = conn;...

Full Screen

Full Screen

DatabaseReportingParserTest.cs

Source:DatabaseReportingParserTest.cs Github

copy

Full Screen

...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}...

Full Screen

Full Screen

ExtractCommand

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 NBi.Core.Report.Html;10using NBi.Core.Report.Olap;11using NBi.Core.Report.PowerPoint;12using NBi.Core.Report.Projection;13using NBi.Core.Report.Rdl;14using NBi.Core.Report.Word;15{16 {17 static void Main(string[] args)18 {19 string reportPath = @"C:\Users\Public\Documents\NBi\Reports\1.rdl";20 string reportType = "rdl";21 string command = "select * from [MyCube].[MyDimension]";22 DatabaseReportingParser parser = new DatabaseReportingParser();23 var result = parser.ExtractCommand(reportPath, reportType, command);24 Console.WriteLine(result);25 Console.ReadLine();26 }27 }28}29using System;30using System.Collections.Generic;31using System.Linq;32using System.Text;33using System.Threading.Tasks;34using NBi.Core.Report;35using NBi.Core.Report.Delimited;36using NBi.Core.Report.Excel;37using NBi.Core.Report.Html;38using NBi.Core.Report.Olap;39using NBi.Core.Report.PowerPoint;40using NBi.Core.Report.Projection;41using NBi.Core.Report.Rdl;42using NBi.Core.Report.Word;43{44 {45 static void Main(string[] args)46 {47 string reportPath = @"C:\Users\Public\Documents\NBi\Reports\2.xlsx";48 string reportType = "excel";49 string command = "select * from [MyCube].[MyDimension]";50 DatabaseReportingParser parser = new DatabaseReportingParser();51 var result = parser.ExtractCommand(reportPath, reportType, command);52 Console.WriteLine(result);53 Console.ReadLine();54 }55 }56}57using System;58using System.Collections.Generic;59using System.Linq;60using System.Text;61using System.Threading.Tasks;62using NBi.Core.Report;63using NBi.Core.Report.Delimited;64using NBi.Core.Report.Excel;65using NBi.Core.Report.Html;

Full Screen

Full Screen

ExtractCommand

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 NBi.Core.Report.Html;10using NBi.Core.Report.Pivot;11using NBi.Core.Report.PowerPoint;12using NBi.Core.Report.Word;13using NBi.Core.Report.Xml;14using NBi.Core.Report.Csv;15{16 {17 static void Main(string[] args)18 {19 IReportParser parser = new DatabaseReportingParser();20 string filePath = @"C:\NBi\report.rdl";21 string command = "select * from [dbo].[table]";22 ReportType reportType = ReportType.Rdl;23 var result = parser.ExtractCommand(filePath, command, reportType);24 Console.WriteLine(result);25 Console.ReadLine();26 }27 }28}

Full Screen

Full Screen

ExtractCommand

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.Query;8using NBi.Core.Query.Command;9using NBi.Core.Query.Client;10using NBi.Core.Query.Resolver;11using NBi.Core.Query.Resolver.CommandBuilder;12using NBi.Core.Query.Resolver.Csv;13using NBi.Core.Query.Resolver.Csv.MsBiff;14using NBi.Core.Query.Resolver.Csv.MsBiff.Excel;15using System.Data;16using System.Data.OleDb;17using System.Data.SqlClient;18using System.IO;19using System.Diagnostics;20using System.Xml;21using System.Xml.Linq;22using System.Xml.Serialization;23using NBi.Core.Report;24{25 {26 static void Main(string[] args)27 {28 string reportPath = @"C:\Users\mohammad\Desktop\Report.rdl";29 string connectionString = @"Data Source=.\SQL2012;Initial Catalog=AdventureWorks;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False";30 string commandText = "SELECT * FROM [Production].[Product]";31 var reportParser = new DatabaseReportingParser();32 var command = reportParser.ExtractCommand(reportPath, connectionString, commandText);33 Console.WriteLine(command.CommandText);

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Report;2using NBi.Core.Report.Rendering;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 static void Main(string[] args)11 {12 var parser = new DatabaseReportingParser();13 var command = parser.ExtractCommand("C:\\Report.rdl");14 Console.WriteLine(command);15 Console.ReadKey();16 }17 }18}

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Report;2using NBi.Core.Scalar.Resolver;3using System;4using System.Collections.Generic;5using System.Data;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 static void Main(string[] args)12 {13 var connectionString = new ConnectionStringResolver("Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=True");14 var parser = new DatabaseReportingParser(connectionString);15 var command = parser.ExtractCommand("SELECT * FROM Production.Product");16 var adapter = new System.Data.SqlClient.SqlDataAdapter(command as System.Data.SqlClient.SqlCommand);17 var ds = new DataSet();18 adapter.Fill(ds);19 Console.WriteLine(ds.Tables[0].Rows[0][0]);20 }21 }22}23using NBi.Core.Report;24using NBi.Core.Scalar.Resolver;25using System;26using System.Collections.Generic;27using System.Data;28using System.Linq;29using System.Text;30using System.Threading.Tasks;31{32 {33 static void Main(string[] args)34 {35 var connectionString = new ConnectionStringResolver("Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=True");36 var parser = new DatabaseReportingParser(connectionString);37 var command = parser.ExtractCommand("SELECT * FROM Production.Product");38 var adapter = new System.Data.SqlClient.SqlDataAdapter(command as System.Data.SqlClient.SqlCommand);39 var ds = new DataSet();40 adapter.Fill(ds);41 Console.WriteLine(ds.Tables[0].Rows[0][0]);42 }43 }44}

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Report;2using System;3using System.Collections.Generic;4using System.Data;5using System.Data.SqlClient;6using System.Linq;7using System.Text;8using System.Threading.Tasks;9{10 {11 public void ExtractCommand()12 {13 var connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";14 var commandText = "SELECT * FROM [Production].[Product]";15 var parser = new DatabaseReportingParser();16 var command = parser.ExtractCommand(connectionString, commandText);17 Console.WriteLine(command.CommandText);18 Console.WriteLine(command.Connection.ConnectionString);19 }20 }21}22using NBi.Core.Report;23using System;24using System.Collections.Generic;25using System.Data;26using System.Data.SqlClient;27using System.Linq;28using System.Text;29using System.Threading.Tasks;30{31 {32 public void ExtractCommand()33 {34 var connectionString = "Data Source=.;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";35 var commandText = "SELECT * FROM [Production].[Product]";36 var parser = new DatabaseReportingParser();37 var command = parser.ExtractCommand(connectionString, commandText);38 Console.WriteLine(command.CommandText);39 Console.WriteLine(command.Connection.ConnectionString);40 }41 }42}43Assembly: NBi.Core (in NBi.Core.dll)44public SqlCommand ExtractCommand(string connectionString, string commandText)45Public Function ExtractCommand(connectionString As String, commandText As String) As SqlCommand46SqlCommand^ ExtractCommand(String^ connectionString, String^ commandText)

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1using NBi.Core.Report;2using NBi.Core.Report.Delimited;3using System;4using System.Collections.Generic;5using System.Linq;6using System.Text;7using System.Threading.Tasks;8{9 {10 static void Main(string[] args)11 {12 var parser = new DatabaseReportingParser();13 var output = parser.ExtractCommand(@"C:\Users\Public\Documents\NUnit Projects\NBi.Testing.Core.Report.Delimited\1.rdl");14 Console.WriteLine(output);15 Console.ReadLine();16 }17 }18}19using NBi.Core.Report;20using NBi.Core.Report.Excel;21using System;22using System.Collections.Generic;23using System.Linq;24using System.Text;25using System.Threading.Tasks;26{27 {28 static void Main(string[] args)29 {30 var parser = new ExcelReportingParser();31 var output = parser.ExtractCommand(@"C:\Users\Public\Documents\NUnit Projects\NBi.Testing.Core.Report.Excel\1.xlsx");32 Console.WriteLine(output);33 Console.ReadLine();34 }35 }36}37using NBi.Core.Report;38using NBi.Core.Report.PowerPoint;39using System;40using System.Collections.Generic;41using System.Linq;42using System.Text;43using System.Threading.Tasks;44{45 {46 static void Main(string[] args)47 {48 var parser = new PowerPointReportingParser();49 var output = parser.ExtractCommand(@"C:\Users\Public\Documents\NUnit Projects\NBi.Testing.Core.Report.PowerPoint\1.pptx");50 Console.WriteLine(output);51 Console.ReadLine();52 }53 }54}55using NBi.Core.Report;56using NBi.Core.Report.Word;57using System;58using System.Collections.Generic;59using System.Linq;60using System.Text;61using System.Threading.Tasks;62{63 {64 static void Main(string[] args)65 {

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1var reportParser = new NBi.Core.Report.DatabaseReportingParser();2var command = reportParser.ExtractCommand(reportPath, reportName, parameters);3var connectionString = "my connection string";4var connection = new System.Data.SqlClient.SqlConnection(connectionString);5var command = new System.Data.SqlClient.SqlCommand("my sql command", connection);6var adapter = new NBi.NUnit.Query.DbCommandAdapter(command);7var resultSet = new NBi.NUnit.ResultSet.ResultSetComparison();8resultSet.Setup(new NBi.Xml.Constraints.ResultSetComparisonXml()9{10 ResultSet = new NBi.Xml.Items.ResultSetXml()11 {12 Columns = new System.Collections.Generic.List<NBi.Xml.Items.ColumnDefinitionXml>()13 {14 new NBi.Xml.Items.ColumnDefinitionXml()15 {16 },17 new NBi.Xml.Items.ColumnDefinitionXml()18 {19 }20 }21 }22});23var assertion = new NBi.NUnit.Query.DbCommandAssertion(adapter, resultSet);24var result = assertion.Execute();25var reportParser = new NBi.Core.Report.DatabaseReportingParser();26var command = reportParser.ExtractCommand(reportPath, reportName, parameters);27var connectionString = "my connection string";28var connection = new System.Data.SqlClient.SqlConnection(connectionString);29var command = new System.Data.SqlClient.SqlCommand("my sql command", connection);30var adapter = new NBi.NUnit.Query.DbCommandAdapter(command);31var resultSet = new NBi.NUnit.ResultSet.ResultSetComparison();32resultSet.Setup(new NBi.Xml.Constraints.ResultSetComparisonXml()33{34 ResultSet = new NBi.Xml.Items.ResultSetXml()35 {36 Columns = new System.Collections.Generic.List<NBi.Xml.Items.ColumnDefinitionXml>()37 {38 new NBi.Xml.Items.ColumnDefinitionXml()39 {40 },41 new NBi.Xml.Items.ColumnDefinitionXml()42 {43 }44 }45 }46});

Full Screen

Full Screen

ExtractCommand

Using AI Code Generation

copy

Full Screen

1using System;2using System.IO;3using System.Text;4using System.Text.RegularExpressions;5using System.Collections.Generic;6using System.Linq;7using System.Xml;8using System.Xml.Linq;9using NBi.Core.Report;10{11 {12 static void Main(string[] args)13 {14WHERE ([DimDate].[DayNumberOfYear] > 2) AND ([DimDate].[DayNumberOfYear] < 4)";15 var parser = new DatabaseReportingParser();16 var testSuite = parser.ExtractCommand(sql);17 Console.WriteLine(testSuite);18 Console.ReadLine();19 }20 }21}

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful