示例#1
0
        private OlapReport CreateOLAPReport()
        {
            OlapReport olapReport = new OlapReport
            {
                Name            = "Calculated Report",
                CurrentCubeName = "Adventure Works"
            };

            DimensionElement dimensionElementColumn = new DimensionElement();

            dimensionElementColumn.Name          = "Customer";
            dimensionElementColumn.HierarchyName = "Customer Geography";
            dimensionElementColumn.AddLevel("Customer Geography", "Country");

            MeasureElements measureElementColumn = new MeasureElements();

            measureElementColumn.Elements.Add(new MeasureElement {
                Name = "Internet Sales Amount"
            });
            measureElementColumn.Elements.Add(new MeasureElement {
                Name = "Sales Amount"
            });

            DimensionElement dimensionElementRow = new DimensionElement();

            dimensionElementRow.Name = "Date";
            dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");

            // Calculated measure
            CalculatedMember calculatedMeasure1 = new CalculatedMember();

            calculatedMeasure1.Name       = "Order on Discount Sale";
            calculatedMeasure1.Expression = "[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)";
            calculatedMeasure1.AddElement(new MeasureElement {
                Name = "Order Quantity"
            });
            olapReport.CalculatedMembers.Add(calculatedMeasure1);

            // Adding column members
            olapReport.CategoricalElements.Add(dimensionElementColumn);
            olapReport.CategoricalElements.Add(calculatedMeasure1);

            // Adding measure element
            olapReport.CategoricalElements.Add(measureElementColumn);

            // Adding row members
            olapReport.SeriesElements.Add(dimensionElementRow);

            return(olapReport);
        }
