Beispiel #1
0
        public CUTS.CumulativePortPerformance FindCumulativePortPerformance(string name)
        {
            // Try to locate the port with the specified name.
            foreach (Control item in this.ports_.Controls)
            {
                if (item is CUTS.CumulativePortPerformance)
                {
                    CUTS.CumulativePortPerformance temp = (CUTS.CumulativePortPerformance)item;

                    if (temp.PortName == name)
                    {
                        return(temp);
                    }
                }
            }

            // Since we could not find the port, we need to create
            // a new port performance control.
            Control control = this.LoadControl("~/controls/CumulativePortPerformance.ascx");

            this.ports_.Controls.Add(control);

            CUTS.CumulativePortPerformance port = (CUTS.CumulativePortPerformance)control;
            port.PortName = name;

            return(port);
        }
        private void CreateControlHeirarchy(bool useviewstate)
        {
            IEnumerable datasrc = this.GetDataSource();

            if (datasrc != null)
            {
                CUTS.ComponentPerformanceGrid     grid     = null;
                CUTS.ComponentPerformanceCategory category = null;
                CUTS.CumulativePortPerformance    inport   = null;

                foreach (object item in datasrc)
                {
                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(item);

                    if (this.data_component_name_ == null)
                    {
                        throw new Exception("DataComponentName property not defined.");
                    }

                    string value = this.GetDataValue(ref props, item, this.data_component_name_);
                    grid = this.FindComponentPerformanceGrid(value);

                    // Create the control for the category of the component. We do
                    // not have to check if the category is for the component since
                    // the grid will be correct.
                    if (this.data_category_name_ == null)
                    {
                        throw new Exception("DataCategoryName property not defined.");
                    }

                    value    = this.GetDataValue(ref props, item, this.data_category_name_);
                    category = grid.FindCategory(value);

                    // Before we can continue reading the metrics, we need to get
                    // the metric's type. This is either 'queue' or 'process'.
                    if (this.data_metric_type_ == null)
                    {
                        throw new Exception("DataMetricType property not defined.");
                    }

                    string metric_type = this.GetDataValue(ref props, item, this.data_metric_type_);

                    if (metric_type != "process" && metric_type != "queue")
                    {
                        throw new Exception("DataMetricType must have value 'queue' or 'process'");
                    }

                    // We have now moved onto the inputs for the component. This
                    // is determined by the source name.
                    if (this.data_src_name_ == null)
                    {
                        throw new Exception("DataSrcName property not defined.");
                    }

                    value  = this.GetDataValue(ref props, item, this.data_src_name_);
                    inport = category.FindCumulativePortPerformance(value);

                    // Ok, let's get the performance metrics for this item. We can
                    // do this because regardless of what metrics we are processing,
                    // they will all have the following performance metrics.
                    CUTS.PerformanceTimes perf = new CUTS.PerformanceTimes();
                    this.GetPerformanceMetrics(ref props, item, ref perf);

                    if (metric_type == "process")
                    {
                        // We have now moved onto the exit points for the input. This
                        // is determined by the destination name.
                        if (this.data_dst_name_ == null)
                        {
                            throw new Exception("DataDstName property not defined.");
                        }

                        value = this.GetDataValue(ref props, item, this.data_dst_name_);

                        if (value != String.Empty)
                        {
                            String url =
                                String.Format("t={0}&c={1}&m={2}&src={3}&dst={4}",
                                              this.GetDataValue(ref props, item, this.data_test_number_),
                                              this.GetDataValue(ref props, item, this.data_component_id_),
                                              metric_type,
                                              this.GetDataValue(ref props, item, this.data_src_id_),
                                              this.GetDataValue(ref props, item, this.data_dst_id_));

                            // Set the values of the exit point.
                            CUTS.CumulativeExitPoint ep = new CumulativeExitPoint();

                            ep.Name             = value;
                            ep.Performance      = perf;
                            ep.TimelineURLQuery = url;

                            // Insert the exit point in the exit times.
                            inport.InsertExitPoint(ep);
                        }
                        else
                        {
                            String url =
                                String.Format("t={0}&c={1}&m={2}&src={3}",
                                              this.GetDataValue(ref props, item, this.data_test_number_),
                                              this.GetDataValue(ref props, item, this.data_component_id_),
                                              metric_type,
                                              this.GetDataValue(ref props, item, this.data_src_id_));

                            // Save the performance metric in the service time.
                            inport.ServiceTime             = perf;
                            inport.ServiceTimelineURLQuery = url;
                        }
                    }
                    else
                    {
                        String url =
                            String.Format("t={0}&c={1}&m={2}&src={3}",
                                          this.GetDataValue(ref props, item, this.data_test_number_),
                                          this.GetDataValue(ref props, item, this.data_component_id_),
                                          metric_type,
                                          this.GetDataValue(ref props, item, this.data_src_id_));

                        // Save the performance metric in the queuing time.
                        inport.QueuingTime = perf;
                        inport.QueueingTimelineURLQuery = url;
                    }
                }
            }
        }