posts - 124,  comments - 29,  trackbacks - 0

TCP/UDP协议基础

(转载)

 

  理解数据包,对于网络管理的网络安全具有至关重要的意义。比如,防火墙的作用本质就是检测网络中的数据包,判断其是否违反了预先设置的规则,如果违反就加以阻止。图1就是瑞星个人版防火墙软件设置规则的界面。细心的读者会发现,图1中的“协议”栏中有“TCP”、“UDP”等名词,它们是什么意思呢?现在我们就来讲讲什么是TCP和UDP。

  面向连接的TCP

  “面向连接”就是在正式通信前必须要与对方建立起连接。比如你给别人打电话,必须等线路接通了、对方拿起话筒才能相互通话。

  TCP(Transmission Control Protocol,传输控制协议)是基于连接的协议,也就是说,在正式收发数据前,必须和对方建立可靠的连接。一个TCP连接必须要经过三次“对话”才能建立起来,其中的过程非常复杂,我们这里只做简单、形象的介绍,你只要做到能够理解这个过程即可。我们来看看这三次对话的简单过程:主机A向主机B发出连接请求数据包:“我想给你发数据,可以吗?”,这是第一次对话;主机B向主机A发送同意连接和要求同步(同步就是两台主机一个在发送,一个在接收,协调工作)的数据包:“可以,你什么时候发?”,这是第二次对话;主机A再发出一个数据包确认主机B的要求同步:“我现在就发,你接着吧!”,这是第三次对话。三次“对话”的目的是使数据包的发送和接收同步,经过三次“对话”之后,主机A才向主机B正式发送数据。

  TCP协议能为应用程序提供可靠的通信连接,使一台计算机发出的字节流无差错地发往网络上的其他计算机,对可靠性要求高的数据通信系统往往使用TCP协议传输数据。


图2

  我们来做一个实验,用计算机A(安装Windows 2000 Server操作系统)从“网上邻居”上的一台计算机B拷贝大小为8,644,608字节的文件,通过状态栏右下角网卡的发送和接收指标就会发现:虽然是数据流是由计算机B流向计算机A,但是计算机A仍发送了3,456个数据包,如图2所示。这些数据包是怎样产生的呢?因为文件传输时使用了TCP/IP协议,更确切地说是使用了面向连接的TCP协议,计算机A接收数据包的时候,要向计算机B回发数据包,所以也产生了一些通信量。


图3

  如果事先用网络监视器监视网络流量,就会发现由此产生的数据流量是9,478,819字节,比文件大小多出10.96%(如图3所示),原因不仅在于数据包和帧本身占用了一些空间,而且也在于TCP协议面向连接的特性导致了一些额外的通信量的产生。

  面向非连接的UDP协议

  “面向非连接”就是在正式通信前不必与对方先建立连接,不管对方状态就直接发送。这与现在风行的手机短信非常相似:你在发短信的时候,只需要输入对方手机号就OK了。

  UDP(User Data Protocol,用户数据报协议)是与TCP相对应的协议。它是面向非连接的协议,它不与对方建立连接,而是直接就把数据包发送过去!


图4

  UDP适用于一次只传送少量数据、对可靠性要求不高的应用环境。比如,我们经常使用“ping”命令来测试两台主机之间TCP/IP通信是否正常,其实“ping”命令的原理就是向对方主机发送UDP数据包,然后对方主机确认收到数据包,如果数据包是否到达的消息及时反馈回来,那么网络就是通的。例如,在默认状态下,一次“ping”操作发送4个数据包(如图2所示)。大家可以看到,发送的数据包数量是4包,收到的也是4包(因为对方主机收到后会发回一个确认收到的数据包)。这充分说明了UDP协议是面向非连接的协议,没有建立连接的过程。正因为UDP协议没有连接的过程,所以它的通信效果高;但也正因为如此,它的可靠性不如TCP协议高。QQ就使用UDP发消息,因此有时会出现收不到消息的情况。

  附表:tcp协议和udp协议的差别

  TCP协议和UDP协议各有所长、各有所短,适用于不同要求的通信环境。TCP协议和UDP协议之间的差别如附表所示。

