private void showContent(string command)
    {
        hideSubControls();

        this.ucSheetLinks.HighLight(command);
        string txt = Resources.GetGlobal("Pollutant", "AllValuesAreYearlyReleases");

        bool conf = PollutantReleaseTrend.IsAffectedByConfidentiality(FacilityBasic.FacilityID, PollutantCode, CurrentMedium);

        string alert = conf ? Resources.GetGlobal("Common", "ConfidentialityAlertLink") : string.Empty;

        if (command.Equals(TrendReleaseContent.TimeSeries.ToString()))
        {
            this.litHeadline.Text   = Resources.GetGlobal("Facility", "PollutantReleaseTimeSeries");
            ViewState[CONTENT_TYPE] = TrendReleaseContent.TimeSeries;
        }
        else if (command.Equals(TrendReleaseContent.Comparison.ToString()))
        {
            this.litHeadline.Text   = Resources.GetGlobal("Facility", "PollutantReleaseComparison");
            ViewState[CONTENT_TYPE] = TrendReleaseContent.Comparison;
        }
        else if (command.Equals(TrendReleaseContent.Confidentiality.ToString()))
        {
            this.litHeadline.Text = Resources.GetGlobal("Facility", "PollutantReleaseConfidentiality");
            this.ucContentConfidentiality.Visible = true;
            this.ucContentConfidentiality.Populate(FacilityBasic.FacilityID, PollutantCode, CurrentMedium);

            ViewState[CONTENT_TYPE] = TrendReleaseContent.Confidentiality;
            alert = string.Empty;
        }

        updateHeader(txt);
        updateAlert(alert);
    }
Esempio n. 2
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);
    }
Esempio n. 3
0
 /// <summary>
 /// Populate charts. Selected year in compare dropdown will be searchyear
 /// </summary>
 public void Populate(PollutantReleasesTimeSeriesFilter filter, int?searchYear)
 {
     SearchFilter = filter;
     SearchYear   = searchYear;
     initializeContentLinks();
     //Only determine once and store in viewstate
     ConfidentialityAffected = PollutantReleaseTrend.IsAffectedByConfidentiality(filter);
     // show timeseries as default
     showContent(Sheets.TimeSeries.TimeSeries.ToString());
 }
Esempio n. 4
0
    public void Populate(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium)
    {
        SearchFilter = filter;
        var counts = PollutantReleaseTrend.GetFacilityCounts(filter);

        this.ucMediumSelector.PopulateMediumRadioButtonList(filter.MediumFilter, medium, counts);

        // check that any relases are selected
        if (!filter.MediumFilter.ReleasesToAir &&
            !filter.MediumFilter.ReleasesToSoil &&
            !filter.MediumFilter.ReleasesToWater)
        {
            dataFound(false);
            return;
        }
    }
    private void showContent(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium)
    {
        CurrentMedium = medium;

        //examine if there exists any confidential data for the medium given
        bool hasConfidentialInformationMedium = PollutantReleaseTrend.IsAffectedByConfidentiality(filter, medium);

        this.divConfidentialityInformation.Visible   = hasConfidentialInformationMedium;
        this.divNoConfidentialityInformation.Visible = !hasConfidentialInformationMedium;

        if (hasConfidentialInformationMedium)
        {
            this.lvConfidentiality.DataSource = PollutantReleaseTrend.GetConfidentialTimeSeries(filter, medium);
            this.lvConfidentiality.DataBind();
        }
    }
