Knowledgebase
Overview. RadarCube for ASP.NET MVC
Posted by Andrey Stepanov on 09 September 2015 03:26 PM

This article applies to: RadarCube ASP.NET MVC


In this article we will talk about RadarCube OLAP components that were designed for ASP.NET MVC applications to solve business intelligence tasks.

Editions

There are two RadarCube Editions that are suggested to use depending on the analyzed Data Source:

  1. MSAS Edition is used to analyze data from Multidimensional cubes provided by Microsoft Analysis Services.
  2. Direct Edition is used to analyze data from Relational data bases: Microsoft SQL Server, Access, My SQL, Oracle, etc.

DLLs

  1. RadarSoft.RadarCube.Web.Mvc.dll contains the MvcOlapAnalysis control. This component is responsible for displaying data in form of pivot grid or chart and provides a user interface for business analysis. It uses the following technologies: HTML5, CSS, TypeScript, JavaScript, AJAX
  2. RadarSoft.RadarCube.Web.MSAS.Mvc.dll contains the MvcMCube control. It is designed to connect and interact with Multidimensional Data Sources. It is a part of the MSAS Edition.
  3. RadarSoft.RadarCube.Web.Direct.Mvc.dll contains the MvcRCube control. It is used to connect and interact with Relational Data Sources. It is a part of the Direct Edition.

ASP.NET RadarCube controls for MVC have a number of advantages compared to RadarCube controls for WebForms. Due to MVC features a developer has full control over creation, configuration, handling of client-side requests and rendering of components. Let's consider each step of embedding the components from point of MVC pattern view. As an example we consider a project where the "RadarCube.MvcControls.MOLAP" NuGet package was installed.

Controller

Controller manages the operation of the components. It calls a view in which client-side of the component is rendered. Also Controller provides interaction of the client-side with the server-side of the component.

In the MVC RadarCube components almost all of the UI actions use AJAX requests and do not lead to the restart of the page. The exception is requests for the Export. The disuse of postback requests is also a feature of the MVC components compared with the components for ASP.NET WebForms where most of the OLAP Toolbox actions refresh the page.

public class OlapAnalysisController : Controller
{
    public ActionResult RadarCube()
    {
        return View();
    }

    [AjaxOnly]
    [AcceptVerbs(HttpVerbs.Post)]
    public JsonResult CallbackHandler()
    {
        var olapAnalysis = HtmlHelperExtension.CreateOlapAnalysis();
        return Json(olapAnalysis.DoCallback(), JsonRequestBehavior.DenyGet);
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public BinaryStreamResult ExportHandler()
    {
        var olapAnalysis = HtmlHelperExtension.CreateOlapAnalysis();
        return olapAnalysis.DoExport();
    }
}

Thus to achieve full RadarCube OLAP functionality the Controller must have at least three Actions:

  1. RadarCube() renders  the component on the page;
  2. CallbackHandler() if for the client-server communication by means of AJAX requests;
  3. ExportHandler() exports the viewed data slice.

View

Now consider how the RadarCube components are displayed.

There is a markup of RadarCube View:

@using MvcApplication1.Helpers
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>RadarCube MOLAP Analysis for ASP.NET MVC aplications</title>
    <link href="~/Content/rsolap/css/Redmond.RadarSoft.RadarCube.jquery-ui.css" rel="stylesheet" />
    <link href="~/Content/rsolap/css/rsMvcOlapAnalysis.all.min.css" rel="stylesheet" />
    <script src="~/Content/rsolap/rsMvcOlapAnalysis.all.min.js"></script>
    <style type="text/css">
        body {
            font-size: 12px;
            margin: 0;
        }
    </style>
</head>
<body>
@(Html.OlapSample())
</body>
</html>

There are two files with styles and a file with JavaScript code are linked to the page:

