Пример #1
0
        private void RetrieveDataAndBindCharts()
        {
            int pullRequestId = int.Parse(hfPullRequestID.Value.ToString());
            List <vPredictedObservedTests> POTestsList = PredictedObservedDS.GetCurrentAcceptedTests(pullRequestId);

            bool   newchart      = false;
            string holdFileName  = string.Empty;
            string holdTableName = string.Empty;
            string holdVariable  = string.Empty;
            string holdTitle     = string.Empty;
            string holdPO_Id     = string.Empty;
            string tooltip       = string.Empty;
            //string[] xValues = { "September", "October", "November", "December" };
            //double[] yValues = { 15, 60, 12, 13 };


            List <string> AcceptedXValues = new List <string>();
            List <double> AcceptedYValues = new List <double>();
            List <Color>  AcceptedColours = new List <Color>();
            List <string> CurrentXValues  = new List <string>();
            List <double> CurrentYValues  = new List <double>();
            List <Color>  CurrentColours  = new List <Color>();


            Color currColour, accColour;
            int   chartNo = 0;

            foreach (vPredictedObservedTests item in POTestsList)
            {
                //this is the first instance
                if (holdFileName == string.Empty)
                {
                    holdFileName  = item.FileName;
                    holdTableName = item.TableName;
                    holdVariable  = item.Variable;

                    holdPO_Id = item.PredictedObservedDetailsID.ToString();
                }

                newchart = false;
                if (item.FileName != holdFileName)
                {
                    newchart = true;
                }
                if (item.TableName != holdTableName)
                {
                    newchart = true;
                }
                if (item.Variable != holdVariable)
                {
                    newchart = true;
                }

                if (newchart == true)
                {
                    if ((AcceptedXValues.Count > 0) || (CurrentXValues.Count > 0))
                    {
                        chartNo += 1;
                        tooltip  = string.Format("{0} - {1}", holdFileName, holdTableName);
                        CreateCharts(chartNo, holdVariable, holdPO_Id, tooltip, AcceptedColours.ToArray(), AcceptedXValues.ToArray(), AcceptedYValues.ToArray(),
                                     CurrentColours.ToArray(), CurrentXValues.ToArray(), CurrentYValues.ToArray());
                    }
                    //clear these for next time
                    AcceptedXValues = new List <string>();
                    AcceptedYValues = new List <double>();
                    AcceptedColours = new List <Color>();
                    CurrentXValues  = new List <string>();
                    CurrentYValues  = new List <double>();
                    CurrentColours  = new List <Color>();
                    holdFileName    = item.FileName;
                    holdTableName   = item.TableName;
                    holdVariable    = item.Variable;
                    holdPO_Id       = item.PredictedObservedDetailsID.ToString();
                }

                if ((item.Test != "n") && (item.Test != "RMSE"))
                {
                    if (item.Accepted != null)
                    {
                        AcceptedXValues.Add(item.Test);
                        AcceptedYValues.Add((double)item.Accepted);
                        if (Math.Abs((double)item.Accepted) > 1)
                        {
                            accColour = Color.Black;
                        }
                        else
                        {
                            accColour = Color.Gray;
                        }
                        AcceptedColours.Add(accColour);
                    }

                    if (item.Current != null)
                    {
                        try
                        {
                            CurrentXValues.Add(item.Test);
                            CurrentYValues.Add((double)item.Current);
                            if (Math.Abs((double)item.Current) > 1)
                            {
                                currColour = Color.Orange;
                            }
                            else if (((bool)item.IsImprovement) || ((bool)item.PassedTest))
                            {
                                currColour = Color.Green;
                            }
                            else if (item.Accepted != null)
                            {
                                if ((double)item.Current == (double)item.Accepted)
                                {
                                    currColour = Color.Gray;
                                }
                                else
                                {
                                    currColour = Color.Red;
                                }
                            }
                            else
                            {
                                currColour = Color.Red;
                            }
                            CurrentColours.Add(currColour);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }

            if ((AcceptedXValues.Count > 0) || (CurrentXValues.Count > 0))
            {
                chartNo += 1;
                tooltip  = string.Format("{0} - {1}", holdFileName, holdTableName);
                CreateCharts(chartNo, holdVariable, holdPO_Id, tooltip, AcceptedColours.ToArray(), AcceptedXValues.ToArray(), AcceptedYValues.ToArray(),
                             CurrentColours.ToArray(), CurrentXValues.ToArray(), CurrentYValues.ToArray());
            }
        }
Пример #2
0
        private void RetrieveDataAndBindCharts(PredictedObservedDetail currPODetails)
        {
            //some of the older records may not have this yet.  So find it the old way.
            if ((currPODetails.AcceptedPredictedObservedDetailsID == null) || (currPODetails.AcceptedPredictedObservedDetailsID <= 0))
            {
                //Retrieve the curresponding (parent) ApsimFile for this PredictedObservedDetail
                ApsimFile apsimFile = ApsimFilesDS.GetByID(currPODetails.ApsimFilesID);

                //get the Pull Request Id for the lastest released pull request that is not the current one
                int acceptPullRequestId = ApsimFilesDS.GetLatestMergedPullRequestId(apsimFile.PullRequestId);

                //get the PredictedObservedDetail.ID for the records that match our current record 'matching' criteria
                currPODetails.AcceptedPredictedObservedDetailsID = PredictedObservedDS.GetIDByMatchingDetails(acceptPullRequestId, apsimFile.FileName, currPODetails.TableName,
                                                                                                              currPODetails.PredictedTableName, currPODetails.ObservedTableName, currPODetails.FieldNameUsedForMatch);
            }

            List <vSimulationPredictedObserved> POCurrentValuesList = PredictedObservedDS.GetCurrentAcceptedSimulationValues(currPODetails.ID, (int)currPODetails.AcceptedPredictedObservedDetailsID);
            string        holdVariable = string.Empty, holdSimulationName = string.Empty;
            string        tooltip = string.Empty, textAnnotation = string.Empty;
            List <double> AcceptedXValues = new List <double>();
            List <double> AcceptedYValues = new List <double>();
            List <double> CurrentXValues = new List <double>();
            List <double> CurrentYValues = new List <double>();
            double        maxXYValue = 0;
            bool          newchart = false;
            int           chartNo = 0;

            foreach (vSimulationPredictedObserved item in POCurrentValuesList)
            {
                if (holdVariable == string.Empty)
                {
                    holdVariable       = item.ValueName;
                    holdSimulationName = item.SimulationName;
                    tooltip            = String.Format("{0} - {1}", item.SimulationName, item.ValueName);
                }

                newchart = false;
                //if (item.SimulationName != holdSimulationName) { newchart = true; }
                if (item.ValueName != holdVariable)
                {
                    newchart = true;
                }

                if (newchart == true)
                {
                    //create the chart
                    if ((CurrentXValues.Count > 0) || (AcceptedXValues.Count > 0))
                    {
                        chartNo       += 1;
                        textAnnotation = GetPredictedObservedTests(currPODetails.ID, holdVariable);
                        BindCurrentAcceptedChart(chartNo, holdVariable, currPODetails.ID, tooltip, CurrentXValues.ToArray(), CurrentYValues.ToArray(), AcceptedXValues.ToArray(), AcceptedYValues.ToArray(), maxXYValue, textAnnotation);
                    }
                    //reset the variables
                    AcceptedXValues    = new List <double>();
                    AcceptedYValues    = new List <double>();
                    CurrentXValues     = new List <double>();
                    CurrentYValues     = new List <double>();
                    maxXYValue         = 0;
                    holdVariable       = item.ValueName;
                    holdSimulationName = item.SimulationName;
                }

                if ((item.AcceptedObservedValue != null) && (item.AcceptedPredictedValue != null))
                {
                    AcceptedXValues.Add((double)item.AcceptedObservedValue);
                    AcceptedYValues.Add((double)item.AcceptedPredictedValue);

                    if ((double)item.AcceptedObservedValue > maxXYValue)
                    {
                        maxXYValue = (double)item.AcceptedObservedValue;
                    }
                    if ((double)item.AcceptedPredictedValue > maxXYValue)
                    {
                        maxXYValue = (double)item.AcceptedPredictedValue;
                    }
                }

                if ((item.CurrentObservedValue != null) && (item.CurrentPredictedValue != null))
                {
                    CurrentXValues.Add((double)item.CurrentObservedValue);
                    CurrentYValues.Add((double)item.CurrentPredictedValue);

                    if ((double)item.CurrentObservedValue > maxXYValue)
                    {
                        maxXYValue = (double)item.CurrentObservedValue;
                    }
                    if ((double)item.CurrentPredictedValue > maxXYValue)
                    {
                        maxXYValue = (double)item.CurrentPredictedValue;
                    }
                }
            }
            if ((CurrentXValues.Count > 0) || (AcceptedXValues.Count > 0))
            {
                chartNo       += 1;
                textAnnotation = GetPredictedObservedTests(currPODetails.ID, holdVariable);
                BindCurrentAcceptedChart(chartNo, holdVariable, currPODetails.ID, tooltip, CurrentXValues.ToArray(), CurrentYValues.ToArray(), AcceptedXValues.ToArray(), AcceptedYValues.ToArray(), maxXYValue, textAnnotation);
            }
        }