posted @ 2010-06-04 14:05 天书 阅读(2262) | 评论 (0)编辑 收藏

TCP/UDP协议基础

(转载)

 

  理解数据包,对于网络管理的网络安全具有至关重要的意义。比如,防火墙的作用本质就是检测网络中的数据包,判断其是否违反了预先设置的规则,如果违反就加以阻止。图1就是瑞星个人版防火墙软件设置规则的界面。细心的读者会发现,图1中的“协议”栏中有“TCP”、“UDP”等名词,它们是什么意思呢?现在我们就来讲讲什么是TCP和UDP。

  面向连接的TCP

  “面向连接”就是在正式通信前必须要与对方建立起连接。比如你给别人打电话,必须等线路接通了、对方拿起话筒才能相互通话。

  TCP(Transmission Control Protocol,传输控制协议)是基于连接的协议,也就是说,在正式收发数据前,必须和对方建立可靠的连接。一个TCP连接必须要经过三次“对话”才能建立起来,其中的过程非常复杂,我们这里只做简单、形象的介绍,你只要做到能够理解这个过程即可。我们来看看这三次对话的简单过程:主机A向主机B发出连接请求数据包:“我想给你发数据,可以吗?”,这是第一次对话;主机B向主机A发送同意连接和要求同步(同步就是两台主机一个在发送,一个在接收,协调工作)的数据包:“可以,你什么时候发?”,这是第二次对话;主机A再发出一个数据包确认主机B的要求同步:“我现在就发,你接着吧!”,这是第三次对话。三次“对话”的目的是使数据包的发送和接收同步,经过三次“对话”之后,主机A才向主机B正式发送数据。

  TCP协议能为应用程序提供可靠的通信连接,使一台计算机发出的字节流无差错地发往网络上的其他计算机,对可靠性要求高的数据通信系统往往使用TCP协议传输数据。


图2

  我们来做一个实验,用计算机A(安装Windows 2000 Server操作系统)从“网上邻居”上的一台计算机B拷贝大小为8,644,608字节的文件,通过状态栏右下角网卡的发送和接收指标就会发现:虽然是数据流是由计算机B流向计算机A,但是计算机A仍发送了3,456个数据包,如图2所示。这些数据包是怎样产生的呢?因为文件传输时使用了TCP/IP协议,更确切地说是使用了面向连接的TCP协议,计算机A接收数据包的时候,要向计算机B回发数据包,所以也产生了一些通信量。


图3

  如果事先用网络监视器监视网络流量,就会发现由此产生的数据流量是9,478,819字节,比文件大小多出10.96%(如图3所示),原因不仅在于数据包和帧本身占用了一些空间,而且也在于TCP协议面向连接的特性导致了一些额外的通信量的产生。

  面向非连接的UDP协议

  “面向非连接”就是在正式通信前不必与对方先建立连接,不管对方状态就直接发送。这与现在风行的手机短信非常相似:你在发短信的时候,只需要输入对方手机号就OK了。

  UDP(User Data Protocol,用户数据报协议)是与TCP相对应的协议。它是面向非连接的协议,它不与对方建立连接,而是直接就把数据包发送过去!


图4

  UDP适用于一次只传送少量数据、对可靠性要求不高的应用环境。比如,我们经常使用“ping”命令来测试两台主机之间TCP/IP通信是否正常,其实“ping”命令的原理就是向对方主机发送UDP数据包,然后对方主机确认收到数据包,如果数据包是否到达的消息及时反馈回来,那么网络就是通的。例如,在默认状态下,一次“ping”操作发送4个数据包(如图2所示)。大家可以看到,发送的数据包数量是4包,收到的也是4包(因为对方主机收到后会发回一个确认收到的数据包)。这充分说明了UDP协议是面向非连接的协议,没有建立连接的过程。正因为UDP协议没有连接的过程,所以它的通信效果高;但也正因为如此,它的可靠性不如TCP协议高。QQ就使用UDP发消息,因此有时会出现收不到消息的情况。

  附表:tcp协议和udp协议的差别

  TCP协议和UDP协议各有所长、各有所短,适用于不同要求的通信环境。TCP协议和UDP协议之间的差别如附表所示。

