Exemple #1
0
        protected override void CreateChildControls()
        {
            StateIndicatorUserControl control = Page.LoadControl(_ascxPath) as StateIndicatorUserControl;

            if (control != null)
            {
                control.webObj = this;
            }
            Controls.Add(control);
        }
Exemple #2
0
        /// <summary>
        /// 获取我的指标(从个人状态指标列表中读取)
        /// </summary>
        /// <returns></returns>
        private void ChartTableData()
        {
            DataTable dtIndex = StateIndicatorUserControl.GetListData(IndicatorListName);//指标列表

            //趋势表格
            _table = new DataTable();
            _table.Columns.Add("Title", typeof(string));
            foreach (DataRow dr in dtIndex.Rows)//找下面的指标规则
            {
                string indexTitle = dr["Title"].ToString();
                _table.Columns.Add(new DataColumn(indexTitle, typeof(int)));
            }
            long userID = StateIndicatorUserControl.GetAuthorID();

            DataTable dtActivity = StateIndicatorUserControl.GetActivityByUser(ListName, userID);//获当前用户的所有状态指标

            if (userID == 0 || dtActivity == null)
            {
                return;
            }
            //获取n天之前的数据,天数作为参数

            DateTime dtFrom = DateTime.Today.AddDays(-CalDays);
            DateTime dtTo   = DateTime.Today.AddDays(1);

            //按每天进行统计
            while (dtFrom < dtTo)
            {
                DataRow[] drsActivty = dtActivity.Select("JudgeDate>='" + dtFrom.ToShortDateString() + "' and JudgeDate<'" + dtFrom.AddDays(1).ToShortDateString() + "'");
                DataRow   drNew      = _table.NewRow();
                drNew["Title"] = dtFrom.ToString("M-d");//按标题进行统计
                if (drsActivty.Length > 0)
                {
                    foreach (DataRow dr in drsActivty)
                    {
                        string title = dr["Index"].ToString();
                        drNew[title] = dr["Value"];
                    }
                }
                else
                {
                    foreach (DataRow dr in dtIndex.Rows)//找下面的指标规则
                    {
                        string indexTitle = dr["Title"].ToString();
                        drNew[indexTitle] = 1;
                    }
                }
                _table.Rows.Add(drNew);
                dtFrom = dtFrom.AddDays(1);
            }
        }