//public void CreateCollection(int step, int bulksize,int filenum)
        public void CreateCollection(int filenum)
        {
            GuangZhou_GbEntities_209 gb = new GuangZhou_GbEntities_209();
            gb.CommandTimeout = 0;
            gb.ContextOptions.LazyLoadingEnabled = true;
            gb.Gb_FlowControly.MergeOption = MergeOption.NoTracking;
            LacCellBvci lcb = new LacCellBvci();
            //List<FlowControlOneBvc> fcob_list = new List<FlowControlOneBvc>();
            //查询
            var fc = from p in gb.Gb_FlowControly.Where(e => e.FileNum == filenum)
                     //.OrderBy(e => e.PacketNum ).Skip(step * bulksize).Take(bulksize)
                     //var fc = from p in gb.Gb_FlowControly
                     select new
                     {
                         p.FileNum,
                         p.PacketNum,
                         p.bssgp_tlli,
                         p.Flow_Control_time,
                         p.ip_src_host,
                         p.ip_dst_host,
                         p.nsip_bvci,
                         p.Flow_Control_MsgType,
                         p.ip_len,
                         p.bssgp_direction,
                         p.bssgp_bmax_default_ms,
                         p.bssgp_bucket_full_ratio,
                         p.bssgp_bucket_leak_rate,
                         p.bssgp_bvc_bucket_size,
                         p.bssgp_ms_bucket_size,
                         p.bssgp_R_default_ms,
                     };

            Parallel.ForEach(fc, p =>
            //foreach (var p in fc.AsParallel().ToList())
            {
                FlowControlOneBvc fcob = new FlowControlOneBvc();
                fcob._id = p.FileNum * 100000000 + p.PacketNum;
                //fcob.FileNum = p.FileNum;
                //fcob.PacketNum = p.PacketNum;
                fcob.tlli = p.bssgp_tlli;
                fcob.Flow_Control_time = DateTime.Parse(p.Flow_Control_time);
                fcob.lac_cell = lcb.GetLacCell(p.ip_src_host, p.ip_dst_host, p.nsip_bvci.ToString());
                fcob.bvci = p.nsip_bvci.ToString();
                fcob.Flow_Control_MsgType = p.Flow_Control_MsgType;
                fcob.ip_len = (int)p.ip_len;
                fcob.bssgp_direction = p.bssgp_direction;
                fcob.bssgp_bmax_default_ms = Convert.ToDouble(p.bssgp_bmax_default_ms) / 1000.0;
                fcob.bssgp_bucket_full_ratio = p.bssgp_bucket_full_ratio;
                fcob.bssgp_bucket_leak_rate = Convert.ToDouble(p.bssgp_bucket_leak_rate) / 1000.0;
                fcob.bssgp_bvc_bucket_size = Convert.ToDouble(p.bssgp_bvc_bucket_size) / 1000.0;
                fcob.bssgp_ms_bucket_size = Convert.ToDouble(p.bssgp_ms_bucket_size) / 1000.0;
                fcob.bssgp_R_default_ms = Convert.ToDouble(p.bssgp_R_default_ms) / 1000.0;

                //Task.Factory.StartNew(() => FCOB_col.Insert(fcob));
                //fcob_list.Add(fcob);
                FCOB_col.Insert(fcob);
                //}
            });

            /*
             *
             * tolist 修改成  asienumble,预计可以解决内存不足的问题
             * */

            //BulkMongo(fcob_list);
            //fcob_list.Clear();
            //var fclook = fc.AsParallel().ToList();

            //var fcl = from p in fclook.AsParallel()
            //          select new FlowControlOneBvc
            //          {
            //              _id = p.PacketNum,
            //              PacketNum = p.PacketNum,
            //              Flow_Control_time = DateTime.Parse(p.Flow_Control_time),
            //              lac_cell = lcb.GetLacCell(p.ip_src_host, p.ip_dst_host, p.nsip_bvci.ToString()),
            //              Flow_Control_MsgType = p.Flow_Control_MsgType,
            //              ip_len = (int)p.ip_len,
            //              bssgp_direction = p.bssgp_direction,
            //              bssgp_bmax_default_ms = Convert.ToDouble(p.bssgp_bmax_default_ms) / 1000.0,
            //              bssgp_bucket_full_ratio = p.bssgp_bucket_full_ratio,
            //              bssgp_bucket_leak_rate = Convert.ToDouble(p.bssgp_bucket_leak_rate) / 1000.0,
            //              bssgp_bvc_bucket_size = Convert.ToDouble(p.bssgp_bvc_bucket_size) / 1000.0,
            //              bssgp_ms_bucket_size = Convert.ToDouble(p.bssgp_ms_bucket_size) / 1000.0,
            //              bssgp_R_default_ms = Convert.ToDouble(p.bssgp_R_default_ms) / 1000.0,
            //          };

            //BulkMongo(fcl.AsParallel().ToList());
        }
 private void navBarItem26_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee)
 {
     LacCellBvci lcb = new LacCellBvci();
     var query = from p in lcb.QueryMongo()
                 select new
                     {
                         p._id,
                         p.lac_cell,
                         p.src,
                         p.dst,
                         p.bvci,
                     };
     clearColumns();
     var dborder = query.OrderBy(e => e.lac_cell);
     gridControl1.DataSource = dborder.AsParallel().ToList();
     gridView1.OptionsView.ColumnAutoWidth = true;
 }
        private void navBarItem30_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee)
        {
            clearColumns();
            FlowControlMapBvc fcmb = new FlowControlMapBvc();
            var bvc = fcmb.QueryMongo().ToList();
            LacCellBvci lcb = new LacCellBvci();
            var cell = from p in lcb.QueryMongo().ToList()
                       group p by p.lac_cell into ttt
                       select new
                       {
                           lac_cell = ttt.Key,
                           bvci_aggre = ttt.Select(e => e.bvci).Aggregate((a, b) => a + "," + b),

                       };
            var query = from p in bvc
                        join q in cell on p.lac_cell equals q.lac_cell
                        select new
                        {
                            p.lac_cell,
                            p.fcb_cnt,
                            p.packet_cnt,
                            p.tlli_cnt,
                            q.bvci_aggre,
                            radio_status = p.msg_distinct_aggre.CountMessage("BSSGP.RADIO-STATUS"),
                            p.ms_leak_rate,
                            p.ms_bucket_size,
                            p.bssgp_bmax_default_ms,
                            p.bssgp_bucket_full_ratio,
                            p.bssgp_bucket_leak_rate,
                            p.bssgp_bvc_bucket_size,
                            p.bssgp_ms_bucket_size,
                            p.bssgp_R_default_ms,
                            p.down_packet_rate,
                            p.down_total_len,
                            p.fcb_delay_aggre,
                            p.fcb_time_aggre,
                            p.msg_distinct_aggre,
                            p.tlli_distinct_aggre
                        };

            gridControl1.DataSource = query.OrderByDescending(e => e.fcb_cnt).AsParallel().ToList();
            gridView1.OptionsView.ColumnAutoWidth = true;
        }
 //先弄一个库出来,
 private void navBarItem24_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs ee)
 {
     LacCellBvci lcb = new LacCellBvci();
     lcb.CreatCollection();
     MessageBox.Show("ok");
 }