Exemple #1
0
 public YesorNo()
 {
     MongoConnect.MongoConnection();
     MongoConnect.MongoFsConnect();
     MongoConnect.GetFs();
     _mp = new MongoOperation();
     _mp.Connect2Mongo();
 }
Exemple #2
0
        public DataGridView Getcaseinfo()
        {
            //初始化DataGridView
            Caseinfo = new DataGridView();


            Caseinfo.ColumnCount     = 8;
            Caseinfo.Columns[0].Name = "开始时间";
            Caseinfo.Columns[1].Name = "结束时间";
            Caseinfo.Columns[2].Name = "耕地NDVI";
            Caseinfo.Columns[3].Name = "palmer";
            Caseinfo.Columns[4].Name = "SPI";
            Caseinfo.Columns[5].Name = "农作物播种面积";
            Caseinfo.Columns[6].Name = "实际受灾面积";
            Caseinfo.Columns[7].Name = "GDP";

            var chk = new DataGridViewCheckBoxColumn();

            chk.HeaderText = "选择";
            chk.Name       = "chk";

            Caseinfo.Columns.Add(chk);

            MongoConnect.MongoConnection();
            _mp = new MongoOperation();
            _mp.Connect2Mongo();
            _mp.UseCollection("旱灾案例");
            var cases = _mp.FindAll();

            if (!cases.Documents.Any())
            {
                return(Caseinfo);
            }
            foreach (var celvalue in from casedoc in cases.Documents
                     let cel = 0
                               select new List <string>
            {
                casedoc["Time"].ToString(),
                casedoc["EndTime"].ToString(),
                casedoc["NDVI"].ToString(),
                casedoc["Palmer"].ToString(),
                casedoc["SPI"].ToString(),
                casedoc["CropArea"].ToString(),
                casedoc["AffectedCropArea"].ToString(),
                casedoc["GDP"].ToString()
            })
            {
                // ReSharper disable once CoVariantArrayConversion
                Caseinfo.Rows.Add(celvalue.ToArray());
            }

            return(Caseinfo);
        }