Esempio n. 6
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
        {
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Save
    /// </summary>
    protected void doSave(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Create Header
            int    facilityReportId = (int)ViewState[FACILITY_REPORTID];
            string pollutantCode    = PollutantCode;

            bool confidentialityAffected       = PollutantReleaseTrend.IsAffectedByConfidentiality(FacilityBasic.FacilityID, PollutantCode, CurrentMedium);
            Dictionary <string, string> header = CsvHeaderBuilder.GetFacilityTrendHeader(facilityReportId, confidentialityAffected);

            // Create Body
            string mediumName    = LOVResources.MediumName(EnumUtil.GetStringValue(CurrentMedium));
            string codeEPER      = pollutantCode + "EPER";
            string pollutantName = LOVResources.PollutantNameEPER(pollutantCode, codeEPER);
            List <TimeSeriesClasses.PollutantReleases> data = getTimeSeriesData(FacilityBasic.FacilityID, CurrentMedium);

            // dump to file
            string topheader       = csvformat.CreateHeader(header);
            string pollutantHeader = csvformat.GetPollutantReleaseTrendHeader();

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Releases_Time_Series");

            Response.Write(topheader + pollutantHeader);

            foreach (var v in data)
            {
                string row = csvformat.GetPollutantReleaseTrendRow(v, pollutantName, mediumName);
                Response.Write(row);
            }
            Response.End();
        }
        catch
        {
        }
    }
    public void Populate(int facilityid, string pollutantCode, MediumFilter.Medium medium)
    {
        PollutantCode = pollutantCode;
        //set parentcode
        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(pollutantCode);

        ParentCode = null;
        if (pollutant != null && pollutant.ParentID != null)
        {
            LOV_POLLUTANT pollutantGroup = ListOfValues.GetPollutant(pollutant.ParentID.Value);
            ParentCode = pollutantGroup != null ? pollutantGroup.Code : null;
        }

        List <TimeSeriesClasses.ConfidentialityPollutant> data = PollutantReleaseTrend.GetConfidentialTimeSeries(facilityid, pollutantCode, medium);
        bool hasConfidentialInformation = data.Any();

        this.divConfidentialityInformation.Visible   = hasConfidentialInformation;
        this.divNoConfidentialityInformation.Visible = !hasConfidentialInformation;

        this.lvConfidentiality.Visible    = true;
        this.lvConfidentiality.DataSource = data;
        this.lvConfidentiality.DataBind();
    }
    public void Populate(PollutantReleasesTimeSeriesFilter filter, bool hasConfidentialInformation, MediumFilter.Medium medium)
    {
        SearchFilter = filter;

        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(filter.PollutantFilter.PollutantID);

        PollutantCode = pollutant != null ? pollutant.Code : null;

        //set parentcode
        ParentCode = null;
        if (pollutant != null && pollutant.ParentID != null)
        {
            LOV_POLLUTANT pollutantGroup = ListOfValues.GetPollutant(pollutant.ParentID.Value);
            ParentCode = pollutantGroup != null ? pollutantGroup.Code : null;
        }

        this.ucMediumSelector.Visible = hasConfidentialInformation;

        if (hasConfidentialInformation)
        {
            var count = PollutantReleaseTrend.GetFacilityCounts(filter);
            this.ucMediumSelector.PopulateMediumRadioButtonList(filter.MediumFilter, medium, count);
        }
    }
    /// <summary>
    /// updateTimeSeries
    /// </summary>
    private void updateCompareChart(PollutantReleasesTimeSeriesFilter filter, MediumFilter.Medium medium)
    {
        CurrentMedium = medium;

        // view everything, user may select other years to compare
        dataFound(true);

        // init year combo boxes
        int year1 = this.ucYearCompare.Year1;
        int year2 = this.ucYearCompare.Year2;

        // get compare result compare char
        TimeSeriesClasses.ComparisonPollutant result = PollutantReleaseTrend.GetComparisonTimeSeries(filter, year1, year2, medium);
        bool foundData = (result.QuantityFrom != null || result.QuantityTo != null);

        if (foundData)
        {
            Color[] colors = new Color[] { };

            // create compare chart and table
            if (medium.Equals(MediumFilter.Medium.Air))
            {
                colors = new Color[] { Global.ColorAirTotal, Global.ColorAirTotal };
            }
            else if (medium.Equals(MediumFilter.Medium.Water))
            {
                // get report data
                colors = new Color[] { Global.ColorWaterTotal, Global.ColorWaterTotal };
            }
            else if (medium.Equals(MediumFilter.Medium.Soil))
            {
                colors = new Color[] { Global.ColorSoilTotal, Global.ColorSoilTotal };
            }

            ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal };
            string[]          legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") };
            this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantReleaseTrend.CODE_KG, colors, hatchStyles, legendTexts);

            TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData
            {
                Year   = result.YearFrom,
                Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityFrom), TimeSeriesUtils.RangeValue(result.QuantityFrom) - TimeSeriesUtils.RangeValue(result.BothQuantityFrom) },
            };

            TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData
            {
                Year   = result.YearTo,
                Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityTo), TimeSeriesUtils.RangeValue(result.QuantityTo) - TimeSeriesUtils.RangeValue(result.BothQuantityTo) },
            };

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

            // update sinle table
            updateTable(result);
        }
        else
        {
            dataFound(false);
        }
    }
Esempio n. 11
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));
    }