示例#2
0
        OlapReport CalculatedReport()
        {
            // CubeModel cubeModel = new CubeModel(ConnectionString);
            OlapReport olapReport = new OlapReport();

            olapReport.CurrentCubeName = "Adventure Works";

            DimensionElement dimensionElementColumn = new DimensionElement();

            //Specifying the Name for the Dimension Element
            dimensionElementColumn.Name          = "Customer";
            dimensionElementColumn.HierarchyName = "Customer Geography";
            dimensionElementColumn.AddLevel("Customer Geography", "Country");

            DimensionElement internalDimension = new DimensionElement();

            internalDimension.Name = "Product";
            internalDimension.AddLevel("Product Categories", "Category");

            //// Calculated Measure
            CalculatedMember calculatedMeasure1 = new CalculatedMember();

            calculatedMeasure1.Name       = "Oder on Discount";
            calculatedMeasure1.Expression = "[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)";
            calculatedMeasure1.AddElement(new MeasureElement {
                Name = "Order Quantity"
            });

            //// Calculated Measure
            CalculatedMember calculatedMeasure2 = new CalculatedMember();

            calculatedMeasure2.Name = "Sales Range";
            calculatedMeasure2.AddElement(new MeasureElement {
                Name = "Sales Amount"
            });
            calculatedMeasure2.Expression = "IIF([Measures].[Sales Amount]>200000,\"High\",\"Low\")";

            // Calculated Dimension
            CalculatedMember calculateDimension = new CalculatedMember();

            calculateDimension.Name       = "Bikes & Components";
            calculateDimension.Expression = "([Product].[Product Categories].[Category].[Bikes] + [Product].[Product Categories].[Category].[Components] )";
            calculateDimension.AddElement(internalDimension);

            MeasureElements measureElementColumn = new MeasureElements();

            measureElementColumn.Elements.Add(new MeasureElement {
                Name = "Sales Amount"
            });
            measureElementColumn.Elements.Add(new MeasureElement {
                Name = "Order Quantity"
            });

            DimensionElement dimensionElementRow = new DimensionElement();

            //Specifying the Dimension Name
            dimensionElementRow.Name = "Date";
            dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");


            //// Adding Calculated members in calculated member collection
            olapReport.CalculatedMembers.Add(calculatedMeasure1);
            olapReport.CalculatedMembers.Add(calculateDimension);
            olapReport.CalculatedMembers.Add(calculatedMeasure2);

            // Adding Column Members
            olapReport.CategoricalElements.Add(dimensionElementColumn);
            olapReport.CategoricalElements.Add(calculateDimension);
            //Adding Measure Element
            olapReport.CategoricalElements.Add(measureElementColumn);
            olapReport.CategoricalElements.Add(calculatedMeasure1);
            olapReport.CategoricalElements.Add(calculatedMeasure2);

            //Adding Row Members
            olapReport.SeriesElements.Add(dimensionElementRow);

            return(olapReport);
        }
        private OlapReport CreateOlapReport(string Report)
        {
            OlapReport olapReport = new OlapReport()
            {
                Name = "Default Report"
            };

            olapReport.CurrentCubeName = "Adventure Works";

            if (Report == "Paging")
            {
                olapReport.EnablePaging = true;
                olapReport.PagerOptions.SeriesPageSize      = 5;
                olapReport.PagerOptions.CategoricalPageSize = 3;

                DimensionElement dimensionElement = new DimensionElement()
                {
                    Name = "Customer"
                };
                dimensionElement.AddLevel("Customer", "Customer");
                olapReport.CategoricalElements.Add(dimensionElement);

                DimensionElement dimensionElementRow = new DimensionElement()
                {
                    Name = "Customer", HierarchyName = "Customer"
                };
                dimensionElementRow.AddLevel("Customer Geography", "Country");
                olapReport.SeriesElements.Add(dimensionElementRow);

                MeasureElements measureElementColumn = new MeasureElements();
                measureElementColumn.Elements.Add(new MeasureElement {
                    Name = "Internet Sales Amount"
                });
                olapReport.CategoricalElements.Add(measureElementColumn);
            }
            else if (Report == "CalculatedMember")
            {
                DimensionElement internalDimension = new DimensionElement();
                internalDimension.Name = "Product";
                internalDimension.AddLevel("Product Categories", "Category");

                //// Calculated Measure
                CalculatedMember calculatedMeasure1 = new CalculatedMember();
                calculatedMeasure1.Name       = "Oder on Discount";
                calculatedMeasure1.Expression = "[Measures].[Order Quantity] + ([Measures].[Order Quantity] * 0.10)";
                calculatedMeasure1.AddElement(new MeasureElement {
                    Name = "Order Quantity"
                });

                // Calculated Dimension
                CalculatedMember calculateDimension = new CalculatedMember();
                calculateDimension.Name       = "Bikes & Components";
                calculateDimension.Expression = "([Product].[Product Categories].[Category].[Bikes] + [Product].[Product Categories].[Category].[Components] )";
                calculateDimension.AddElement(internalDimension);

                MeasureElements measureElementColumn = new MeasureElements();
                measureElementColumn.Elements.Add(new MeasureElement {
                    Name = "Sales Amount"
                });
                measureElementColumn.Elements.Add(new MeasureElement {
                    Name = "Order Quantity"
                });

                DimensionElement dimensionElementRow = new DimensionElement();
                //Specifying the Dimension Name
                dimensionElementRow.Name = "Date";
                dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");


                //// Adding Calculated members in calculated member collection
                olapReport.CalculatedMembers.Add(calculatedMeasure1);
                olapReport.CalculatedMembers.Add(calculateDimension);

                ///Adding Measure Element
                olapReport.CategoricalElements.Add(measureElementColumn);
                olapReport.CategoricalElements.Add(calculatedMeasure1);

                ///Adding Row Members
                olapReport.SeriesElements.Add(dimensionElementRow);
                olapReport.SeriesElements.Add(calculateDimension);
            }
            else if (Report == "KPI")
            {
                DimensionElement dimensionElement = new DimensionElement()
                {
                    Name = "Date"
                };
                dimensionElement.AddLevel("Fiscal", "Fiscal Year");
                olapReport.CategoricalElements.Add(dimensionElement);

                DimensionElement dimensionElementRow = new DimensionElement()
                {
                    Name = "Customer", HierarchyName = "Customer"
                };
                dimensionElementRow.AddLevel("Customer Geography", "Country");
                olapReport.SeriesElements.Add(dimensionElementRow);

                MeasureElements measureElementColumn = new MeasureElements();
                measureElementColumn.Elements.Add(new MeasureElement {
                    Name = "Internet Sales Amount"
                });
                olapReport.CategoricalElements.Add(measureElementColumn);

                KpiElements kpiElement = new KpiElements();
                kpiElement.Elements.Add(new KpiElement
                {
                    Name          = "Revenue",
                    ShowKPIStatus = false,
                    ShowKPIGoal   = false,
                    ShowKPITrend  = true,
                    ShowKPIValue  = false
                });
                olapReport.CategoricalElements.Add(kpiElement);
            }
            else
            {
                MeasureElements measureElement = new MeasureElements();
                measureElement.Elements.Add(new MeasureElement {
                    UniqueName = "[Measures].[Customer Count]"
                });

                DimensionElement dimensionElementRow = new DimensionElement();
                dimensionElementRow.Name = "Date";
                dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");

                olapReport.SeriesElements.Add(dimensionElementRow);
                olapReport.CategoricalElements.Add(measureElement);
            }
            return(olapReport);
        }