Databases Reference
In-Depth Information
//Open a connection to the server.
this.server = new Server();
this.server.Connect(“Datasource=localhost;”);
SubscribeToSessionTrace();
//Subscribe to the trace event.
this.processProgress.Value = 0;
this.reportTree.Nodes.Clear();
//When the connection is opened, it is possible to
//start processing, but still impossible to cancel the process.
SetButtonsState(ButtonState.Process);
}
After the connection to the server is established, we subscribe to the default trace events:
//Set the event handler that will be called when the trace event is
//fired.
//Start tracing.
private void SubscribeToSessionTrace()
{
this.server.SessionTrace.OnEvent +=
new TraceEventHandler(sessionTrace_OnEvent);
this.server.SessionTrace.Stopped +=
new TraceStoppedEventHandler(sessionTrace_Stopped);
this.server.SessionTrace.Start(); // this method is not blocking
}
After the user clicks the Process button, our application takes the Warehouse and Sales
cube of the FoodMart 2008 database and passes it to the function running on the back-
ground thread so that it can be processed:
//This function is called when the user clicks the Process button.
private void processButton_Click(object sender, EventArgs e)
{
//Get a database and a cube.
Database database = this.server.Databases.GetByName(“Foodmart 2008”);
Cube cube = database.Cubes.GetByName(“Warehouse and Sales”);
//Before starting the worker thread, disable the Process button
//so the user won't be able to click it again.
SetButtonsState(ButtonState.None);
//Start the worker thread, then pass the Cube object as a parameter
//to the function that will be called on the worker thread.
this.backgroundWorker.RunWorkerAsync(cube);
}
On the background thread, we process the Warehouse and Sales cube:
void OnDoWork(object sender, DoWorkEventArgs doWorkArgs)
Search WWH ::




Custom Search