protected string GetQuantityGroup(object obj)
 {
     TimeSeriesClasses.ConfidentialityPollutant row = (TimeSeriesClasses.ConfidentialityPollutant)obj;
     return(QuantityFormat.Format(row.QuantityConfidential, row.UnitConfidential));
 }
Beispiel #2
0
 protected string GetTotal(object obj)
 {
     AreaOverview.PollutantData row = (AreaOverview.PollutantData)obj;
     return(QuantityFormat.Format(row.Quantity, row.Unit));
 }
    /// <summary>
    /// Create trend sheet
    /// </summary>
    private void createTrendSheet(TrendReleaseContent type, int facilityid, MediumFilter.Medium medium)
    {
        this.ucStackColumnTime.Visible    = false;
        this.ucStackColumnCompare.Visible = false;
        this.ucYearCompareSeries.Visible  = false;
        this.compareTable.Visible         = false;

        // Get time series data, used by all sub sheets
        List <TimeSeriesClasses.PollutantReleases> data = getTimeSeriesData(facilityid, medium);

        // Time series sheet
        if (type == TrendReleaseContent.TimeSeries)
        {
            ViewState[CONTENT_TYPE] = TrendReleaseContent.TimeSeries;
            if (data != null && data.Count > 0)
            {
                this.ucStackColumnTime.Visible = true;

                // initialize chart

                Color[]           colors      = getColors(medium);
                string[]          labelTexts  = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") };
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None };
                this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, labelTexts);

                List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>();

                foreach (var v in data)
                {
                    string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesTotal"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesAccidentalReleases"), QuantityFormat.Format(v.QuantityAccidental, v.QuantityAccidentalUnit)),
                                                  (v.AccidentalPercent > 0.0) ? String.Format("{0}: {1:F5}%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue"), v.AccidentalPercent) : String.Format("{0}: 0%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue")) };


                    TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
                    {
                        Year    = v.Year,
                        Values  = new double?[] { TimeSeriesUtils.RangeValue(v.QuantityAccidental), TimeSeriesUtils.RangeValue(v.Quantity) - TimeSeriesUtils.RangeValue(v.QuantityAccidental) },
                        ToolTip = ToolTipFormatter.FormatLines(tip)
                    };
                    bars.Add(cd);
                }

                if ((medium == MediumFilter.Medium.Air) || (medium == MediumFilter.Medium.Water))
                {
                    this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYears(bars, showEPER));
                }
                if (medium == MediumFilter.Medium.Soil)
                {
                    this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, showEPER));
                }
            }
        }

        // comparison
        if (type == TrendReleaseContent.Comparison)
        {
            ViewState[CONTENT_TYPE] = TrendReleaseContent.Comparison;

            if (data != null && data.Count > 0)
            {
                this.compareTable.Visible = true;

                // Create chart
                this.ucStackColumnCompare.Visible = true;

                Color[]           colors      = getColors(medium);
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None };
                string[]          labelTexts  = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") };

                this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, labelTexts);
                //this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_TNE, colors, labelTexts);

                // init year combo boxes
                this.ucYearCompareSeries.Visible = true;
                int year1 = this.ucYearCompareSeries.Year1;
                int year2 = this.ucYearCompareSeries.Year2;
                // reset
                resetLabels();

                TimeSeriesClasses.PollutantReleases data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(year1)).Single();
                TimeSeriesClasses.PollutantReleases data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantReleases(year2)).Single();

                bool dataFound = data1 != null || data2 != null;


                if (dataFound)
                {
                    TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData {
                        Year = year1
                    };
                    TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData {
                        Year = year2
                    };

                    if (data1 != null)
                    {
                        dataFrom.Values = new double?[] { data1.QuantityAccidental, data1.Quantity - data1.QuantityAccidental };
                    }

                    if (data2 != null)
                    {
                        dataTo.Values = new double?[] { data2.QuantityAccidental, data2.Quantity - data2.QuantityAccidental };
                    }

                    // from and to bar
                    this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>()
                    {
                        dataFrom, dataTo
                    });
                    updateTableLabels(data1, data2);
                }

                // display that no data found for the selected years
                this.lbNoDataForSelectedYears.Visible = !dataFound;
            }
        }
    }
