コード例 #1
0
        private List <Hashtable> SeriesToHashtables(List <Series> listOfSeries)
        {
            List <Hashtable> hashtableList = new List <Hashtable>();

            foreach (Series series in listOfSeries)
            {
                List <object> dataList  = new List <object>();
                Hashtable     hashtable = new Hashtable();
                if (series is LineSeries)
                {
                    LineSeries lineSeries = series as LineSeries;
                    lineSeries.Data.ForEach(
                        (Action <LineSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    lineSeries.Type = LineSeriesType.Line;
                    hashtable       = lineSeries.ToHashtable();
                }
                if (series is SplineSeries)
                {
                    SplineSeries splineSeries = series as SplineSeries;
                    splineSeries.Data.ForEach((Action <SplineSeriesData>)(data =>
                                                                          dataList.Add((object)data.ToHashtable())));
                    splineSeries.Type = SplineSeriesType.Spline;
                    hashtable         = splineSeries.ToHashtable();
                }
                if (series is AreaSeries)
                {
                    AreaSeries areaSeries = series as AreaSeries;
                    areaSeries.Data.ForEach(
                        (Action <AreaSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    areaSeries.Type = AreaSeriesType.Area;
                    hashtable       = areaSeries.ToHashtable();
                }
                if (series is AreasplineSeries)
                {
                    AreasplineSeries areasplineSeries = series as AreasplineSeries;
                    areasplineSeries.Data.ForEach(
                        (Action <AreasplineSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    areasplineSeries.Type = AreasplineSeriesType.Areaspline;
                    hashtable             = areasplineSeries.ToHashtable();
                }
                if (series is ArearangeSeries)
                {
                    ArearangeSeries arearangeSeries = series as ArearangeSeries;
                    arearangeSeries.Data.ForEach(
                        (Action <ArearangeSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    arearangeSeries.Type = ArearangeSeriesType.Arearange;
                    hashtable            = arearangeSeries.ToHashtable();
                }
                if (series is ColumnrangeSeries)
                {
                    ColumnrangeSeries columnrangeSeries = series as ColumnrangeSeries;
                    columnrangeSeries.Data.ForEach(
                        (Action <ColumnrangeSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    columnrangeSeries.Type = ColumnrangeSeriesType.Columnrange;
                    hashtable = columnrangeSeries.ToHashtable();
                }
                if (series is BarSeries)
                {
                    BarSeries barSeries = series as BarSeries;
                    barSeries.Data.ForEach((Action <BarSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    barSeries.Type = BarSeriesType.Bar;
                    hashtable      = barSeries.ToHashtable();
                }
                if (series is ColumnSeries)
                {
                    ColumnSeries columnSeries = series as ColumnSeries;
                    columnSeries.Data.ForEach((Action <ColumnSeriesData>)(data =>
                                                                          dataList.Add((object)data.ToHashtable())));
                    columnSeries.Type = ColumnSeriesType.Column;
                    hashtable         = columnSeries.ToHashtable();
                }
                if (series is PieSeries)
                {
                    PieSeries pieSeries = series as PieSeries;
                    pieSeries.Data.ForEach((Action <PieSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    pieSeries.Type = PieSeriesType.Pie;
                    hashtable      = pieSeries.ToHashtable();
                }
                if (series is ScatterSeries)
                {
                    ScatterSeries scatterSeries = series as ScatterSeries;
                    scatterSeries.Data.ForEach(
                        (Action <ScatterSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    scatterSeries.Type = ScatterSeriesType.Scatter;
                    hashtable          = scatterSeries.ToHashtable();
                }
                if (series is BubbleSeries)
                {
                    BubbleSeries bubbleSeries = series as BubbleSeries;
                    bubbleSeries.Data.ForEach((Action <BubbleSeriesData>)(data =>
                                                                          dataList.Add((object)data.ToHashtable())));
                    bubbleSeries.Type = BubbleSeriesType.Bubble;
                    hashtable         = bubbleSeries.ToHashtable();
                }
                if (series is GaugeSeries)
                {
                    GaugeSeries gaugeSeries = series as GaugeSeries;
                    gaugeSeries.Data.ForEach((Action <GaugeSeriesData>)(data =>
                                                                        dataList.Add((object)data.ToHashtable())));
                    gaugeSeries.Type = GaugeSeriesType.Gauge;
                    hashtable        = gaugeSeries.ToHashtable();
                }
                if (series is SolidgaugeSeries)
                {
                    SolidgaugeSeries solidgaugeSeries = series as SolidgaugeSeries;
                    solidgaugeSeries.Data.ForEach(
                        (Action <SolidgaugeSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    solidgaugeSeries.Type = SolidgaugeSeriesType.Solidgauge;
                    hashtable             = solidgaugeSeries.ToHashtable();
                }
                if (series is HeatmapSeries)
                {
                    HeatmapSeries heatmapSeries = series as HeatmapSeries;
                    heatmapSeries.Data.ForEach(
                        (Action <HeatmapSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    heatmapSeries.Type = HeatmapSeriesType.Heatmap;
                    hashtable          = heatmapSeries.ToHashtable();
                }
                if (series is BoxplotSeries)
                {
                    BoxplotSeries boxplotSeries = series as BoxplotSeries;
                    boxplotSeries.Data.ForEach(
                        (Action <BoxplotSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    boxplotSeries.Type = BoxplotSeriesType.Boxplot;
                    hashtable          = boxplotSeries.ToHashtable();
                }
                if (series is ErrorbarSeries)
                {
                    ErrorbarSeries errorbarSeries = series as ErrorbarSeries;
                    errorbarSeries.Data.ForEach(
                        (Action <ErrorbarSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    errorbarSeries.Type = ErrorbarSeriesType.Errorbar;
                    hashtable           = errorbarSeries.ToHashtable();
                }
                if (series is FunnelSeries)
                {
                    FunnelSeries funnelSeries = series as FunnelSeries;
                    funnelSeries.Data.ForEach((Action <FunnelSeriesData>)(data =>
                                                                          dataList.Add((object)data.ToHashtable())));
                    funnelSeries.Type = FunnelSeriesType.Funnel;
                    hashtable         = funnelSeries.ToHashtable();
                }
                if (series is PyramidSeries)
                {
                    PyramidSeries pyramidSeries = series as PyramidSeries;
                    pyramidSeries.Data.ForEach(
                        (Action <PyramidSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    pyramidSeries.Type = PyramidSeriesType.Pyramid;
                    hashtable          = pyramidSeries.ToHashtable();
                }
                if (series is WaterfallSeries)
                {
                    WaterfallSeries waterfallSeries = series as WaterfallSeries;
                    waterfallSeries.Data.ForEach(
                        (Action <WaterfallSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    waterfallSeries.Type = WaterfallSeriesType.Waterfall;
                    hashtable            = waterfallSeries.ToHashtable();
                }
                if (series is PolygonSeries)
                {
                    PolygonSeries polygonSeries = series as PolygonSeries;
                    polygonSeries.Data.ForEach(
                        (Action <PolygonSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    polygonSeries.Type = PolygonSeriesType.Polygon;
                    hashtable          = polygonSeries.ToHashtable();
                }
                if (series is TreemapSeries)
                {
                    TreemapSeries treemapSeries = series as TreemapSeries;
                    treemapSeries.Data.ForEach(
                        (Action <TreemapSeriesData>)(data => dataList.Add((object)data.ToHashtable())));
                    treemapSeries.Type = TreemapSeriesType.Treemap;
                    hashtable          = treemapSeries.ToHashtable();
                }
                hashtableList.Add(hashtable);
            }
            return(hashtableList);
        }
コード例 #2
0
        public int MetricSeries(DateTime fromDate, DateTime toDate, decimal[] plantArray)
        {
            int         status = 0;
            int         item   = 0;
            GaugeSeries series;

            this.Results.Initialize();

            QSAttribute atr;
            bool        isAttribute;

            if ((isAttribute = Enum.TryParse(this.Calculation, out atr)) == false)
            {
                this.SetScopeRef(this.Calculation);
            }

            List <object> foList = new List <object>();
            string        text   = "";

            switch (this.Seriesorder)
            {
            case QSCalcsCtl.SeriesOrder.MeasureSeries:
                switch (this.MetricScope)
                {
                case "plant":
                    foList = this.RecordList.Where(r => plantArray.Contains(r.PlantResponsible.PLANT_ID)).Select(r => (object)r.PlantResponsible).Distinct().ToList();
                    break;

                case "plantResp":
                    foList = this.RecordList.Select(r => (object)r.PlantResponsible).Distinct().ToList();
                    break;

                case "plantDetect":
                    foList = this.RecordList.Select(r => (object)r.Plant).Distinct().ToList();
                    break;

                case "person":
                    foList = this.RecordList.Select(r => (object)r.Person).Distinct().ToList();
                    break;

                case "partType":
                    List <string> pat = this.RecordList.Select(r => r.QIIssue.PART_TYPE).Distinct().ToList();
                    foList = SQMModelMgr.SelectPartAttributeList("TYPE", "", false).Where(l => pat.Contains(l.ATTRIBUTE_CD)).Select(l => (object)l).ToList();
                    break;

                case "month":
                    foreach (WebSiteCommon.DatePeriod pd in WebSiteCommon.CalcDatePeriods(fromDate, toDate, DateIntervalType.month, DateSpanOption.FYEffTimespan, ""))
                    {
                        foList.Add(pd);
                    }
                    break;

                default:
                    if ((isAttribute = Enum.TryParse(this.MetricScope, out atr)))
                    {
                        this.SetAttributeRef(atr);
                        foreach (KeyValuePair <string, string> xlat in this.Calc.AttributeXref)
                        {
                            foList.Add(xlat);
                        }
                    }
                    break;
                }

                foreach (string factor in this.GetFactorsByScope(this.Calculation))
                {
                    series = new GaugeSeries().CreateNew(1, factor, "");
                    foreach (object fo in foList)
                    {
                        switch (this.MetricScope)
                        {
                        case "plant":
                        case "plantDetect":
                        case "plantResp":
                            text = ((PLANT)fo).PLANT_NAME;
                            this.FilterByPlant(new decimal[1] {
                                ((PLANT)fo).PLANT_ID
                            });
                            break;

                        case "person":
                            text = SQMModelMgr.FormatPersonListItem((PERSON)fo);
                            this.FilterByPerson(new decimal[1] {
                                ((PERSON)fo).PERSON_ID
                            });
                            break;

                        case "partType":
                            text = ((PART_ATTRIBUTE)fo).ATTRIBUTE_VALUE;
                            this.FilterByPartType(new string[1] {
                                ((PART_ATTRIBUTE)fo).ATTRIBUTE_CD
                            });
                            break;

                        case "month":
                            WebSiteCommon.DatePeriod pd = (WebSiteCommon.DatePeriod)fo;
                            text = pd.Label;
                            this.FilterByDate(pd.FromDate, pd.ToDate);
                            break;

                        default:
                            text = ((KeyValuePair <string, string>)fo).Value;
                            this.FilterByAttribute(this.MetricScope, new string[1] {
                                ((KeyValuePair <string, string>)fo).Key
                            });
                            break;
                        }

                        this.MetricFactor(plantArray, new decimal[0] {
                        }, fromDate, toDate, factor, "", null);
                        if (this.Results.ValidResult)
                        {
                            series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, item++, text, this.Results));
                        }
                    }
                    this.Results.metricSeries.Add(series);
                }
                break;

            case QSCalcsCtl.SeriesOrder.SumAll:
                if (isAttribute)
                {
                    this.InitCalc();
                    this.SetAttributeRef(atr);
                    GaugeSeries sumSeries = new GaugeSeries().CreateNew(0, "", "");
                    foreach (KeyValuePair <string, string> xlat in this.Calc.AttributeXref)
                    {
                        if (this.MetricFactor(plantArray, new decimal[0] {
                        }, fromDate, toDate, this.Calculation, xlat.Key, null) > 0)
                        {
                            sumSeries.ItemList.Add(new GaugeSeriesItem().CreateNew(1, item++, 0, this.Results.Result, xlat.Value));
                        }
                    }
                    if (sumSeries.ItemList.Count > 0)
                    {
                        this.Results.metricSeries.Add(sumSeries);
                    }

                    if (this.Results.metricSeries.Count > 0)
                    {
                        this.Results.ValidResult = true;
                    }

                    if (this.Stat == SStat.pct)      // transform series from values to percentages
                    {
                        this.Results.TransformSeries(this.Stat, EHSCalcsCtl.SeriesOrder.MeasureSeries);
                    }
                }
                break;

            default:
                break;
            }
            return(status);
        }
コード例 #3
0
        public int MetricSeries(EHSCalcsCtl.SeriesOrder seriesOrder, decimal[] plantIDS, string targetScope)
        {
            int         status = 0;
            int         item   = 0;
            GaugeSeries series = null;

            this.Results.Initialize();
            PLANT plant = null;

            switch (seriesOrder)
            {
            case EHSCalcsCtl.SeriesOrder.PlantMeasure:
                int numYears   = this.ToDate.Year - this.FromDate.Year + 1;
                int numPeriods = ((this.ToDate.Year - this.FromDate.Year) * 12) + (this.ToDate.Month - this.FromDate.Month) + 1;
                foreach (decimal plantID in plantIDS)
                {
                    try
                    {
                        if (plantID > 0)
                        {
                            plant  = SQMModelMgr.LookupPlant(plantID);
                            series = new GaugeSeries().CreateNew(1, plant.PLANT_NAME, "");
                        }
                        else
                        {
                            series = new GaugeSeries().CreateNew(1, "overall", "");
                        }

                        for (int n = 0; n < numPeriods; n++)
                        {
                            DateTime thePeriod = this.FromDate.AddMonths(n);
                            if (TargetMetric(targetScope, new decimal[1] {
                                plantID
                            }, thePeriod) >= 0 && this.Results.ValidResult)
                            {
                                series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, n + 1, 0, this.Results.Result, SQMBasePage.FormatDate(thePeriod, "yyyy/MM", false)));
                            }
                            else
                            {
                                series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, n + 1, 0, 0, SQMBasePage.FormatDate(thePeriod, "yyyy/MM", false)));
                            }
                        }

                        this.Results.metricSeries.Add(series);
                    }
                    catch
                    {
                    }
                }
                break;

            default:
                series = new GaugeSeries().CreateNew(1, "", "");
                foreach (decimal plantID in plantIDS)
                {
                    plant = SQMModelMgr.LookupPlant(plantID);

                    if (TargetMetric(targetScope, new decimal[1] {
                        plantID
                    }, DateTime.MinValue) >= 0 && this.Results.ValidResult)
                    {
                        series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, item++, 0, this.Results.Result, plant.PLANT_NAME));
                        series.Name = this.Results.Text;
                    }
                }
                this.Results.metricSeries.Add(series);
                break;
            }

            if (this.Results.metricSeries.Count > 0)
            {
                this.Results.ValidResult = true;
            }

            return(status);
        }
コード例 #4
0
        protected void ddlChartTypeChange(object sender, EventArgs e)
        {
            divChart.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
            //if (ddlChartType.SelectedValue == "" || HSCalcs().ehsCtl.IncidentHst == null || HSCalcs().ehsCtl.IncidentHst.Count == 0)
            if (ddlChartType.SelectedValue == "")
            {
                pnlChartSection.Style.Add("display", "none");
                lnkChartClose.Visible = lnkPrint.Visible = false;
            }
            else
            {
                //PERSPECTIVE_VIEW view = null;
                //divSummaryCharts.Controls.Clear();

                //view = ViewModel.LookupView(entities, "HSIR", "HSIR", 0);

                //if (view != null)
                //{
                //	PERSPECTIVE_VIEW_ITEM vi = view.PERSPECTIVE_VIEW_ITEM.Where(i => i.ITEM_SEQ.ToString() == ddlChartType.SelectedValue).FirstOrDefault();
                //	if (vi != null)
                //	{
                //		GaugeDefinition ggCfg = new GaugeDefinition().Initialize().ConfigureControl(vi, null, "", false, !string.IsNullOrEmpty(hfwidth.Value) ? Convert.ToInt32(hfwidth.Value) - 62 : 0, 0);
                //		ggCfg.Position = null;
                //		HSCalcs().ehsCtl.SetCalcParams(vi.CALCS_METHOD, vi.CALCS_SCOPE, vi.CALCS_STAT, (int)vi.SERIES_ORDER).IncidentSeries((EHSCalcsCtl.SeriesOrder)vi.SERIES_ORDER, SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToArray(), new DateTime(1900, 1, 1), SessionManager.UserContext.LocalTime.AddYears(100), HSCalcs().ehsCtl.GetIncidentTopics());
                //		uclChart.CreateControl((SQMChartType)vi.CONTROL_TYPE, ggCfg, HSCalcs().ehsCtl.Results, divSummaryCharts);
                //		pnlChartSection.Style.Add("display", "inline");
                //		lnkChartClose.Visible = lnkPrint.Visible = true;
                //		// return;
                //	}
                //}
                divChart.Controls.Clear();
                switch (ddlChartType.SelectedValue)
                {
                case "charts":
                    decimal protection          = 0;
                    decimal protectionTotal     = 0;
                    decimal surveillance        = 0;
                    decimal surveillanceTotal   = 0;
                    decimal manualresponse      = 0;
                    decimal manualresponseTotal = 0;
                    decimal humanelement        = 0;
                    decimal humanelementTotal   = 0;
                    decimal hazards             = 0;
                    decimal hazardsTotal        = 0;
                    decimal maintenence         = 0;
                    decimal maintenenceTotal    = 0;
                    int     iTopic = 0;
                    decimal answerValue;

                    // get the current year results
                    foreach (EHSAuditData audit in HSCalcs().ehsCtl.AuditHst)
                    {
                        foreach (AUDIT_ANSWER answer in audit.Audit.AUDIT_ANSWER)
                        {
                            try
                            {
                                answerValue = Convert.ToInt16(answer.ANSWER_VALUE);
                            }
                            catch
                            {
                                answerValue = 0;
                            }
                            EHSAuditQuestion question = EHSAuditMgr.SelectAuditQuestion(audit.Audit.AUDIT_ID, answer.AUDIT_QUESTION_ID);
                            iTopic = Convert.ToInt16(question.TopicId);
                            switch (iTopic)
                            {
                            case 3:
                                protection      += answerValue;
                                protectionTotal += 3;
                                break;

                            case 4:
                                surveillance      += answerValue;
                                surveillanceTotal += 3;
                                break;

                            case 5:
                                manualresponse      += answerValue;
                                manualresponseTotal += 3;
                                break;

                            case 6:
                                humanelement      += answerValue;
                                humanelementTotal += 3;
                                break;

                            case 7:
                                hazards      += answerValue;
                                hazardsTotal += 3;
                                break;

                            case 8:
                                maintenence      += answerValue;
                                maintenenceTotal += 3;
                                break;
                            }
                        }
                    }
                    List <GaugeSeries> gaugeSeries = new List <GaugeSeries>();
                    GaugeSeries        g           = new GaugeSeries();
                    g.Name = "Percentage";
                    if (protectionTotal > 0)
                    {
                        answerValue = Math.Round((protection / protectionTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Protection"));
                    if (surveillanceTotal > 0)
                    {
                        answerValue = Math.Round((surveillance / surveillanceTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Surveillance"));
                    if (manualresponseTotal > 0)
                    {
                        answerValue = Math.Round((manualresponse / manualresponseTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Manual Response"));
                    if (humanelementTotal > 0)
                    {
                        answerValue = Math.Round((humanelement / humanelementTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Human Element"));
                    if (hazardsTotal > 0)
                    {
                        answerValue = Math.Round((hazards / hazardsTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Hazards"));
                    if (maintenenceTotal > 0)
                    {
                        answerValue = Math.Round((maintenence / maintenenceTotal), 3) * 100;
                    }
                    else
                    {
                        answerValue = 0;
                    }
                    g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Maintenence"));
                    gaugeSeries.Add(g);
                    GaugeDefinition gauge = new GaugeDefinition();
                    gauge.ColorPallete = "chartSeriesColor";
                    //gauge.ContainerHeight = 550;
                    //gauge.ContainerWidth = 550;
                    gauge.ControlType    = 70;
                    gauge.DisplayLabel   = true;
                    gauge.DisplayLegend  = true;
                    gauge.DisplayTitle   = true;
                    gauge.DisplayTooltip = true;
                    gauge.Grouping       = 0;
                    gauge.Height         = 550;
                    gauge.Width          = 650;
                    gauge.ItemVisual     = "CENTER";
                    gauge.MinorTics      = false;
                    gauge.Multiplier     = 0;
                    gauge.ScaleMax       = 100;
                    gauge.ScaleMin       = 0;

                    gauge.Title        = "Audit Summary";
                    gauge.DisplayTitle = false;
                    CalcsResult rslt = new CalcsResult();
                    rslt.metricSeries = gaugeSeries;
                    rslt.Status       = 0;
                    rslt.ValidResult  = true;

                    uclChart.CreateControl(SQMChartType.SpiderChart, gauge, rslt, divChart);
                    pnlChartSection.Style.Add("display", "inline");
                    lnkChartClose.Visible  = lnkPrint.Visible = true;
                    divChart.Visible       = true;
                    divDataResults.Visible = false;
                    break;

                case "report":
                    lnkChartClose.Visible  = lnkPrint.Visible = true;
                    divChart.Visible       = false;
                    divDataResults.Visible = true;
                    break;
                }
            }
        }