  • Redmond.RadarSoft.RadarCube.jquery-ui.css file defines the visual theme of the component. Redmond is a one of the many themes that are proposed by jQuery UI. If none of those does not suit you then you can create your own using ThemeRoller and apply it to the RadarCube component.
  • rsMvcOlapAnalysis.all.min.css file contains component's styles in a compressed form.
  • rsMvcOlapAnalysis.all.min.js file provides all the necessary code to run client-side of the component. In the original form the code is contained in several files which then are combined into one and the code is compressed.

The combination and the compression of the client resources are made by gulp tasks.

Let us return to the View. There is the following code inside: @(Html.OlapSample()). It is a call of HTML Custom Helper function in the Razor syntax.

Look at the Helper:

public static class HtmlHelperExtension
{
    public static HtmlString OlapSample(this HtmlHelper helper)
    {
        var olapAnalysis = CreateOlapAnalysis();
        return olapAnalysis.Render();
    }

    public static MvcOlapAnalysis CreateOlapAnalysis()
    {
        var OlapAnalysis = new MvcOlapAnalysis("MvcOlapAnalysis1");

        OlapAnalysis.InitOlap += delegate { InitSample(OlapAnalysis); };
            
        var cube = new MvcMCube
        {
            ID = OlapAnalysis.ID + "_Cube",
        };

        OlapAnalysis.Cube = cube;

        return OlapAnalysis;
    }

    private static void InitSample(MvcOlapAnalysis OlapAnalysis)
    {
        OlapAnalysis.CallbackController = "OlapAnalysis";
        OlapAnalysis.CallbackAction = "CallbackHandler";
        OlapAnalysis.ExportController = "OlapAnalysis";
        OlapAnalysis.ExportAction = "ExportHandler";

        ((TMDCube)OlapAnalysis.Cube).ConnectionString = String.Format("Provider=MSOLAP.3;Data Source='{0}'",
                                                    HttpContext.Current.Request.MapPath("~/App_Data/WarehouseAndSales.cub"));

        ((TMDCube)OlapAnalysis.Cube).CubeName = "Warehouse and Sales";
        OlapAnalysis.Cube.Active = true;

        OlapAnalysis.PivotingFirst(OlapAnalysis.Dimensions.FindHierarchy("[Product]"), TLayoutArea.laRow);
        OlapAnalysis.PivotingFirst(OlapAnalysis.Dimensions.FindHierarchy("[Time]"), TLayoutArea.laColumn);

        var measure = OlapAnalysis.Measures.Find("[Measures].[Warehouse Sales]");
        OlapAnalysis.Pivoting(measure, TLayoutArea.laRow, null);
        measure = OlapAnalysis.Measures.Find("[Measures].[Sales Count]");
        OlapAnalysis.Pivoting(measure, TLayoutArea.laRow, null);
    }
}

The components creation and its HTML-markup generation take place in the OlapSample method.

In the CreateOlapAnalysis method the OLAP components are created, as well as subscription to the InitOlap event occurs. A special feature of this event that it is called only once when the page is loading. That is why in the handler of this event components settings are happened: its properties determination, layout initialization, the cube structure creation (for Direct edition) and a cube activation. The fact is that a re-setting of the components is not required, since it is recovered from a cache.

Model

Due to the simplicity of the example, the Model is not used therein. However, it can be very useful and even necessary for solving more complex problems. As an example, you can see the demo project that is included in the RadarCube for ASP.NET MVC distributives.

Here is only a recommendation: to place the code to create and configure the components inside the Model.

Functionality

RadarCube components for ASP.NET MVC are descendants of the components for ASP.NET WebForms and therefore inherit all of their functionality. It overrides the methods and properties that use WebForms Framework particularities. So, there is no the ViewState in ASP.NET MVC and therefore the values of the properties store in the component's cache. Also, there is no Web designer in ASP.NET MVC for easy setting of components properties. To solve this problem the user interface of RadarCube components for ASP.NET MVC has ability to configure their properties online. All other Frameworks differences are more into the hands of the MVC components, as provide more flexible and elegant solutions for business intelligence applications development on ASP.NET MVC.

For more information about the RadarCube components features, welcome to the Knowledgebase.

(0 vote(s))
This article was helpful
This article was not helpful

Help Desk Software by Kayako Resolve