Beispiel #4
0
    /// <summary>
    /// Create trend sheet
    /// </summary>
    private void createTrendSheet(TrendTransferContent type, int facilityid, string pollutantCode)
    {
        this.ucStackColumnTime.Visible    = false;
        this.ucStackColumnCompare.Visible = false;
        this.ucYearCompareSeries.Visible  = false;
        this.compareTable.Visible         = false;

        // Get time series data, used by all sub sheets
        List <TimeSeriesClasses.PollutantTransfers> data = getTimeSeriesData(facilityid, pollutantCode);

        // Time series sheet
        if (type == TrendTransferContent.TimeSeries)
        {
            ViewState[CONTENT_TYPE] = TrendTransferContent.TimeSeries;
            if (data != null && data.Count > 0)
            {
                this.ucStackColumnTime.Visible = true;

                Color[]           colors      = new Color[] { Global.ColorWasteWater };
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None };

                this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null);
                //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_TNE, colors, null);

                List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>();

                foreach (var v in data)
                {
                    string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Common", "Quantity"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)) };

                    TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
                    {
                        Year    = v.Year,
                        Values  = new double?[] { v.Quantity },
                        ToolTip = ToolTipFormatter.FormatLines(tip)
                    };
                    bars.Add(cd);
                }
                this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYears(bars, showEPER));
            }
        }

        // comparison
        if (type == TrendTransferContent.Comparison)
        {
            ViewState[CONTENT_TYPE] = TrendTransferContent.Comparison;
            if (data != null && data.Count > 0)
            {
                this.compareTable.Visible = true;

                // Create chart
                this.ucStackColumnCompare.Visible = true;

                Color[]           colors      = new Color[] { Global.ColorWasteWater };
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None };
                this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null);
                //this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_TNE, colors, null);

                // init year combo boxes
                this.ucYearCompareSeries.Visible = true;
                int year1 = this.ucYearCompareSeries.Year1;
                int year2 = this.ucYearCompareSeries.Year2;
                // reset
                resetLabels();

                TimeSeriesClasses.PollutantTransfers data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year1)).Single();
                TimeSeriesClasses.PollutantTransfers data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.PollutantTransfers(year2)).Single();

                bool dataFound = data1 != null || data2 != null;


                if (dataFound)
                {
                    TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData {
                        Year = year1
                    };
                    TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData {
                        Year = year2
                    };

                    if (data1 != null)
                    {
                        dataFrom.Values = new double?[] { data1.Quantity };
                    }

                    if (data2 != null)
                    {
                        dataTo.Values = new double?[] { data2.Quantity };
                    }

                    // from and to bar
                    this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>()
                    {
                        dataFrom, dataTo
                    });
                    updateTableLabels(data1, data2);
                }

                // display that no data found for the selected years
                this.lbNoDataForSelectedYears.Visible = !dataFound;
            }
        }
    }
