Esempio n. 1
0
 private void navBarItem10_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee)
 {
     GiGETRateMap giget = new GiGETRateMap();
     var query = from p in giget.mongo_get.QueryMongo()
                 select new
                 {
                     p._id,
                     p.rkey.ip,
                     p.rkey.ip_id,
                     p.rkey.tcp_seq,
                     p.rkey.tcp_nxtseq,
                     p.rkey.tcp_ack,
                     p.rkey.http_request_uri,
                     p.rkey.http_user_agent,
                     p.itface,
                     p.ip_proto,
                     p.min_time,
                     p.max_time,
                     p.get_cnt,
                     p.reponse_cnt,
                     p.reponse_rate,
                     p.reponse_delay,
                     p.packetnum_aggre,
                 };
     clearColumns2();
     var dborder = query.OrderByDescending(e => e.get_cnt).Take(1000);
     gridControl2.DataSource = dborder.AsParallel().ToList();
     gridView2.OptionsView.ColumnAutoWidth = true;
 }
 public static void ExecMultiInterface()
 {
     using (GnGETRateMap giget = new GnGETRateMap())
     {
         giget.CreateCollection();
         Console.WriteLine("GiGETRateMap giget = new GiGETRateMap();;ok");
     }
     GC.Collect();//手工销毁
     using (GiGETRateMap giget = new GiGETRateMap())
     {
         giget.CreateCollection();
         Console.WriteLine("GiGETRateMap giget = new GiGETRateMap();;ok");
     }
     GC.Collect();//手工销毁
     using (GwGETRateMap giget = new GwGETRateMap())
     {
         giget.CreateCollection();
         Console.WriteLine("GiGETRateMap giget = new GiGETRateMap();;ok");
     }
     GC.Collect();//手工销毁
 }
        /*
         *
         * ALTER TABLE [dbo].[GnGiGw_Get2x] ADD PRIMARY KEY CLUSTERED ([PacketNum] ASC,[FileNum] ASC)ON [PRIMARY]
         *
         alter TABLE [Gi_Get2x_Multi]   alter  COLUMN [PacketNum] int  not null
        alter TABLE [Gi_Get2x_Multi]  alter  COLUMN [FileNum] int  not null
        alter table [Gi_Get2x_Multi] add  PRIMARY KEY (PacketNum,FileNum);
         *
         * CREATE INDEX <name> ON <table> (KeyColList) INCLUDE (NonKeyColList)
         *
        CREATE  NONCLUSTERED  INDEX GnGiGw_Get2x_tcp
        ON dbo.GnGiGw_Get2x (ip_dst_host,ip_id,tcp_seq,tcp_nxtseq,tcp_ack,http_request_uri,http_user_agent)
        INCLUDE (PacketTime,Response,Response_delayFirst,PacketNum)
         *
         * 警告! 最大键长度为 900 个字节。索引 'GnGiGw_Get2x_gre' 的最大长度为 2800 个字节。对于某些大值组合,插入/更新操作将失败。
        * */
        private void CreateCollectionTCP()
        {
            GuangZhou_GwGET gw = new GuangZhou_GwGET();
            gw.CommandTimeout = 0;
            gw.ContextOptions.LazyLoadingEnabled = true;
            gw.GnGiGw_Get2x.MergeOption = MergeOption.NoTracking;

            var query = from i in gw.GnGiGw_Get2x
                        where i.ip_proto == this.ip_proto_tcp  //tcp
                        group i by new
                        {
                            ip = i.ip_dst_host,  //tcp
                            ip_id = i.ip_id,   //tcp
                            i.tcp_seq,
                            i.tcp_nxtseq,
                            i.tcp_ack,
                            i.http_request_uri,
                            i.http_user_agent
                        }
                            into ttt
                            select new
                            {
                                rkey = ttt.Key,
                                min_time = ttt.Min(e => e.PacketTime),
                                max_time = ttt.Max(e => e.PacketTime),
                                get_cnt = ttt.Count(),
                                reponse_cnt = ttt.Where(e => e.Response != null).Count(),
                                reponse_rate = 1.0 * ttt.Where(e => e.Response != null).Count() / ttt.Count(),
                                reponse_delay = ttt.Where(e => e.Response != null).Average(e => e.Response_delayFirst),
                                packetnum_arr = ttt.Select(e => new { e.FileNum, e.PacketNum }),//这里返回的是集合
                            };

            //这里完成聚合?2012.8.3
            Parallel.ForEach(query.ToList(), q =>
            {
                GiGETRateMap get = new GiGETRateMap();
                get._id = GenerateId();
                get.rkey = new RelationKeyWords();
                get.rkey.ip = q.rkey.ip;
                get.rkey.ip_id = q.rkey.ip_id;
                get.rkey.tcp_seq = q.rkey.tcp_seq;
                get.rkey.tcp_nxtseq = q.rkey.tcp_nxtseq;
                get.rkey.tcp_ack = q.rkey.tcp_ack;
                get.rkey.http_request_uri = q.rkey.http_request_uri;
                get.rkey.http_user_agent = q.rkey.http_user_agent;
                get.itface = this.ip_itface;
                get.ip_proto = this.ip_proto_tcp; //tcp
                get.min_time = q.min_time;
                get.max_time = q.max_time;
                get.get_cnt = q.get_cnt;
                get.reponse_cnt = q.reponse_cnt;
                get.reponse_rate = q.reponse_rate;
                get.reponse_delay = q.reponse_delay;
                //信令回放
                get.packetnum_aggre = q.packetnum_arr
                    .Select(e => e.FileNum.ToString() + "-" + e.PacketNum.ToString()).Aggregate((a, b) => a + "," + b);//这里进行集合aggre
                //GET_col.Insert(get);
                mongo_get.MongoCol.Insert(get);
            });
        }