private void navBarItem22_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee) { FlowControlOneMs fcos = new FlowControlOneMs(); var query = from p in fcos.QueryMongo() select new { p.BeginFrameNum, p.fcontrol_cnt, p.packet_cnt, p.leak_rate_avg, p.leak_rate_max, p.leak_rate_min, p.bucket_size_avg, p.bucket_size_max, p.bucket_size_min, p.down_packet_rate, p.down_total_len, p.fcm_time, p.bucket_size, p.first_delay, p.leak_rate, }; clearColumns(); var dborder = query.OrderByDescending(e => e.fcontrol_cnt); gridControl1.DataSource = dborder.AsParallel().ToList(); gridView1.OptionsView.ColumnAutoWidth = false; }
//选中其他数据进行研究 /* * use GuangZhou_Gb go SELECT * into [Gb_FlowControlx] FROM gzserver.[GuangZhou_Gb].[dbo].[Gb_FlowControlx] * */ private void navBarItem21_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee) { //var gb = new ExtendedGuangZhou_GbEntities(); Guangzhou_GbEntities gb = new Guangzhou_GbEntities(); gb.ContextOptions.LazyLoadingEnabled = true; gb.Gb_FlowControlx.MergeOption = MergeOption.NoTracking; //GuangZhou_GbEntities gb = new GuangZhou_GbEntities(); //查询 var fc = gb.Gb_FlowControlx.ToLookup(e => new { e.BeginFrameNum, e.PacketNum, //e.PacketTime, e.Flow_Control_time, e.Flow_Control_MsgType, e.bssgp_direction, //e.bssgp_tlli, e.bssgp_ms_bucket_size, e.bssgp_bucket_leak_rate, e.ip_len }, null); //为空更加能加少内存 //MessageBox.Show(fc.Count().ToString()); //转换 var fcl = from p in fc.Select(e => e.Key) let bucket_size = Convert.ToDouble(p.bssgp_ms_bucket_size) / 1000.0 //转换成KByte let leak_rate = Convert.ToDouble(p.bssgp_bucket_leak_rate) / 1000.0 //转化成kbps let Flow_Control_time = DateTime.Parse(p.Flow_Control_time) select new { p.BeginFrameNum, Flow_Control_time, p.PacketNum, p.ip_len, p.Flow_Control_MsgType, p.bssgp_direction, //p.Key.bssgp_tlli, bucket_size, leak_rate, }; //MessageBox.Show(fcl.Count().ToString()); string fc_msg = "BSSGP.FLOW-CONTROL-MS"; //分组 var query = from p in fcl group p by new { p.BeginFrameNum } into ttt select new FlowControlOneMs { _id = ttt.Key.BeginFrameNum, BeginFrameNum = ttt.Key.BeginFrameNum, //ttt.Key.bssgp_tlli, fcontrol_cnt = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Count(), packet_cnt = ttt.Count(), bucket_size_avg = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Average(e => e.bucket_size), bucket_size_min = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Min(e => e.bucket_size), bucket_size_max = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Max(e => e.bucket_size), leak_rate_avg = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Average(e => e.leak_rate), leak_rate_min = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Min(e => e.leak_rate), leak_rate_max = ttt.Where(e => e.Flow_Control_MsgType == fc_msg).Max(e => e.leak_rate), first_delay = ttt.Where(e => e.Flow_Control_MsgType == fc_msg) .OrderBy(e => e.PacketNum) .Select(e => new { fd = (e.Flow_Control_time - ttt.Min(f => f.Flow_Control_time)).TotalMilliseconds }) .Select(e => (e.fd / 1000).ToString("f1")) .Aggregate((a, b) => a + "," + b), leak_rate = ttt.Where(e => e.Flow_Control_MsgType == fc_msg) .OrderBy(e => e.PacketNum) .Select(e => (e.leak_rate).ToString("f1")) .Aggregate((a, b) => a + "," + b), bucket_size = ttt.Where(e => e.Flow_Control_MsgType == fc_msg) .OrderBy(e => e.PacketNum) .Select(e => (e.bucket_size).ToString("f1")) .Aggregate((a, b) => a + "," + b), //用扩展方法实现, 在fc消息之间进行ip.len的累加 down_total_len = ttt // .Where(e => e.bssgp_direction == "Down") .OrderBy(e => e.PacketNum) .AggregateSum(e => (int)e.ip_len, e => e.Flow_Control_MsgType, fc_msg), down_packet_rate = ttt // .Where(e => e.bssgp_direction == "Down") .OrderBy(e => e.PacketNum) .AggregatePacketRate(e => (int)e.ip_len, e => e.Flow_Control_time, e => e.Flow_Control_MsgType, fc_msg), fcm_time = ttt // .Where(e => e.bssgp_direction == "Down") .OrderBy(e => e.PacketNum) .AggregatePacketTime(e => e.Flow_Control_time, e => e.Flow_Control_MsgType, fc_msg), }; FlowControlOneMs fcos = new FlowControlOneMs(); fcos.BulkMongo(query.ToList()); MessageBox.Show("OK"); }