Beispiel #5
0
 public string GetQuantityAccidental(object obj)
 {
     PollutantReleases.ResultFacility row = (PollutantReleases.ResultFacility)obj;
     return(QuantityFormat.Format(row.QuantityAccidental, row.Unit, row.ConfidentialIndicator));
 }
    protected string GetQuantity(object obj)
    {
        FACILITYDETAIL_WASTETRANSFER row = (FACILITYDETAIL_WASTETRANSFER)obj;

        return(QuantityFormat.Format(row.Quantity, row.UnitCode, row.ConfidentialIndicator));
    }
 protected string GetRecovery(object obj)
 {
     WasteTransfers.ResultFacility row = (WasteTransfers.ResultFacility)obj;
     return(QuantityFormat.Format(row.QuantityRecovery, row.QuantityCommonUnit, row.ConfidentialIndicatorRecovery));
 }
    /// <summary>
    /// updateTableReportFacilities
    /// </summary>
    private void updateTable(TimeSeriesClasses.ComparisonWasteTransfer data)
    {
        this.grdCompareDetailsAll.Visible       = true;
        this.grdCompareDetailsBothYears.Visible = true;


        //all facilities
        List <CompareDetailElement> elementsAll = new List <CompareDetailElement>();


        elementsAll.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Total"),
                                                 data != null ? QuantityFormat.Format(data.TotalFrom, CODE_TNE) : String.Empty,
                                                 data != null ? QuantityFormat.Format(data.TotalTo, CODE_TNE) : String.Empty));

        elementsAll.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Recovery"),
                                                 data != null ? QuantityFormat.Format(data.RecoveryFrom, CODE_TNE) : String.Empty,
                                                 data != null ? QuantityFormat.Format(data.RecoveryTo, CODE_TNE) : String.Empty));

        elementsAll.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Disposal"),
                                                 data != null ? QuantityFormat.Format(data.DisposalFrom, CODE_TNE) : String.Empty,
                                                 data != null ? QuantityFormat.Format(data.DisposalTo, CODE_TNE) : String.Empty));

        elementsAll.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Unspecified"),
                                                 data != null ? QuantityFormat.Format(data.UnspecFrom, CODE_TNE) : String.Empty,
                                                 data != null ? QuantityFormat.Format(data.UnspecTo, CODE_TNE) : String.Empty));

        elementsAll.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Facilities"),
                                                 data != null ? NumberFormat.Format(data.FacilitiesFrom) : String.Empty,
                                                 data != null ? NumberFormat.Format(data.FacilitiesTo) : String.Empty));


        //facilites in both years
        List <CompareDetailElement> elementsBothYears = new List <CompareDetailElement>();


        elementsBothYears.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Total"),
                                                       data != null ? QuantityFormat.Format(data.BothTotalFrom, CODE_TNE) : String.Empty,
                                                       data != null ? QuantityFormat.Format(data.BothTotalTo, CODE_TNE) : String.Empty));

        elementsBothYears.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Recovery"),
                                                       data != null ? QuantityFormat.Format(data.BothRecoveryFrom, CODE_TNE) : String.Empty,
                                                       data != null ? QuantityFormat.Format(data.BothRecoveryTo, CODE_TNE) : String.Empty));

        elementsBothYears.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Disposal"),
                                                       data != null ? QuantityFormat.Format(data.BothDisposalFrom, CODE_TNE) : String.Empty,
                                                       data != null ? QuantityFormat.Format(data.BothDisposalTo, CODE_TNE) : String.Empty));

        elementsBothYears.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Unspecified"),
                                                       data != null ? QuantityFormat.Format(data.BothUnspecFrom, CODE_TNE) : String.Empty,
                                                       data != null ? QuantityFormat.Format(data.BothUnspecTo, CODE_TNE) : String.Empty));


        elementsBothYears.Add(new CompareDetailElement(Resources.GetGlobal("Common", "Facilities"),
                                                       data != null ? NumberFormat.Format(data.BothFacilities) : String.Empty,
                                                       data != null ? NumberFormat.Format(data.BothFacilities) : String.Empty));


        // data binding
        this.grdCompareDetailsAll.DataSource = elementsAll;
        grdCompareDetailsAll.DataBind();

        this.grdCompareDetailsBothYears.DataSource = elementsBothYears;
        grdCompareDetailsBothYears.DataBind();
    }
 //protected string GetTreaterSiteCountryCode(object obj)
 //{
 //    return ((QueryLayer.WasteTransfers.ResultHazardousWasteTreater)obj).TreaterSiteCountryCode;
 //}
 protected string GetQuantity(object obj)
 {
     WasteTransfers.ResultHazardousWasteTreater row = (WasteTransfers.ResultHazardousWasteTreater)obj;
     return(QuantityFormat.Format(row.Quantity, row.Unit, row.ConfidentialIndicator));
 }
    protected string GetQuantity(object obj)
    {
        FACILITYDETAIL_POLLUTANTTRANSFER row = (FACILITYDETAIL_POLLUTANTTRANSFER)obj;

        return(QuantityFormat.Format(row.Quantity, row.UnitCode));
    }
 protected string GetNONHWQuantity(object obj)
 {
     AreaOverview.AOWasteTreeListRow row = (AreaOverview.AOWasteTreeListRow)obj;
     return(QuantityFormat.Format(row.GetQuantity(AreaOverview.CODE_NONHW), row.GetUnit(AreaOverview.CODE_NONHW)));
 }
