Example #1
0
        protected ViewChart FillChartData(Int64 id /*chart id.*/, int width, int height, Guid userId)
        {
            ViewChart viewchart = BaseChartRepository.GetChart(id, userId);

            ViewBag.Width  = (width != -1) ? width : viewchart.Width;
            ViewBag.Height = (height != -1) ? height : viewchart.Height;

            if (viewchart.ChartType.TrimEnd().ToLower() == Diagram.ToLower())
            {
                //  the reference to document is meaningful only for diagrams,
                //  so it can be null
                if (viewchart.DocID != null)
                {
                    List <String> states = ChartRepository.ExportDataElementStates((long)viewchart.DocID, userId);
                    ViewBag.DataStates = states;
                }
                else
                {
                    ViewBag.DataStates = new List <String>();
                }
            }
            else
            {
                var fileNames     = new List <String>();
                var statFileNames = new List <String>();

                var l = viewchart.DataSetType.Trim().ToLower() == LastSeconds?
                        BaseChartRepository.GetPointsVsAcqTime_Stat_LastSeconds(id, userId, viewchart.DataSetMaxCount) :
                            BaseChartRepository.GetPointsVsAcqTime_Stat_Last(id, userId, viewchart.DataSetMaxCount);

                for (int i = 0; i < l.Count(); i++)
                {
                    ViewFile vf = l[i];
                    if (vf.Content.ToLower() == "dataset")
                    {
                        fileNames.Add(vf.FileName);
                    }
                    else if (vf.Content.ToLower() == "datastat")
                    {
                        statFileNames.Add(vf.FileName);
                    }
                }
                ViewBag.FileNames     = fileNames;
                ViewBag.StatFileNames = statFileNames;
            }

            return(viewchart);
        }