private void btnInitialize_Click(object sender, EventArgs e) { _dict = new Mdx(txtDictFile.Text); _dict.GetStyleSheets(); _dict.GetKeys(); _dict.IgnoreKeys(); _dict.GetRecordBlocksInfo(); MessageBox.Show(@"Ok well done!", @"Done", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void FluentWay() { var query = Mdx.Query() .On(Mdx.Axis(0).AsNonEmpty() .WithSlicer(Mdx.Tuple() .With(Mdx.Member("Dim Hierarchy", "Dim")))) .From(Mdx.Cube("Cube")) .Where(Mdx.Tuple() .With(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key") .WithValue("1"))); }
public void CreateQuery_WithSimpleWhereClause_QueryCreatedAsExpected() { const string expectedQueryString = "SELECT " + "NON EMPTY { [Dim Hierarchy].[Dim] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( [Dim Hierarchy].[Dim].[Dim Key].&[1] ) } ) }"; var query = Mdx.Query() .On(Mdx.Axis(0).WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim"))).AsNonEmpty()) .From(Mdx.Cube("Cube")) .Where(Mdx.Tuple().With(Mdx.Set().With(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key").WithValue("1")))); query.ToString().Should().Be(expectedQueryString); }
public void CreateQuery_WithFunctionAndDifferentExpressions_QueryCreatedAsExpected() { const string expectedQueryString = "SELECT { [Dim Hierarchy].[Dim] } ON Columns " + "FROM [Cube] " + "WHERE { ( { FILTER([Dim Hierarchy].[Dim].[Dim Key], { [Dim Hierarchy].[Dim].[Dim Key] }) } ) }"; var query = Mdx.Query() .On(Mdx.Axis().WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim")))) .From(Mdx.Cube("Cube")) .Where(Mdx.Tuple().With( Mdx.Function("FILTER") .WithParameters(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key")) .WithParameters(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key"))))); query.ToString().Should().Be(expectedQueryString); }
public void CreateQuery_WithMultipleAxesAndWhereClause_QueryCreatedAsExpected() { const string expectedQueryString = "SELECT " + "{ [Dim1 Hierarchy].[Dim1] } ON Columns, " + "{ [Dim2 Hierarchy].[Dim2] } DIMENSION PROPERTIES CHILDREN_CARDINALITY ON Rows " + "FROM [Cube] " + "WHERE { ( { ( [Dim2 Hierarchy].[Dim2].[Dim2 Key].&[1] ) } ) }"; var query = Mdx.Query() .On(Mdx.Axis(0).AsEmpty().WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim1 Hierarchy", "Dim1")))) .On(Mdx.Axis(1).AsEmpty().WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim2 Hierarchy", "Dim2"))).WithProperties("CHILDREN_CARDINALITY")) .From(Mdx.Cube("Cube")) .Where(Mdx.Tuple().With(Mdx.Set().With(Mdx.Member("Dim2 Hierarchy", "Dim2", "Dim2 Key").WithValue("1")))); query.ToString().Should().Be(expectedQueryString); }
public void AppendQuery_OneWhere_ExtendedWhereClause() { const string initialQueryString = "SELECT { [MyMember] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( [Test].[Test Name].&[test] ) }) }"; const string expectedQueryString = "SELECT { [MyMember] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( { ( [Test].[Test Name].&[test] ) } ) }, { [Company].[Company Name].&[test] } ) }"; var mdxQuery = new MdxParser().ParseQuery(initialQueryString); mdxQuery.Where(Mdx.Tuple().With(Mdx.Member("Company", "Company Name").WithValue("test"))); mdxQuery.ToString().Should().Be(expectedQueryString); }
public void getPdxForFile(string pFileName, TextBox pOutputWindow, TreeNode pParentNode, bool pCheckExists) { string pdxPath = null; // get PDX file Mdx mdx = getMdxForFile(pFileName); string pdxFileName = mdx.PdxFileName; if (pdxFileName != null && pdxFileName != String.Empty) { // add file extension if needed if (!pdxFileName.EndsWith(Mdx.PDX_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase)) { pdxFileName += Mdx.PDX_FILE_EXTENSION; } // build PDX path pdxPath = Path.Combine(Path.GetDirectoryName(pFileName), pdxFileName); if (!pdxHash.ContainsKey(pdxPath)) { // Add to hash pdxHash.Add(pdxPath, pdxPath); if (pCheckExists) { pOutputWindow.Text += pdxPath; if (File.Exists(pdxPath)) { pOutputWindow.Text += " (Found)"; } else { pOutputWindow.Text += " (Not Found)"; } } else { pOutputWindow.Text += pdxFileName; } pOutputWindow.Text += Environment.NewLine; } } buildMdxTreeNode(mdx, pFileName, pParentNode); }
public Mdx getMdxForFile(string pFileName) { Mdx ret = null; FileInfo fi = new FileInfo(pFileName); if (fi.Exists && fi.Extension.Equals(Mdx.MDX_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase)) { FileStream fs = File.OpenRead(pFileName); byte[] data = new byte[fs.Length]; FileUtil.ReadWholeArray(fs, data); fs.Close(); fs.Dispose(); Mdx mdx = new Mdx(data); ret = mdx; } return(ret); }
public void AppendQuery_OneWhere_ExtendedWhereClause() { //ARRANGE const string initialQueryString = "SELECT { [MyMember] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( [Test].[Test Name].&[test] ) }) }"; const string expectedQueryString = "SELECT { [MyMember] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( { ( [Test].[Test Name].&[test] ) } ) }, { [Company].[Company Name].&[test] } ) }"; //ACT var mdxQuery = new MdxParser().ParseQuery(initialQueryString); mdxQuery.Where(Mdx.Tuple().With(Mdx.Member("Company", "Company Name").WithValue("test"))); //ASSERT Assert.That(mdxQuery.ToString(), Is.EqualTo(expectedQueryString)); }
public void CreateQuery_WithDeclaredMemberAndSet_QueryCreatedAsExpected() { const string expectedQueryString = "WITH " + "MEMBER [MyMember] AS [Dim Hierarchy].[Dim] " + "SET [MySet] AS { FILTER([Dim Hierarchy].[Dim].[Dim Key], { [Dim Hierarchy].[Dim].[Dim Key] }) } " + "SELECT { [MyMember] } ON Columns " + "FROM [Cube] " + "WHERE { ( { ( [MySet] ) } ) }"; var query = Mdx.Query() .With(Mdx.DeclaredMember("MyMember").As(Mdx.Expression().WithOperand(Mdx.Member("Dim Hierarchy", "Dim")))) .With(Mdx.DeclaredSet("MySet").As(Mdx.Tuple().With(Mdx.Function("FILTER") .WithParameters(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key")) .WithParameters(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key")))))) .On(Mdx.Axis(0).WithSlicer(Mdx.Tuple().With(Mdx.Member("MyMember")))) .From(Mdx.Cube("Cube")) .Where(Mdx.Tuple().With(Mdx.Set().With(Mdx.Member("MySet")))); query.ToString().Should().Be(expectedQueryString); }
public void CreateQuery_WithMultipleCubesAndRangeWhereClause_QueryCreatedAsExpected() { //ARRANGE const string expectedQueryString = "SELECT " + "NON EMPTY { [Dim Hierarchy].[Dim] } ON Columns " + "FROM [Cube1], [Cube2], [Cube3] " + "WHERE { ( { ( [Dim Hierarchy].[Dim].[Dim Key].&[1]:[Dim Hierarchy].[Dim].[Dim Key].&[4] ) } ) }"; //ACT var query = Mdx.Query() .On(Mdx.Axis(0).AsNonEmpty().WithSlicer(Mdx.Tuple().With(Mdx.Member("Dim Hierarchy", "Dim")))) .From(Mdx.Cube("Cube1")) .From(Mdx.Cube("Cube2")) .From(Mdx.Cube("Cube3")) .Where(Mdx.Tuple().With(Mdx.Set().With( Mdx.Range() .From(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key").WithValue("1")) .To(Mdx.Member("Dim Hierarchy", "Dim", "Dim Key").WithValue("4"))))); //ASSERT Assert.That(query.ToString(), Is.EqualTo(expectedQueryString)); }
public string getPdxForFile(string pFileName, TreeNode pParentNode) { string ret = null; FileInfo fi = new FileInfo(pFileName); if (fi.Exists && fi.Extension.Equals(Mdx.MDX_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase)) { FileStream fs = File.OpenRead(pFileName); byte[] data = new byte[fs.Length]; FileUtil.ReadWholeArray(fs, data); fs.Close(); fs.Dispose(); Mdx mdx = new Mdx(data); ret = mdx.PdxFileName; // Populate Tree View if (pParentNode != null) { // create file node TreeNode fileNode = new TreeNode(Path.GetFileName(pFileName)); TreeNode titleNode = new TreeNode("Title: " + mdx.Title); TreeNode pdxNode = new TreeNode("PDX: " + mdx.PdxFileName); if (!fileNode.Text.Equals(pParentNode.Text)) { fileNode.Nodes.Add(titleNode); fileNode.Nodes.Add(pdxNode); pParentNode.Nodes.Add(fileNode); } else { pParentNode.Nodes.Add(titleNode); pParentNode.Nodes.Add(pdxNode); } } } return(ret); }
public void buildMdxTreeNode(Mdx pMdx, string pFileName, TreeNode pParentNode) { // Populate Tree View if (pParentNode != null) { // create file node TreeNode fileNode = new TreeNode(Path.GetFileName(pFileName)); TreeNode titleNode = new TreeNode("Title: " + pMdx.Title); TreeNode pdxNode = new TreeNode("PDX: " + pMdx.PdxFileName); if (!fileNode.Text.Equals(pParentNode.Text)) { fileNode.Nodes.Add(titleNode); fileNode.Nodes.Add(pdxNode); pParentNode.Nodes.Add(fileNode); } else { pParentNode.Nodes.Add(titleNode); pParentNode.Nodes.Add(pdxNode); } } }