string MDXQuery = "WITH MEMBER [Measures].[OrderQuantityCurr] AS [Measures].[Order Quantity], LANGUAGE=1043, FORMAT_STRING='Currency' " +
"SELECT NON EMPTY { [Measures].[OrderQuantityCurr] } ON COLUMNS, " +
" NON EMPTY { ([Sales Territory].[Sales Territory].[Region].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS " +
"FROM [Adventure Works] " +
"CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS";
[AcceptVerbs("Post")]
public Dictionary<string, object> Initialize(Dictionary<string, object> jsonResult)
{
OlapDataManager DataManager = null;
//..
DataManager = new OlapDataManager(connectionString);
DataManager.SetCurrentReport(CreateOlapReport());
DataManager.BeforeMdxQueryExecute += DataManager_BeforeMdxQueryExecute;
DataManager.OverrideDefaultFormatStrings = true;
return htmlHelper.GetJsonData(jsonResult["action"].ToString(), DataManager, jsonResult.ContainsKey("gridLayout") ? jsonResult["gridLayout"].ToString() : null,Convert.ToBoolean(jsonResult["enablePivotFieldList"].ToString()));
}
void DataManager_BeforeMdxQueryExecute(object sender,QueryExecutingEventArgs e)
{
e.MdxQuery = "WITH MEMBER [Measures].[OrderQuantityCurr] AS [Measures].[Order Quantity], LANGUAGE=1043, FORMAT_STRING='Currency' " +
"SELECT NON EMPTY { [Measures].[OrderQuantityCurr] } ON COLUMNS, " +
" NON EMPTY { ([Sales Territory].[Sales Territory].[Region].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS " +
"FROM [Adventure Works] " +
"CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS";
}
private OlapReport CreateOlapReport()
{
OlapReport olapReport = new OlapReport();
olapReport.CurrentCubeName = "Adventure Works";
{
MeasureElements measureElement = new MeasureElements();
measureElement.Elements.Add(new MeasureElement { UniqueName = "[Measures].[Customer Count]" });
DimensionElement dimensionElementRow = newDimensionElement();
dimensionElementRow.Name = "Date";
dimensionElementRow.AddLevel("Fiscal", "Fiscal Year");
DimensionElement dimensionElementColumn = newDimensionElement();
dimensionElementColumn.Name = "Customer";
dimensionElementColumn.AddLevel("Customer Geography","Country");
olapReport.SeriesElements.Add(dimensionElementRow);
olapReport.CategoricalElements.Add(dimensionElementColumn);
olapReport.CategoricalElements.Add(measureElement);
}
return olapReport;
} |