posted @ 2010-06-04 14:05 天书 阅读(301) | 评论 (0)编辑 收藏

 //设置textbox每行最多显示固定个字符
        public static void SetTextBoxColumn(TextBox textBox1, int charCount)
        {
            try
            {
                for (int i = 0; i < textBox1.Lines.Length; i++)
                {
                    if (textBox1.Lines[i].Length > charCount)
                    {
                        int firstCharIndex = textBox1.GetFirstCharIndexFromLine(i);
                        string str = textBox1.Lines[i];
                        textBox1.Text = textBox1.Text.Insert(firstCharIndex + charCount, "\r\n");

                    }
                }
            }
            catch { }
        }

posted @ 2010-05-17 16:05 天书 阅读(988) | 评论 (0)编辑 收藏
private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
           
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
                
            }
        }
posted @ 2010-05-07 19:19 天书 阅读(1297) | 评论 (0)编辑 收藏

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace ChartControl
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private Dictionary<string, double> chartPieDataDic = new Dictionary<string, double>();
        private Dictionary<string, double> chartBarDataDic = new Dictionary<string, double>();
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedIndex = 0;
            InitPieChartData();
            InitBarChartData();
            showPie();
           
        }
        private void showPie()
        {
            ChartTitle title = new ChartTitle();
            title.Text = "全省话务分析饼图-话务类型分布";

            chartControl1.Titles.Clear();
            chartControl1.Titles.Add(title);

            Series series1 = new Series("话务类型", ViewType.Pie);
            ((PiePointOptions)series1.PointOptions).PointView = PointView.ArgumentAndValues;

            foreach (KeyValuePair<string, double> keyvalue in chartPieDataDic)
            {
                series1.Points.Add(new SeriesPoint(keyvalue.Key, new double[] { keyvalue.Value }));
            }

            chartControl1.Series.Clear();
            chartControl1.Series.Add(series1);
        }

        private void InitPieChartData()
        {
            try
            {
                chartPieDataDic.Add("大连", 0.2);
                chartPieDataDic.Add("沈阳", 0.26);
                chartPieDataDic.Add("锦州", 0.15);
                chartPieDataDic.Add("盘锦", 0.15);
                chartPieDataDic.Add("本溪", 0.1);
                chartPieDataDic.Add("抚顺", 0.12);
                chartPieDataDic.Add("营口", 0.02);
            }
            catch { }
        }
        private void InitBarChartData()
        {
            try
            {
                chartBarDataDic.Add("2001", 0.05);
                chartBarDataDic.Add("2002", 0.02);
                chartBarDataDic.Add("2003", 0.08);
                chartBarDataDic.Add("2004", 0.15);
                chartBarDataDic.Add("2005", 0.1);
                chartBarDataDic.Add("2006", 0.3);
                chartBarDataDic.Add("2007", 0.2);
                chartBarDataDic.Add("2008", 0.1);
            }
            catch { }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text.IndexOf("饼图") != -1)
            {
                showPie();
            }
            else if (comboBox1.Text.IndexOf("柱图") != -1)
            {
                showBar();
            }
            else if (comboBox1.Text.IndexOf("线图") != -1)
            {
                showLine();
            }
            else if (comboBox1.Text.IndexOf("点图") != -1)
            {
                showPoint();
            }
        }

        private void showBar()
        {
            try
            {
                ChartTitle title = new ChartTitle();
                title.Text = "市网元容量增长率统计分析柱图";

                chartControl1.Titles.Clear();
                chartControl1.Titles.Add(title);

                Series series2 = new Series("大连", ViewType.Bar);
                Series series3 = new Series("沈阳", ViewType.Bar);
                Series series4 = new Series("本溪", ViewType.Bar);
                foreach (KeyValuePair<string, double> kvp in chartBarDataDic)
                {
                    series2.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value}));
                    series3.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value + 0.08}));
                    series4.Points.Add(new SeriesPoint(kvp.Key, new double[] {kvp.Value + 0.02}));
                }


                chartControl1.Series.Clear();
                chartControl1.Series.Add(series2);
                chartControl1.Series.Add(series3);
                chartControl1.Series.Add(series4);

                chartControl1.Legend.Visible = true; // 显示标签(旁边的标注哪个颜色代表哪个城市)
            }
            catch { }
        }

        private void showLine()
        {
            ChartTitle title = new ChartTitle();
            title.Text = "线图";
            chartControl1.Titles.Clear();
            chartControl1.Titles.Add(title);

            Series series1 = new Series("辽宁", ViewType.Line);
            series1.ArgumentScaleType = ScaleType.Numerical;

            series1.Points.Add(new SeriesPoint(1, new double[] { 10 }));
            series1.Points.Add(new SeriesPoint(2, new double[] { 12 }));
            series1.Points.Add(new SeriesPoint(3, new double[] { 14 }));
            series1.Points.Add(new SeriesPoint(4, new double[] { 17 }));
            series1.Points.Add(new SeriesPoint(5, new double[] { 21 }));
            series1.Points.Add(new SeriesPoint(6, new double[] { 26 }));
            series1.Points.Add(new SeriesPoint(7, new double[] { 29 }));
            series1.Points.Add(new SeriesPoint(8, new double[] { 30 }));

            ((PointSeriesView)series1.View).PointMarkerOptions.Kind = MarkerKind.Triangle;


            Series series2 = new Series("山东", ViewType.Line);
            series2.ArgumentScaleType = ScaleType.Numerical; //这句话必须有,否则点画不出来.
            ((LineSeriesView)series2.View).LineStyle.DashStyle = DashStyle.DashDotDot;
            series2.Points.Add(new SeriesPoint(1, new double[] { 4 }));
            series2.Points.Add(new SeriesPoint(2, new double[] { 14 }));
            series2.Points.Add(new SeriesPoint(3, new double[] { 17 }));
            series2.Points.Add(new SeriesPoint(4, new double[] { 22 }));
            series2.Points.Add(new SeriesPoint(5, new double[] { 20 }));
            series2.Points.Add(new SeriesPoint(6, new double[] { 15 }));
            series2.Points.Add(new SeriesPoint(7, new double[] { 18 }));
            series2.Points.Add(new SeriesPoint(8, new double[] { 11 }));

            ((PointSeriesView)series2.View).PointMarkerOptions.Kind = MarkerKind.Cross;

            chartControl1.Series.Clear();
            chartControl1.Series.Add(series1);
            chartControl1.Series.Add(series2);
            chartControl1.Legend.Visible = true;
        }
        private void showPoint()
        {
            ChartTitle title = new ChartTitle();
            title.Text = "点图";
            chartControl1.Titles.Clear();
            chartControl1.Titles.Add(title);

            Series series1 = new Series("上线人数", ViewType.Point);
            series1.ArgumentScaleType = ScaleType.Numerical;

            series1.Points.Add(new SeriesPoint(1, new double[] { 20 }));
            series1.Points.Add(new SeriesPoint(2, new double[] { 12 }));
            series1.Points.Add(new SeriesPoint(3, new double[] { 11 }));
            series1.Points.Add(new SeriesPoint(4, new double[] { 17 }));
            series1.Points.Add(new SeriesPoint(5, new double[] { 21 }));
            series1.Points.Add(new SeriesPoint(6, new double[] { 21 }));
            series1.Points.Add(new SeriesPoint(7, new double[] { 29 }));
            series1.Points.Add(new SeriesPoint(8, new double[] { 30 }));

            ((PointSeriesView)series1.View).PointMarkerOptions.Kind = MarkerKind.Triangle;


            Series series2 = new Series("下线人数", ViewType.Point);
            series2.ArgumentScaleType = ScaleType.Numerical; //这句话必须有,否则点画不出来.

            series2.Points.Add(new SeriesPoint(1, new double[] { 4 }));
            series2.Points.Add(new SeriesPoint(2, new double[] { 14 }));
            series2.Points.Add(new SeriesPoint(3, new double[] { 17 }));
            series2.Points.Add(new SeriesPoint(4, new double[] { 22 }));
            series2.Points.Add(new SeriesPoint(5, new double[] { 20 }));
            series2.Points.Add(new SeriesPoint(6, new double[] { 15 }));
            series2.Points.Add(new SeriesPoint(7, new double[] { 18 }));
            series2.Points.Add(new SeriesPoint(8, new double[] { 11 }));

            ((PointSeriesView)series2.View).PointMarkerOptions.Kind = MarkerKind.Cross;

            chartControl1.Series.Clear();
            chartControl1.Series.Add(series1);
            chartControl1.Series.Add(series2);
            chartControl1.Legend.Visible = true;
        }
    }
}

