Beispiel #1
0
        private static void MultipleHyperCubesExamples(IApp theApp)
        {
            var theObject = CreateCustomObject(theApp);
            // Create two hypercubes with the same measure, but different dimensions.
            var salesPerMonthHc = new HyperCubeDef();

            AddInlineDimension(salesPerMonthHc, "Month");
            AddInlineMeasure(salesPerMonthHc, "Sum([Sales Amount])");
            var salesPerYearHc = new HyperCubeDef();

            AddInlineDimension(salesPerYearHc, "Year");
            AddInlineMeasure(salesPerYearHc, "Sum([Sales Amount])");

            // Add the hypercubes to containers. The containers are used to separate the two
            // qHyperCubeDef properties in the property tree of the object.
            var hcContainer0 = new DynamicStructure();

            hcContainer0.Set("qHyperCubeDef", salesPerMonthHc);
            var hcContainer1 = new DynamicStructure();

            hcContainer1.Set("qHyperCubeDef", salesPerYearHc);

            // Add containers to object.
            using (theObject.SuspendedLayout)
            {
                theObject.Properties.Set("container0", hcContainer0);
                theObject.Properties.Set("container1", hcContainer1);
            }

            // Print data for first hypercube
            PrintData("Sales per Month", theObject,
                      row => String.Format("Month: {0}, Sales: {1}", row[0].Text, row[1].Text),
                      // Path to hypercube 0. (Name of container property followed by hypercube property.)
                      "/container0/qHyperCubeDef");

            // Print data for second hypercube
            PrintData("Sales per Year", theObject,
                      row => String.Format("Year: {0}, Sales: {1}", row[0].Num, row[1].Text),
                      // Path to hypercube 1. (Name of container property followed by hypercube property.)
                      "/container1/qHyperCubeDef");

            // Get pager for cube in container 1:
            var thePager = theObject.GetAllHyperCubePagers().First(pager => pager.Path.Contains("container0"));

            // Get Last five rows for that hypercube:
            thePager.CurrentPages = new [] { new NxPage {
                                                 Width = 2, Height = 5
                                             } };
            var theLastFiveRows = thePager.GetLastPage().First();

            PrintPage("The last five rows of hypercube in container0:", theLastFiveRows,
                      row => String.Format("Month: {0}, Sales: {1}", row[0].Text, row[1].Text)
                      );
        }