关于Ranet.UILibrary.OLAP项目的简介请参考我的另一篇文章这里
不管什么原因,有时我们希望可以在Silverlight客户端进行调试,以查看发送到Server端的请求参数等信息,从而可以更好的定位问题;以下方法基于Ranet.UILibrary.OLAP项目,对其客户端添加一个调试窗口:
Add silverligth client debug feature in Ranet.UILibrary.OLAP:
1. change file \ranet-uilibrary-olap\UILibrary.Olap\UILibrary.Olap.MergeModule.Samples.Src\INSTALLDIR\Samples\UITest.Web\SilverliteApplication.htm :
add ?debug=true in line 68(<param name="source" value="ClientBin/UITest.xap?debug=true")
2. change file \ranet-uilibrary-olap\UILibrary.Olap\UILibrary.Olap.MergeModule.Samples.Src\INSTALLDIR\Samples\UITest.Silverlight\evMdxDesigner.cs :
add InitDebug(); method
{
string src = App.Current.Host.Source.ToString();
int idx = src.IndexOf("?");
if (idx>-1)
{
string[] paramLst = src.Substring(idx+1).Split("&".ToCharArray());
for (int i = 0; i < paramLst.Length; i++)
{
string[] p = paramLst[i].Split("=".ToCharArray());
switch (p[0])
{
case "debug":
if (p[1] == "true")
{
isDebug = true;
//txtLogger.Visibility = Visibility.Visible;
debugRow.Height = new GridLength(100);
this.pivotMdxDesignerControl.BeginDataLoad += new EventHandler<Ranet.AgOlap.Controls.General.DataLoaderEventArgs>(pivotMdxDesignerControl_BeginDataLoad);
}
break;
default:
break;
}
}
}
}
add InitDebug(); method invoke in Init method;
add method pivotMdxDesignerControl_BeginDataLoad();
{
if (isDebug)
{
txtLogger.Text += e.UserState;
}
}
add private variable bool isDebug = false;
3. change file ranet-uilibrary-olap\UILibrary.Olap\Ranet.AgOlap\Controls\PivotMdxDesignerControl.cs
add private variable public event EventHandler<DataLoaderEventArgs> BeginDataLoad;
add event register in method Initialize() : m_ServerExplorer.OlapDataLoader.BeginDataLoad += this.BeginDataLoad;
4. change file UITest.Silverlight\Page.xaml
add new TextBox control txtLogger at proper place
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition x:Name="debugRow" Height="0" /><!--here-->
</Grid.RowDefinitions>
<Samples:MyDesigner Grid.Row="0" Grid.Column="0" x:Name="pivotMdxDesignerControl" />
<TextBox x:Name="txtLogger" Grid.Row="1" Grid.Column="0"/><!--here-->
</Grid>
5. change file ranet-uilibrary-olap\UILibrary.Olap\Ranet.AgOlap\Controls\General\OlapDataLoader.cs
add method invoke in LoadData(OlapActionBase schema, object state) : Raise_BeginDataLoad(new DataLoaderEventArgs(null, null, service.Endpoint.Address.Uri.ToString()));
add method Raise_BeginDataLoad(DataLoaderEventArgs args)
{
EventHandler<DataLoaderEventArgs> handler = this.BeginDataLoad;
if (handler != null)
{
handler(this, args);
}
}
add public variable : public event EventHandler<DataLoaderEventArgs> BeginDataLoad;
6. change file ranet-uilibrary-olap\UILibrary.Olap\Ranet.AgOlap\Controls\General\IDataLoader.cs
add variable in interface IDataLoader : event EventHandler<DataLoaderEventArgs> BeginDataLoad;