Beispiel #12
0
    /// <summary>
    /// updateTimeSeries
    /// </summary>
    private void updateTimeSeries(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wastetype)
    {
        CurrentWasteType = wastetype;

        // assume data is found
        dataFound(true);

        // result from qyerylayer
        List <TimeSeriesClasses.WasteTransfer> data = WasteTransferTrend.GetTimeSeries(filter, wastetype);

        // no data found, hide controls and leave
        if (data == null || data.Count == 0)
        {
            dataFound(false); return;
        }



        // set report data to table
        this.lvTimeSeriesTable.DataSource = data;
        this.lvTimeSeriesTable.DataBind();

        // init stack column, 3 ranges
        var _colors      = new List <Color>();
        var _legendTexts = new List <string>();
        var _hatchStyles = new List <ChartHatchStyle>();
        var _tips        = new List <string>();
        var _values      = new List <double?>();

        _tips.Add(Resources.GetGlobal("Common", "Year") + ": {0}");
        _tips.Add(Resources.GetGlobal("Common", "Facilities") + ": {0}");


        // When called from the Time Series menu, the treatment filter will be null
        // Then all treatments are displayed
        bool showAll = (filter.WasteTreatmentFilter == null);

        if (showAll || filter.WasteTreatmentFilter.Recovery)
        {
            _colors.Add(Global.ColorWasteRecovery);
            _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentRecovery"));
            _hatchStyles.Add(ChartHatchStyle.None);
        }

        if (showAll || filter.WasteTreatmentFilter.Disposal)
        {
            _colors.Add(Global.ColorWasteDisposal);
            _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentDisposal"));
            _hatchStyles.Add(ChartHatchStyle.None);
        }

        if (showAll || filter.WasteTreatmentFilter.Unspecified)
        {
            _colors.Add(Global.ColorWasteUnspec);
            _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentUnspecified"));
            _hatchStyles.Add(ChartHatchStyle.None);
        }

        Color[]           colors      = _colors.ToArray();
        string[]          legendTexts = _legendTexts.ToArray();
        ChartHatchStyle[] hatchStyles = _hatchStyles.ToArray();

        this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, WasteTransferTrend.CODE_TNE, colors, hatchStyles, legendTexts);

        List <TimeSeriesUtils.BarData> bardata = new List <TimeSeriesUtils.BarData>();


        // loop through data and create tooltip
        foreach (var v in data)
        {
            _values.Clear();
            _tips.Clear();
            _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year));
            _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities));

            if (showAll || filter.WasteTreatmentFilter.Recovery)
            {
                _values.Add(TimeSeriesUtils.RangeValue(v.QuantityRecovery));
                _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Recovery"), QuantityFormat.Format(v.QuantityRecovery, v.QuantityUnit)));
            }
            if (showAll || filter.WasteTreatmentFilter.Disposal)
            {
                _values.Add(TimeSeriesUtils.RangeValue(v.QuantityDisposal));
                _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Disposal"), QuantityFormat.Format(v.QuantityDisposal, v.QuantityUnit)));
            }
            if (showAll || filter.WasteTreatmentFilter.Unspecified)
            {
                _values.Add(TimeSeriesUtils.RangeValue(v.QuantityUnspec));
                _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Unspecified"), QuantityFormat.Format(v.QuantityUnspec, v.QuantityUnit)));
            }

            TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
            {
                Year    = v.Year,
                Values  = _values.ToArray(),
                ToolTip = ToolTipFormatter.FormatLines(_tips.ToArray())
            };
            bardata.Add(cd);
        }

        this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bardata, false));
    }
Beispiel #13
0
 public string GetPercentage(object obj)
 {
     PollutantReleases.ResultFacility row = (PollutantReleases.ResultFacility)obj;
     return(QuantityFormat.FormatPercentage(row.PercentageAccidental));
 }
