Beispiel #1
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            MongoCollection mongoCol = SystemManager.GetCurrentCollection();
            IMongoQuery     query    = MongoDBHelper.GetQuery(GroupConditionList);
            GroupByDocument groupdoc = new GroupByDocument();

            foreach (CheckBox item in panColumn.Controls)
            {
                if (item.Checked)
                {
                    groupdoc.Add(item.Name, true);
                }
            }
            BsonDocument Initial = new BsonDocument();

            for (int i = 0; i < _conditionCount; i++)
            {
                ctlAddBsonEl ctl = (ctlAddBsonEl)Controls.Find("BsonEl" + (i + 1).ToString(), true)[0];
                if (ctl.IsSetted)
                {
                    Initial.Add(ctl.getElement());
                }
            }

            BsonJavaScript      reduce    = new BsonJavaScript(txtReduceJs.Text);
            BsonJavaScript      finalize  = new BsonJavaScript(txtfinalizeJs.Text);
            List <BsonDocument> resultlst = new List <BsonDocument>();

            try
            {
                ///SkipCnt Reset
                var Result = mongoCol.Group(query, groupdoc, Initial, reduce, finalize);
                //防止错误的条件造成的海量数据
                int Count = 0;
                foreach (var item in Result)
                {
                    if (Count == 1000)
                    {
                        break;
                    }
                    resultlst.Add(item);
                    Count++;
                }
                ;
                MongoDBHelper.FillJSONDataToTextBox(this.txtResult, resultlst, 0);
                if (Count == 1001)
                {
                    this.txtResult.Text = "Too many result,Display first 1000 records" + System.Environment.NewLine + this.txtResult.Text;
                }
                this.txtResult.Select(0, 0);
                tabGroup.SelectedIndex = 4;
            }
            catch (Exception ex)
            {
                MyMessageBox.ShowMessage("Exception", "Exception is Happened", ex.ToString(), true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            MongoCollection mongoCol  = SystemManager.GetCurrentCollection();
            IMongoQuery     query     = MongoDBHelper.GetQuery(GroupConditionList);
            GroupByDocument groupdoc  = new GroupByDocument();
            String          ChartTite = string.Empty;

            foreach (CheckBox item in panColumn.Controls)
            {
                if (item.Checked)
                {
                    groupdoc.Add(item.Name, true);
                    ChartTite += item.Name + ",";
                }
            }
            ChartTite = ChartTite.TrimEnd(",".ToCharArray());
            BsonDocument Initial = new BsonDocument();

            for (int i = 0; i < _conditionCount; i++)
            {
                ctlAddBsonEl ctl = (ctlAddBsonEl)Controls.Find("BsonEl" + (i + 1).ToString(), true)[0];
                if (ctl.IsSetted)
                {
                    Initial.Add(ctl.getElement());
                }
            }

            BsonJavaScript      reduce    = new BsonJavaScript(ctlReduce.Context);
            BsonJavaScript      finalize  = new BsonJavaScript(ctlFinalize.Context);
            List <BsonDocument> resultlst = new List <BsonDocument>();

            try
            {
                ///SkipCnt Reset
                var Result = mongoCol.Group(query, groupdoc, Initial, reduce, finalize);
                //图形化初始化
                chartResult.Series.Clear();
                chartResult.Titles.Clear();
                Series SeriesResult = new Series("Result");

                //防止错误的条件造成的海量数据
                int Count = 0;
                foreach (BsonDocument item in Result)
                {
                    if (Count == 1000)
                    {
                        break;
                    }
                    resultlst.Add(item);
                    //必须带有Count元素
                    DataPoint dPoint = new DataPoint(0, (double)item.GetElement("count").Value);
                    SeriesResult.Points.Add(dPoint);
                    Count++;
                }
                ;
                MongoDBHelper.FillJSONDataToTextBox(this.txtResult, resultlst, 0);
                if (Count == 1001)
                {
                    this.txtResult.Text = "Too many result,Display first 1000 records" + System.Environment.NewLine + this.txtResult.Text;
                }
                this.txtResult.Select(0, 0);
                //图形化加载
                chartResult.Series.Add(SeriesResult);
                chartResult.Titles.Add(ChartTite);
                tabGroup.SelectedIndex = 4;
            }
            catch (Exception ex)
            {
                SystemManager.ExceptionDeal(ex, "Exception", "Exception is Happened");
            }
        }