Exemplo n.º 1
0
        public CUTS.PortPerformance FindPortPerformance(string name)
        {
            // Try to locate the port with the specified name.
            foreach (Control item in this.ports_.Controls)
            {
                if (item is CUTS.PortPerformance)
                {
                    CUTS.PortPerformance temp = (CUTS.PortPerformance)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/PortPerformance.ascx");

            this.ports_.Controls.Add(control);

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

            return(port);
        }
Exemplo n.º 2
0
        private void CreateControlHeirarchy(bool useviewstate)
        {
            // Get an interface pointer to the execution times and baseline
            // tables provided via the datasource.
            IEnumerable execution = this.GetDataSource(this.data_member_);
            IEnumerable baseline  = null;

            if (this.data_member_baseline_ != null)
            {
                baseline = this.GetDataSource(this.data_member_baseline_);
            }

            if (execution != null)
            {
                CUTS.ComponentPerformanceGrid     grid     = null;
                CUTS.ComponentPerformanceCategory category = null;
                CUTS.PortPerformance inport = null;

                foreach (object item in execution)
                {
                    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);

                    if (this.category_heading_ != null)
                    {
                        category.CategoryName = this.category_heading_;
                    }

                    // 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'");
                    }

                    string hostname = string.Empty;

                    if (this.data_member_baseline_ != null)
                    {
                        if (this.data_hostname_ == null)
                        {
                            throw new Exception("DataHostname property not defined");
                        }

                        hostname = this.GetDataValue(ref props, item, this.data_hostname_);
                    }

                    // 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.FindPortPerformance(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_);

                        // Locate baseline metrics for the current performance metrics. This
                        // can be the overall queue/process time, or the exit point times.
                        CUTS.PerformanceTimes perf_baseline = null;

                        if (baseline != null)
                        {
                            this.GetBaselineMetrics(baseline,
                                                    hostname,
                                                    grid.Title,
                                                    metric_type,
                                                    inport.PortName,
                                                    value,
                                                    out perf_baseline);
                        }

                        //if (value != String.Empty)
                        //{
                        //  CUTS.ExitPoint ep = new ExitPoint();

                        //  // Set the values of the exit point. This includes the
                        //  // current observed time and the baseline time.
                        //  ep.Name = value;
                        //  ep.Performance = perf;

                        //  if (baseline != null)
                        //    ep.BaselinePerformance = perf_baseline;

                        //  // Insert the exit point in the exit times.
                        //  inport.InsertExitPoint(ep);
                        //}
                        //else
                        {
                            // Save the performance metric in the service time.
                            inport.ServiceTime = perf;

                            if (baseline != null)
                            {
                                inport.ServiceTimeBaseline = perf_baseline;
                            }
                        }
                    }
                    else
                    {
                        // Check to see if there are baseline metrics for the
                        // queueing time for this port.
                        CUTS.PerformanceTimes perf_baseline = null;

                        if (baseline == null)
                        {
                            this.GetBaselineMetrics(baseline,
                                                    hostname,
                                                    grid.Title,
                                                    metric_type,
                                                    inport.PortName,
                                                    null,
                                                    out perf_baseline);
                        }

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

                        if (baseline != null)
                        {
                            inport.QueuingTimeBaseline = perf_baseline;
                        }
                    }
                }
            }
        }