Beispiel #14
0
    /// <summary>
    /// updateTimeSeries
    /// </summary>
    private void updateTimeSeries(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium)
    {
        CurrentMedium = medium;

        // assume data is found
        dataFound(true);

        // result from qyerylayer
        List <TimeSeriesClasses.PollutantReleases> data = PollutantReleaseTrend.GetTimeSeries(filter, medium);;

        if (data == null || data.Count == 0)
        {
            dataFound(false); return;
        }

        // set report data to table
        this.lvTimeSeriesTable.DataSource = data;
        this.lvTimeSeriesTable.DataBind();


        Color[]  colors      = new Color[] {};
        string[] legendTexts = new string[] { Resources.GetGlobal("Common", "Accidental"), Resources.GetGlobal("Common", "Controlled") };

        // init chart. Must be done after table databinding, because missing years are added.
        if (medium.Equals(MediumFilter.Medium.Air))
        {
            colors = new Color[] { Global.ColorAirAccidental, Global.ColorAirTotal };
        }
        else if (medium.Equals(MediumFilter.Medium.Water))
        {
            colors = new Color[] { Global.ColorWaterAccidental, Global.ColorWaterTotal };
        }
        else if (medium.Equals(MediumFilter.Medium.Soil))
        {
            colors = new Color[] { Global.ColorSoilAccidental, Global.ColorSoilTotal };
        }

        ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None };

        this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, legendTexts);
        //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantReleaseTrend.CODE_TNE, colors, legendTexts);

        List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>();

        foreach (var v in data)
        {
            string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year),
                                          String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities),
                                          String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesTotal"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)),
                                          String.Format("{0}: {1}", Resources.GetGlobal("Pollutant", "ReleasesAccidentalReleases"), QuantityFormat.Format(v.QuantityAccidental, v.QuantityAccidentalUnit)),
                                          (v.AccidentalPercent > 0.0) ? String.Format("{0}: {1:F5}%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue"), v.AccidentalPercent) : String.Format("{0}: 0%", Resources.GetGlobal("Pollutant", "ReleasesAccidentalPercentValue")) };

            TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
            {
                Year    = v.Year,
                Values  = new double?[] { TimeSeriesUtils.RangeValue(v.QuantityAccidental), TimeSeriesUtils.RangeValue(v.Quantity) - TimeSeriesUtils.RangeValue(v.QuantityAccidental) },
                ToolTip = ToolTipFormatter.FormatLines(tip)
            };
            bars.Add(cd);
        }

        this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, false));
    }
 protected string GetDisposal(object obj)
 {
     WasteTransfers.ResultFacility row = (WasteTransfers.ResultFacility)obj;
     return(QuantityFormat.Format(row.QuantityDisposal, row.QuantityCommonUnit, row.ConfidentialIndicatorDisposal));
 }