posted @ 2010-05-07 16:09 天书 阅读(9876) | 评论 (0)编辑 收藏
<?xml version="1.0" encoding="GB2312"?>
<Head>
<Column DisTitle="报表名" DisWidth="150">
  
<Field>tableCName</Field> 
  
<Type>string</Type>
  
<Visible>true</Visible>
</Column>
<Column DisTitle="表英文名" DisWidth="0">
  
<Field>tableEName</Field> 
  
<Type>string</Type> 
  
<Visible>false</Visible>
</Column>
<Column DisTitle="数据开始时间" DisWidth="150">
    
<Field>databtime</Field> 
    
<Type>string</Type> 
    
<Visible>true</Visible> 
</Column>
<Column DisTitle="数据结束时间" DisWidth="150">
    
<Field>dataetime</Field> 
    
<Type>string</Type> 
    
<Visible>true</Visible> 
</Column>
<Column DisTitle="汇总是否成功" DisWidth="300">
  
<Field>collectSuccess</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
<Column DisTitle="是否存在风险" DisWidth="100">
  
<Field>containDanger</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
<Column DisTitle="表描述" DisWidth="300">
  
<Field>discription</Field> 
  
<Type>string</Type> 
  
<Visible>true</Visible>
</Column>
</Head>
    public static List<MyColumn> GetColumnInfo(string fileName, string Node)
        {
            
try
            {
                
string xmlFile = String.Format("{0}\\{1}", System.Windows.Forms.Application.StartupPath, fileName);

                XmlDocument xmldoc 
= new XmlDocument();
                xmldoc.Load(xmlFile);
                
if (xmldoc != null)
                {
                    XmlNode colnode 
= xmldoc.SelectSingleNode(Node);
                    
if (colnode != null)
                    {
                        List
<MyColumn> cols = new List<MyColumn>();
                        
foreach (XmlNode headnode in colnode.ChildNodes)
                        {
                            MyColumn col 
= new MyColumn();
                            col.Caption 
= headnode.Attributes["DisTitle"].Value;
                            col.Width 
= Convert.ToInt32(headnode.Attributes["DisWidth"].Value);
                            col.FieldName 
= headnode.SelectSingleNode("Field").InnerText;
                            col.Visible 
= Convert.ToBoolean(headnode.SelectSingleNode("Visible").InnerText);


                            
string type = headnode.SelectSingleNode("Type").InnerText;

                            
if (String.Compare(type, "int"true== 0 || String.Compare(type, "long"true== 0 || String.Compare(type, "short"true== 0)
                            {
                                col.colType 
= Type.GetType("System.Int64");
                            }
                            
else if (String.Compare(type, "double"true== 0)
                            {
                                col.colType 
= Type.GetType("System.Double");
                            }
                            
else
                            {
                                col.colType 
= Type.GetType("System.String");
                            }
                            cols.Add(col);
                        }

                        
return cols;
                    }
                }
                
return null;
            }
            
catch(Exception ex)
            {
                MessageBox.Show(ex.Message 
+ ex.StackTrace);
                
return null;
            }
        }
posted @ 2010-04-23 12:00 天书 阅读(439) | 评论 (0)编辑 收藏
行款不要设置成自动
列宽要设置成自动
posted @ 2010-04-23 11:57 天书 阅读(2869) | 评论 (1)编辑 收藏
原因在于接口函数中没有用到该类型(也就是说在所有的接口函数中都没有用到这个类型)
posted @ 2010-04-22 15:22 天书 阅读(263) | 评论 (0)编辑 收藏
1: 加GridLevelNode时注意加的位置!!!   不能一味的往顶层节点上加!
 2:一定要把新建的 view放到 viewCollection里面. this.gridControlUserTable.ViewCollection.Add(newGridView)
3:新建的关系名一定要和新建的level保持一致!!!!
4:注意GridView的更新(父GridView的更新)
  private void gridControlUserTable_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                //gridView  datatable  GridLevelNode都用同一个名字
                //ViewCaption中放类别, 1, 用户相关表.  0, 用户无关表
                GridView curView = (DevExpress.XtraGrid.Views.Grid.GridView)gridControlUserTable.FocusedView; //当前的GridView
                curView.MasterRowExpanding += new MasterRowCanExpandEventHandler(curView_MasterRowExpanding);
                curView.MasterRowExpanded += new CustomMasterRowEventHandler(curView_MasterRowExpanded);


                string viewName = curView.Name;
                string id = "view" + icount.ToString();
                int ihandle = curView.FocusedRowHandle; //当前的行号
                DataRow dr = curView.GetDataRow(ihandle); //当前的行


                GridView newGridView = null;
                DataTable newDataTable = null;
                DevExpress.XtraGrid.GridLevelNode gridLevel = null;
                icount++;
                #region 顶层的gridView
                if (curView.Name == "gridViewParent")//顶层的gridView
                {
                    string tableEName = dr["tableEName"].ToString();
                    string supplierRelated = dr["supplierRelated"].ToString();

                    #region 顶层
                    newGridView = new GridView();
                    newGridView.Name = id;
                    newGridView.OptionsView.ShowGroupPanel = false;
                    newGridView.OptionsBehavior.Editable = false;
                    newGridView.OptionsDetail.ShowDetailTabs = false;
                    newGridView.OptionsCustomization.AllowColumnMoving = false;
                    newGridView.OptionsBehavior.AutoExpandAllGroups = true;
                    this.gridControlUserTable.ViewCollection.Add(newGridView);

                    RelatedTableRecord[] relatedTableInfoArray = null;
                    UnrelatedTableRecord[] unRelatedTableInfoArray = null;
                    if (supplierRelated == "1")//厂商相关
                    {

                        relatedTableInfoArray = PublicFunction.GetRelatedTableInfos(tableEName, btime, etime);
                        if (relatedTableInfoArray == null || relatedTableInfoArray.Length == 0)
                        {
                            return;
                        }
                        CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierRelatedColumn.xml", "/Head");
                        newGridView.ViewCaption = "1";
                    }
                    else if (supplierRelated == "0")//厂商无关
                    {

                        unRelatedTableInfoArray = PublicFunction.GetUnRelatedTableInfos(tableEName, "", btime, etime);
                        if (unRelatedTableInfoArray == null || unRelatedTableInfoArray.Length == 0)
                        {
                            return;
                        }
                        CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierUnRelatedColumn.xml", "/Head");
                        newGridView.ViewCaption = "0";
                    }

                    newDataTable = new DataTable(id);
                    CollectCommon.SetDataTableColumn(newGridView, newDataTable);
                    if (supplierRelated == "1")//厂商相关
                    {
                        CollectCommon.FillTableData(newDataTable, relatedTableInfoArray);
                    }
                    else//厂商无关
                    {
                        CollectCommon.FillTableData(newDataTable, unRelatedTableInfoArray);
                    }
                    ds.Tables.Add(newDataTable);

                    gridLevel = new DevExpress.XtraGrid.GridLevelNode();
                    gridLevel.LevelTemplate = newGridView;
                    gridLevel.RelationName = id;

                    gridControlUserTable.LevelTree.Nodes.Add(gridLevel);

                    DataRelation dataRelation = new DataRelation(id, ds.Tables["parent"].Columns["tableEName"], ds.Tables[id].Columns["tableEName"], false);
                    ds.Relations.Add(dataRelation);

                    newGridView.RefreshData();
                    gridViewParent.RefreshData();

                    #endregion
                }
                #endregion
                #region 非顶层表
                else//非顶层表
                {
                    if (curView.ViewCaption == "1")//厂商相关表,再钻取最后一层,厂商无关的信息表,就钻取到头了.
                    {
                        #region
                        string tableEName = dr["tableEName"].ToString();
                        string supplier = dr["supplier"].ToString();
                        UnrelatedTableRecord[] unRelatedTableInfoArray = null;
                        unRelatedTableInfoArray = PublicFunction.GetUnRelatedTableInfos(tableEName, supplier, btime, etime);
                        if (unRelatedTableInfoArray == null || unRelatedTableInfoArray.Length == 0)
                        {
                            return;
                        }
                        newGridView = new GridView();
                        newGridView.Name = id;
                        newGridView.OptionsView.ShowGroupPanel = false;
                        newGridView.OptionsBehavior.Editable = false;
                        newGridView.OptionsDetail.ShowDetailTabs = false;
                        newGridView.OptionsCustomization.AllowColumnMoving = false;
                        newGridView.OptionsBehavior.AutoExpandAllGroups = true;
                        newGridView.ViewCaption = "0";
                        this.gridControlUserTable.ViewCollection.Add(newGridView);

                        CollectCommon.SetGridViewColumn(newGridView, "Config\\CollectMonitor\\supplierUnRelatedColumn.xml", "/Head");

                        newDataTable = new DataTable(id);
                        CollectCommon.SetDataTableColumn(newGridView, newDataTable);
                        CollectCommon.FillTableData(newDataTable, unRelatedTableInfoArray);

                        ds.Tables.Add(newDataTable);

                        gridLevel = new DevExpress.XtraGrid.GridLevelNode();
                        gridLevel.LevelTemplate = newGridView;
                        gridLevel.RelationName = id;

                        string parentTableName = curView.Name;
                        string parentLevelName = curView.Name;

                        //AddGridLevelNode(gridControlUserTable, parentLevelName, gridLevel);
                        
                        gridControlUserTable.LevelTree.Nodes[0].Nodes.Add(gridLevel);

                        DataColumn[] parentColumns = new DataColumn[2];
                        DataColumn[] childColumns = new DataColumn[2];
                        parentColumns[0] = ds.Tables[parentTableName].Columns["tableEName"];
                        parentColumns[1] = ds.Tables[parentTableName].Columns["supplier"];


                        childColumns[0] = ds.Tables[id].Columns["tableEName"];
                        childColumns[1] = ds.Tables[id].Columns["supplier"];

                        DataRelation dataRelation = new DataRelation(id, parentColumns, childColumns, false);
                        //DataRelation dataRelation = new DataRelation(id, parentColumns[0], childColumns[0], false);
                        ds.Relations.Add(dataRelation);
                        curView.RefreshData();
                        
                        #endregion
                    }
                    else if (curView.ViewCaption == "0")//厂商无关表
                    {

                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
posted @ 2010-04-17 18:04 天书 阅读(4304) | 评论 (0)编辑 收藏
原因:
IE浏览器设代理了,把代理去掉就能调起来了。

posted @ 2010-03-15 13:49 天书 阅读(276) | 评论 (0)编辑 收藏
仅列出标题
共13页: 1 2 3 4 5 6 7 8 9 Last 

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