//选中其他数据进行研究 /* * 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"); }
/* * use GuangZhou_Gb go SELECT * into [Gb_Flow_Control_MS] FROM gzserver.[GuangZhou_Gb].[dbo].[Gb_Flow_Control_MS] */ private void navBarItem20_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee) { //var gb = new ExtendedGuangZhou_GbEntities(); Guangzhou_GbEntities gb = new Guangzhou_GbEntities(); //GuangZhou_GbEntities gb = new GuangZhou_GbEntities(); //查询 var fc = from p in gb.Gb_Flow_Control_MS select new { p.BeginFrameNum, p.PacketTime, p.PacketNum, p.bssgp_tlli, p.bssgp_ms_bucket_size, p.bssgp_bucket_leak_rate, }; //转换 var fcl = from p in fc.ToList() let bucket_size = Convert.ToInt64(p.bssgp_ms_bucket_size) let leak_rate = Convert.ToInt64(p.bssgp_bucket_leak_rate) select new { p.BeginFrameNum, p.PacketTime, p.PacketNum, p.bssgp_tlli, bucket_size, leak_rate, }; //分组 var query = from p in fcl group p by new { p.BeginFrameNum, p.bssgp_tlli } into ttt select new { ttt.Key.BeginFrameNum, ttt.Key.bssgp_tlli, cnt = ttt.Count(), bucket_size_avg = ttt.Average(e => e.bucket_size) / 1000, bucket_size_min = ttt.Min(e => e.bucket_size) / 1000, bucket_size_max = ttt.Max(e => e.bucket_size) / 1000, leak_rate_avg = ttt.Average(e => e.leak_rate) / 1000, leak_rate_min = ttt.Min(e => e.leak_rate) / 1000, leak_rate_max = ttt.Max(e => e.leak_rate) / 1000, first_delay = ttt.OrderBy(e => e.PacketNum) .Select(e => new { fd = (e.PacketTime.Value - ttt.Min(f => f.PacketTime).Value).TotalSeconds }) .Select(e => ((int)e.fd).ToString()) .Aggregate((a, b) => a + "," + b), leak_rate = ttt.OrderBy(e => e.PacketNum) .Select(e => ((int)e.leak_rate).ToString()) .Aggregate((a, b) => a + "," + b), bucket_size = ttt.OrderBy(e => e.PacketNum) .Select(e => ((int)e.bucket_size).ToString()) .Aggregate((a, b) => a + "," + b), }; clearColumns(); var dborder = query.OrderByDescending(e => e.cnt).Take(100); gridControl1.DataSource = dborder.AsParallel().ToList(); gridView1.OptionsView.ColumnAutoWidth = false; }