Beispiel #16
0
 protected string GetQuantityUnspecified(object obj)
 {
     WasteTransfers.ResultHazardousWasteRecievingCountry row = (WasteTransfers.ResultHazardousWasteRecievingCountry)obj;
     return(QuantityFormat.Format(row.QuantityUnspecified, row.QuantityCommonUnit));
 }
 protected string GetUnspec(object obj)
 {
     WasteTransfers.ResultFacility row = (WasteTransfers.ResultFacility)obj;
     return(QuantityFormat.Format(row.QuantityUnspecified, row.QuantityCommonUnit, row.ConfidentialIndicatorUnspecified));
 }
        private void Initialize()
        {
            this.initialized = true;
            BindingStringFormat.TryGet(this.binding, out this.bindingQuantityFormat);
            if (!string.IsNullOrEmpty(this.bindingQuantityFormat?.SymbolFormat))
            {
                if (this.ValueFormat != null)
                {
                    this.errorText.AppendLine($"ValueFormat cannot be set when Binding.StringFormat is a unit format.");
                }

                if (this.StringFormat != null)
                {
                    this.errorText.AppendLine($"ValueFormat cannot be set when Binding.StringFormat is a unit format.");
                }
            }

            if (this.quantityFormat != null)
            {
                if (this.ValueFormat != null)
                {
                    this.errorText.AppendLine($"Both ValueFormat and StringFormat cannot be set.");
                }
            }
            else
            {
                if (this.unit != null && this.SymbolFormat != null)
                {
                    this.quantityFormat = FormatCache <AngleUnit> .GetOrCreate(this.ValueFormat, this.unit.Value, this.SymbolFormat.Value);
                }
            }

            if (this.unit == null)
            {
                var hasFmtUnit     = !string.IsNullOrEmpty(this.quantityFormat?.SymbolFormat);
                var hasBindingUnit = !string.IsNullOrEmpty(this.bindingQuantityFormat?.SymbolFormat);
                if (!hasFmtUnit && !hasBindingUnit)
                {
                    this.errorText.AppendLine($"Unit cannot be null.");
                    this.errorText.AppendLine($"Must be specified Explicitly or in StringFormat or in Binding.StringFormat.");
                }
                else if (hasFmtUnit && !hasBindingUnit)
                {
                    this.unit = this.quantityFormat.Unit;
                }
                else if (!hasFmtUnit && hasBindingUnit)
                {
                    this.unit = this.bindingQuantityFormat.Unit;
                }
                else
                {
                    if (this.quantityFormat.Unit != this.bindingQuantityFormat.Unit)
                    {
                        this.errorText.AppendLine($"Ambiguous units StringFormat: {this.quantityFormat.CompositeFormat} Binding.StringFormat: {this.bindingQuantityFormat.CompositeFormat}");
                    }

                    this.unit = this.quantityFormat.Unit;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(this.quantityFormat?.SymbolFormat) &&
                    this.unit != this.quantityFormat.Unit)
                {
                    this.errorText.AppendLine($"Unit is set to '{this.unit}' but StringFormat is '{this.StringFormat.Replace("{0:", string.Empty).Replace("}", string.Empty)}'");
                }

                var hasBindingUnit = !string.IsNullOrEmpty(this.bindingQuantityFormat?.SymbolFormat);
            }

            if (this.UnitInput == Wpf.UnitInput.SymbolRequired)
            {
                if (string.IsNullOrEmpty(this.quantityFormat?.SymbolFormat))
                {
                    if (string.IsNullOrEmpty(this.bindingQuantityFormat?.SymbolFormat))
                    {
                        if (this.unit == null)
                        {
                            this.errorText.AppendLine("UnitInput == SymbolRequired but no unit format is specified");
                        }
                        else if (this.SymbolFormat != null)
                        {
                            this.quantityFormat = FormatCache <AngleUnit> .GetOrCreate(this.ValueFormat, this.unit.Value, this.SymbolFormat.Value);

                            if (this.UnitInput == null)
                            {
                                this.UnitInput = Wpf.UnitInput.SymbolRequired;
                            }
                            else if (this.UnitInput == Wpf.UnitInput.ScalarOnly)
                            {
                                this.errorText.AppendLine("Cannot have ScalarOnly and SymbolFormat specified");
                            }
                        }
                        else
                        {
                            this.quantityFormat = FormatCache <AngleUnit> .GetOrCreate(this.ValueFormat, this.unit.Value);

                            if (this.UnitInput == null)
                            {
                                this.UnitInput = Wpf.UnitInput.ScalarOnly;
                            }
                            else if (this.UnitInput == Wpf.UnitInput.ScalarOnly)
                            {
                                this.errorText.AppendLine("Cannot have ScalarOnly and SymbolFormat specified");
                            }
                        }
                    }
                    else
                    {
                        this.quantityFormat = this.bindingQuantityFormat;
                    }
                }
            }

            if (this.UnitInput == null)
            {
                if (!string.IsNullOrEmpty(this.quantityFormat?.SymbolFormat) ||
                    !string.IsNullOrEmpty(this.bindingQuantityFormat?.SymbolFormat))
                {
                    this.UnitInput = Wpf.UnitInput.SymbolRequired;
                }
            }
        }
    /// <summary>
    /// Create trend sheet
    /// </summary>
    private void createTrendSheet(TrendWasteContent type, int facilityid, WasteTypeFilter.Type waste)
    {
        this.ucStackColumnTime.Visible    = false;
        this.ucStackColumnCompare.Visible = false;
        this.ucYearCompareSeries.Visible  = false;
        this.compareTable.Visible         = false;

        // Get time series data, used by all sub sheets
        List <TimeSeriesClasses.WasteTransfer> data = getTimeSeriesData(facilityid, waste);

        // Time series sheet
        if (type == TrendWasteContent.TimeSeries)
        {
            ViewState[CONTENT_TYPE] = TrendWasteContent.TimeSeries;
            if (data != null && data.Count > 0)
            {
                this.ucStackColumnTime.Visible = true;

                Color[]           colors      = new Color[] { Global.ColorWasteRecovery, Global.ColorWasteDisposal, Global.ColorWasteUnspec };
                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None, ChartHatchStyle.None };
                string[]          legendTexts = new string[] { Resources.GetGlobal("Common", "TreatmentRecovery"),
                                                               Resources.GetGlobal("Common", "TreatmentDisposal"),
                                                               Resources.GetGlobal("Common", "TreatmentUnspecified") };


                // initialize chart
                this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, WasteTransferTrend.CODE_TNE, colors, hatchStyles, legendTexts);

                List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>();

                // add data to chart
                foreach (var v in data)
                {
                    string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Common", "Total"), QuantityFormat.Format(v.QuantityTotal, v.QuantityUnit)),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Common", "Recovery"), QuantityFormat.Format(v.QuantityRecovery, v.QuantityUnit)),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Common", "Disposal"), QuantityFormat.Format(v.QuantityDisposal, v.QuantityUnit)),
                                                  String.Format("{0}: {1}", Resources.GetGlobal("Common", "Unspec"), QuantityFormat.Format(v.QuantityUnspec, v.QuantityUnit)) };

                    TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
                    {
                        Year    = v.Year,
                        Values  = new double?[] { TimeSeriesUtils.RangeValue(v.QuantityRecovery), TimeSeriesUtils.RangeValue(v.QuantityDisposal), TimeSeriesUtils.RangeValue(v.QuantityUnspec) },
                        ToolTip = ToolTipFormatter.FormatLines(tip)
                    };
                    bars.Add(cd);
                }

                //waste was not reported in EPER - hence do not include EPER years.
                this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, false));
            }
        }

        // comparison
        if (type == TrendWasteContent.Comparison)
        {
            ViewState[CONTENT_TYPE] = TrendWasteContent.Comparison;

            if (data != null && data.Count > 0)
            {
                this.compareTable.Visible = true;

                // Create chart
                this.ucStackColumnCompare.Visible = true;

                ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None, ChartHatchStyle.None, ChartHatchStyle.None };

                //Color[] colors = new Color[] { Global.ColorWasteRecovery, Global.ColorWasteDisposal, Global.ColorWasteUnspec };
                //string[] legendTexts = new string[]{Resources.GetGlobal("Common", "TreatmentDisposal"),
                //                                    Resources.GetGlobal("Common", "TreatmentRecovery"),
                //                                    Resources.GetGlobal("Common", "TreatmentUnspecified")};
                Color[]  colors      = new Color[] { Global.ColorWasteRecovery, Global.ColorWasteDisposal, Global.ColorWasteUnspec };
                string[] legendTexts = new string[] { Resources.GetGlobal("Common", "TreatmentRecovery"),
                                                      Resources.GetGlobal("Common", "TreatmentDisposal"),
                                                      Resources.GetGlobal("Common", "TreatmentUnspecified") };

                this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, WasteTransferTrend.CODE_TNE, colors, hatchStyles, legendTexts);

                // init year combo boxes
                this.ucYearCompareSeries.Visible = true;
                int year1 = this.ucYearCompareSeries.Year1;
                int year2 = this.ucYearCompareSeries.Year2;
                // reset
                resetLabels();

                TimeSeriesClasses.WasteTransfer data1 = data.Where(d => d.Year == year1).DefaultIfEmpty(new TimeSeriesClasses.WasteTransfer(year1, waste)).Single();
                TimeSeriesClasses.WasteTransfer data2 = data.Where(d => d.Year == year2).DefaultIfEmpty(new TimeSeriesClasses.WasteTransfer(year2, waste)).Single();

                bool dataFound = data1 != null || data2 != null;


                if (dataFound)
                {
                    TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData {
                        Year = year1
                    };
                    TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData {
                        Year = year2
                    };


                    if (data1 != null)
                    {
                        dataFrom.Values = new double?[] { data1.QuantityRecovery, data1.QuantityDisposal, data1.QuantityUnspec };
                    }

                    if (data2 != null)
                    {
                        dataTo.Values = new double?[] { data2.QuantityRecovery, data2.QuantityDisposal, data2.QuantityUnspec };
                    }

                    // from and to bar
                    this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>()
                    {
                        dataFrom, dataTo
                    });
                    updateTableLabels(data1, data2);
                }

                // display that no data found for the selected years
                this.lbNoDataForSelectedYears.Visible = !dataFound;
            }
        }
    }