Exemplo n.º 1
0
    /// <summary>
    /// getTimeSeriesData
    /// </summary>
    private List <TimeSeriesClasses.PollutantReleases> getTimeSeriesData(int facilityid, MediumFilter.Medium medium)
    {
        List <TimeSeriesClasses.PollutantReleases> data = null;

        // look in viewstate first
        if (medium == MediumFilter.Medium.Air)
        {
            data = ViewState[TIMESERIES_AIR] as List <TimeSeriesClasses.PollutantReleases>;
        }
        else if (medium == MediumFilter.Medium.Water)
        {
            data = ViewState[TIMESERIES_WATER] as List <TimeSeriesClasses.PollutantReleases>;
        }


        if ((data == null || data.Count() == 0))
        {
            data = PollutantReleaseTrend.GetTimeSeries(facilityid, PollutantCode, medium);
            if (medium == MediumFilter.Medium.Air)
            {
                ViewState[TIMESERIES_AIR] = data;
            }
            else if (medium == MediumFilter.Medium.Water)
            {
                ViewState[TIMESERIES_WATER] = data;
            }
        }
        return(data);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Save release data
    /// </summary>
    protected void doSave(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Check if current medium is affected confidentiality claims
            bool confidentialityAffected = PollutantReleaseTrend.IsAffectedByConfidentiality(
                SearchFilter,
                CurrentMedium);

            // Create Header
            var header = CsvHeaderBuilder.GetTsPollutantReleasesSearchHeader(SearchFilter,
                                                                             CurrentMedium,
                                                                             confidentialityAffected);

            var data = PollutantReleaseTrend.GetTimeSeries(SearchFilter, CurrentMedium);

            string mediumName    = LOVResources.MediumName(EnumUtil.GetStringValue(CurrentMedium));
            var    pollutant     = ListOfValues.GetPollutant(SearchFilter.PollutantFilter.PollutantID);
            string pollutantName = LOVResources.PollutantName(pollutant.Code);

            // dump to file
            string topheader  = csvformat.CreateHeader(header);
            string rowheaders = csvformat.GetPollutantReleasesTimeSeriesHeader();

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Releases_Time_Series");

            Response.Write(topheader + rowheaders);

            foreach (var v in data)
            {
                string row = csvformat.GetPollutantReleasesTimeSeriesRow(v, pollutantName, mediumName);
                Response.Write(row);
            }
            Response.End();
        }
        catch
        {
        }
    }
Exemplo n.º 3
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));
    }