zoukankan      html  css  js  c++  java
  • 给Silverlight项目Ranet.UILibrary.OLAP添加客户端调试功能

    关于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

    代码
    void InitDebug()
            {
                
    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();

    代码
    void pivotMdxDesignerControl_BeginDataLoad(object sender, Ranet.AgOlap.Controls.General.DataLoaderEventArgs e)
            {
                
    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 x:Name="LayoutRoot" Loaded="Init">
            
    <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)

    代码
    void 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;

  • 相关阅读:
    Windows Live Writer加载代码着色插件步骤
    C#中List<object>.Clear()方法和实例化new List<object>()操作的结果分析
    QT Creator引用win32 api类库方法(.lib)
    Fiddler系列教程1:初识Http协议抓包工具
    Robot Framework自动化测试框架初探
    JMeter基础教程1:若隐若现的参数化
    python异步并发模块concurrent.futures入门详解
    符合语言习惯的Python优雅编程技巧
    Python实现正交实验法自动设计测试用例
    Python Nose框架编写测试用例方法
  • 原文地址:https://www.cnblogs.com/andy65007/p/1788964.html
Copyright © 2011-2022 走看看